|
Dynamically changing Y axis minimum and maximum value |
Posted by abhishek.mr on May-06-2018 23:02 |
|
Hello,
I have a scenario like dynamically changing Y axis minimum value and maximum value with zoom In , zoom out, Pan and multiple Y axis support. Could you please help me on this and also the layer should sync with y axis and x axis when minimum and maximum value changed
Thanks and Regards,
Abhishek |
Re: Dynamically changing Y axis minimum and maximum value |
Posted by Peter Kwan on May-07-2018 17:16 |
|
Hi abhishek.mr.
Sorry, I am not sure what you mean by "dynamically changing Y axis minimum value and maximum value with zoom in, zoom out, pan".
1. By "Y axis minimum value and maximum value", do you mean the y-axis minimum value and maximum value as displayed on the chart? The y-axis minimum value and maximum value are controlled by the user by using zooming and panning. In our sample code, they are already dynamically updated based on user control (by using mouse wheel, drag to select region, scroll bar, etc).
2. If you are referring to the "full range" of the y-axis, you can use WPFChartViewer.setFullRange to set up the initial range, and WPFChartViewer.updateFullRangeV to dynamically update the full range. See:
http://www.advsofteng.com/doc/cdnet.htm#WPFChartViewer.updateFullRangeV.htm
The "Real-Time Chart with Zooming and Scrolling" sample code demonstrates how to apply the above method to the x-axis. You can apply this method to the y-axis as well.
http://www.advsofteng.com/doc/cdnet.htm#realtimezoomscroll.htm
If you have multiple axes, you can just apply to the the axes one by one. For example, you can set up the axis range with id "y1", "y2", "y3", ... and then update them and sync them with the y-axis (syncLinearAxisWithViewPort).
Regards
Peter Kwan |
Re: Dynamically changing Y axis minimum and maximum value |
Posted by abhishek.mr on May-07-2018 19:39 |
|
Hello Peter,
I am trying to implement Zoom and Pan functionality using liner Y and X axis . My code as per below
public partial class MainWindow : Window
{
XYChart _XYChart;
double[] _DataSet = new double[] { 104, 155, 85, 86, 957, 657, 694, 85, 65, 17};
public MainWindow()
{
InitializeComponent();
InitializeChart(chartViewer);
}
private void InitializeChart(WinChartViewer viewer)
{
if (viewer == null)
{
return;
}
_XYChart = new XYChart(700, 460, 0xf4f4f4, 0x000000, 0);
_XYChart.setPlotArea(40, 10, _XYChart.getWidth() - 120, _XYChart.getHeight()
- 90, 0xffffff, -1, -1, 0xcccccc, Chart.Transparent);
_XYChart.setClipping(0);
_XYChart.yAxis().setLinearScale(0, 100);
LineLayer layer = _XYChart.addLineLayer2();
if (layer == null)
{
return;
}
layer.setLineWidth(2);
layer.addDataSet(_DataSet);
layer.setXData(_DataSet);
chartViewer.syncLinearAxisWithViewPort("y", _XYChart.yAxis());
viewer.Chart = _XYChart;
chartViewer.updateViewPort(true, false);
}
}
In the above sample panning and zoom functionality is not working.
Hope you understand my problem
Thanks and Regards,
Abhishek |
Re: Dynamically changing Y axis minimum and maximum value |
Posted by Peter Kwan on May-08-2018 00:04 |
|
Hi abhishek.mr,
To create a chart that can zoom/pan, please follow the examples included in ChartDirector. In my previous message, I mentioned about the XY Zooming and Scrolling sample code.
http://www.advsofteng.com/doc/cdnet.htm#xyzoomscroll.htm
If you find the above too complicated, you can get started from the "Simple Zooming and Scrolling" sample code:
http://www.advsofteng.com/doc/cdnet.htm#simplezoomscroll.htm
It is also useful to read the ChartDirector documentation on how zooming and scrolling works:
http://www.advsofteng.com/doc/cdnet.htm#zoomscrollintro.htm
If you want zoom/scroll by using the mouse, you need to configure the function of the mouse. (By default, the mouse is used to trigger tooltips and hotspots.) In the sample code above, the mouse can be used for "drag to scroll" or "drag to zoom", and mouse click can be used for "zoom in" or "zoom out" depending on the mode selected by the buttons on the left side.
Then you need to draw the chart in the "ViewPortChanged" event handler, not in InitializeChart.
By following the "Simple Zooming and Scrolling" sample code, you can make the chart zoom/scroll in the x-direction. You can then modify the code to also zoom/scroll in the y-direction (by also syncing the y-axis and set the zoom and scroll to bidirectional - see WinChartViewer.setZoomDirection and WinChartViewer.setScrollDirection).
Regards
Peter Kwan |
|