I'd like to know if there is a way to detect when the mouse is over the graph line/lines and to be able to acces the data from the dataset corresponding to that point.
Getting this data depends on where you are using the chart.
In a swing application use the mouse listeners from the panel that the chart is displayed in.
On a web page using an image you will not be able to get to the data (as it is only an image), but JFreeChart will generate an image map for you which can call java script on hover.
In a recent project I did something like:
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
String pngLocation = Servlet.saveChartAsPNG(chart, 200, 200, info, request.getPortletSession());
StringWriter sw = new StringWriter();
ChartUtilities.writeImageMap(new PrintWriter(sw), pngLocation, info, false);
Here chart is a JFreeChart with the appropriate flags for what it is you are seeking to do (tool tips, url's, labels)
Related
In my design page, the user will be creating/drawing new shapes, in addition to adding image overlays. I'm finding that any shapes drawn using the drawing manager are rendering underneath any image overlays added to the map, see below:
I'd like to know how to achieve a couple of tasks:
1 - How to set the drawing manager so any shape (rectangle/point/circle etc be default is always added as an upper/top layer when the drawingcomplete event has fired, that way the shapes will always appear above any images added to the map.
2 - How to programatically change the order of the various layers created during design, given the user may want to adjust the z-index of the various layers to suit their own endering requirements.
The MS docs here is not really helping me understand how to achieve the above, but also doesnt mention anything about shapes/layers that currently reside within the drawing manager.
Partial answer but along the right tracks...
We can retrieve the shapes (drawing manager layers) from the drawing manager so we have a reference to them.
When i add an image overlay, before actually adding/rendering it to the map, i would first get the shape layers from the drawing manager, then remove them from the map.
Next we add the image overlay to the map and add the shape layers back in as well, its the order that we add/remove the layers that seems to be relevant here.
Once i had added all layers back to the map in the chosen order, i was still able to put the drawing manager into edit mode and select the shape for editing, so i beleive this will work as my solution going forwards.
// Create the image layer
var imageLayer = new atlas.layer.ImageLayer({
url: 'myImageUrl,
coordinates: coordinates
})
// Then get the existing shapes (layers) from the DM
var layers = drawingManager.getLayers();
console.log(layers);
// Remove the shapes.
map.layers.remove(layers.polygonLayer); // polygonLayer as an example...
// Add new image overlay, then the shapes
map.layers.add([imageLayer, layers.polygonLayer]);
as you can read from the title i want to be able to draw some images on the screen, move them in some direction and video capture the movement with a good fps rate.
I want to specify that i do not want to record the desktop nor some portion of it but the content of the actual window in which the images are moving(so the window can also be minimized). Also if possible i want to be able to set a custom size for my view where everything will happen.
Where i should start from?
I have already tried with WPF but as the UI is single threaded i am not able to take a screenshot of the view while something is moving on it.
What library you would suggest me?
Are there similar open-source projects i can learn from?
Any suggestion i welcomed!
Here's some code I recently wrote to do this, it cycles through a number of frames and renders a control (in this case, a Canvas) into PNGs:
private void Export(int frame)
{
// force the control to update after any changes you've just made
theCanvas.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
// render the control into a bitmap
RenderTargetBitmap bitmap = new RenderTargetBitmap(1920, 1080, 96, 96, PixelFormats.Pbgra32);
bitmap.Render(theCanvas);
// save the bitmap out as a PNG
using (var stream = File.Create($"Animation/Frame_{frame.ToString("D3")}.png"))
{
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
encoder.Save(stream);
}
}
You can then use ffmpeg to pack those PNGs into the movie file format of your choice.
I have created a custom control which has Telerik RadCartesianChart. This custom control creates any number of charts based on user dropdown selection. The number of charts on screen can vary but all have same x axis. I added a chart track ball line on custom control which is working fine on one chart on mouse movement. I want to add the same track ball line on all of the other chart on window so that movement on one track ball would reflect the same position on the other charts.
How could I implement this behavior programmatically?
I don't know if you can do what you are attempting without adding a ChartTrackBallController to every chart.
What I'd suggest is adding multiple series to the one chart, share the X axis but have multiple Y axes as required. This way the ChartTrackBallController will pick a point on all series in the chart.
// Trackball
ChartTrackballController ctbcMain = new ChartTrackballController();
ctbcMain.TextNeeded += ctbcMain_TextNeeded;
ctbcMain.InnerPointSize = new SizeF(0, 0);
ctbcMain.OuterPointsSize = new SizeF(0, 0);
rcvUPM.Controllers.Add(ctbcMain);
rcvUPM.ShowTrackBall = true;
In the above code snippit, rcvUPM is a radchartview containing all the data series you want to show, and ctbcMain_TextNeeded is used to customise the content of what the hover for the trackball shows.
It seems that by default the hover content will contain multiple points from each series, even after the InnerPointSize and OuterPointsSize was set to zero on advice by Telerik support a LINQ FirstOrDefault was needed on the collection of DataPointInfo objects to limit it to one point per series.
We have a system in which we have big plan images loading in multiscale deepzoom images like an image gallery.Images are usually of very high resolutions.
Users have the ability to draw shapes ect on selected deepzoom image.We are using a canves on deepzoom image and save all overlay shapes drwan along with their logical poistion in db.thus the drawn shapes auto sets their position as user pans in or pans out.
We need an automated solution so we can take the printout of all the plan images along with all overlay work done on each deepzoom image.
Currently we are doing this one by one i.e we use Grid,Multistage,Canvas.We load image in Multiscale image,then draw Canves then we use following code to same them in jpeg from Grid(ContentGrid)
SaveFileDialog saveDlg = new SaveFileDialog();
saveDlg.Filter = "JPG Files (*.jpg|*.jpg|*.jpeg|*.jpeg)";
saveDlg.DefaultExt = ".jpg";
if ((bool)saveDlg.ShowDialog())
{
using (Stream fs = saveDlg.OpenFile())
{
SaveToFile(new WriteableBitmap(ContentGrid, null), fs);
}
}
But this solution does not work properly.This throws memory issues when deepzoom image is big one.
We want something like this.For all plans images in gallery we need to loop and programatically convert to jpeg along with canves etc and then save to Amazon s3 by program.An automation will pick all the jpegs and make a single pdf for all those.
or an automated solution.
Please suggest.
Is there a way to detect when the mouse goes over a bar in the chart ?
Take a look at ImageMapUtilities. I added mouseover capabilities by drawing custom XYAnnotations over what I wanted the browser to respond to, and specifying the appropriate tooltip/URLs in the annotation.
(the above is particularly useful for a browser)