I am building a custom pan/zoom lasso control and am looking at how to find out the exact coordinates of the rectangle relative to the plotted grid area, also be handy for a mouse location based pan/zoom control via the mouse wheel.
It seems to some combination of the ChartviewArea minus the various sizes and marigns for the Chart and the title and the legend plis their sizes.
I haven't had any luck finding them and I haven't had any luck finding the Axes Length and Width.
This will be useful for also adding my own annotations.
Also plan to add a view dataset which will change the number of records displayed depending on the pan zoom controls for my datasets which are from 1 to 16000 dtapoints.
Hopefully if I solve all this I can post up a demo project which handles these various circumstances for complex chart data analysis.
Alternatively would I be better off embedding the Chart control from Reporting to achieve these various features, (probably need to anyway to achieve vector graphic charts for the pdf exports).
Best regards,
Kurt Scholz
LogTag Recorders Ltd
Lead Software Developer
DevCraft Complete
9 Answers, 1 is accepted
Thank you for writing.
Currently there is no way to get the bounding rectangles of the axes or the plot area itself. We are aware of this limitation and will consider some method to address it. At this point in time, I cannot engage with any specific time frame as to when this will happen.
Feel free to write back with any further questions.
Regards,
Ivan Petrov
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Thank you for writing.
I believe that the rectangle defined by the LayoutSlot property can fit your setup:
RadRect rect =
this
.radChartView1.View.Area.AreaModel.PlotArea.LayoutSlot;
I hope this helps. Please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Thank you for writing back.
The LayoutSlot property is defined in the abstract ChartNode class, and you can generally access it as per the snippet I sent you before.
Now I am attaching to this thread a sample project in which I am zooming and panning the different quadrants of the chart using the value of this property.
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
I wasn't able to access the AreaModel previously because I was referencing the wrong version. I switched to 2015 Q3, and I can access the AreaModel and get the PlotArea's LayoutSlot, BUT it's not quite what I need. I need to get the area inside the axes, that corresponds to the actual plotting space of the chart, so I can calculate where on the screen a data point is, and where a data point should be for a screen coordinate. Looking at the children of the AreaModel, there appears to be a Grid property that returns a "CartesianChartGridModel", but it's a property of a derived "CartesianChartAreaModel" class that I can't get a reference to other than through the debugger. I guess it doesn't matter because the LayoutSlot that I can view with the debugger does not have its properties set.
I also looked at the Model.LayoutSlot property of the Axis, but its properties were not set either.
Is there any other way to get the position of the actual plotting space inside the axes, or get the screen coordinates of data points?
Thank you for writing back.
The rectangle inside the axes is defined by the LayoutSlot property plus the offset of the viewport. You can calculate it this way:
RadRect layouSlot =
this
.radChartView1.View.Area.AreaModel.PlotArea.LayoutSlot;
RectangleF plotArea = RectangleF.Empty;
plotArea.X = (
float
)layouSlot.X + (
float
)
this
.radChartView1.View.Viewport.X;
plotArea.Y = (
float
)layouSlot.Y + (
float
)
this
.radChartView1.View.Viewport.Y;
plotArea.Width = (
float
)layouSlot.Width;
plotArea.Height = (
float
)layouSlot.Height;
I hope this information is useful. Please let me know if you need further assistance.
Regards,
Hristo Merdjanov
Telerik