ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Zoom in Multichart
Posted by Frank on Nov-28-2015 22:31
Hello Peter,

I use ChartDirector in C#, also WinChartViewer. In my issue I have a top chart for analog values and a bottom chart for binary values. For top chart I've implement zooming - like your examples. It's running. Now my issue. When I zoom in/out, I lost synchronism of x-axis from top chart with bottom chart. I mean, xy-zoom in top chart ok, but y-zoom for bottom chart will not work. Important, I need only x-zoom for binary charts (bottom charts). I learn from other threads, that WinChartViewer use only the top chart (my idea to change top chart by use setMainChart to bottom chart, send changes to ViewPort again and reset MainChart to top chart has no effect). How I can synchronize (x)y-zoom for all charts in a MultiChart viewer?
An other issue. I use track label legend in MultiChart Viewer, synchronous track line in all charts, track label flags also fine. Only with track label legend I have trouble. The funktion "dataSet.getLegendIcon()" will not work. As workaround I found following solution "<*img=@Square,color=" +color +",size=8*>", but I'm not happy with it. It is fix and user can't select an own icon.
Now I have question for extend dataset in next versions. Is it possible to add a property "unit" for a dataset? Then can ask dataset for show value with unit for track labels or in other situations. This very helpful for dynamic user configured charts.

Best regards
Frank

  Re: Zoom in Multichart
Posted by Peter Kwan on Dec-01-2015 03:10
Hi Frank,

When the user zooms in/out, the code should redraw the chart. For example, in the
"Simple Zooming and Scrolling" sample code, the "drawChart" function is called. The
function is supposed to draw a chart that reflects what the user has selected for
viewing.

In your case, I suppose in drawChart, you are drawing an analog and a digital chart. In
this case, your code should draw the analog chart and the digital chart based on what
the user has selected. For the x-axis scale, in the sample code, it is using:

viewer.syncDateAxisWithViewPort("x", c.xAxis());

For your case, you can use the same code for both charts, except to change the names:

viewer.syncDateAxisWithViewPort("x2", c2.xAxis());

or your can simply synchronize the bottom x-axis with the top x-axis:

c2.xAxis().syncAxis(c.xAxis());

If you also allows vertical zooming, for the y-axis, you can use:

viewer.syncDateAxisWithViewPort("y", c.yAxis());

You do not need to synchronize the digital chart y-axis with the viewport if you do not
want vertical zooming for the digital chart.

For zooming and scrolling, ChartDirector needs a region to receive mouse input. The
region typically is the plot area of a chart. If it is a MultiChart, you can use setMainChart
to specify which plot area you would like to receive the mouse input. You can also set
the main chart to the MultiChart itself to ask the MultiChart to use the bounded box of all
the plot area in all the charts to receive mouse input. It is like:

m.setMainChart(m);

If you use the latter method, you can zoom in/out or scroll by using the plot area of
either chart. However, if your chart is stacked up, and if you want to zoom vertically,
then the vertical selected region will be ambiguous. For example, the user may select
from the middle of the top chart to the middle of the bottom chart (the selected region
spans both charts). The end result is that the vertical zooming by selection would not
reflect the actually selected region.

Another method you may consider is to simply create two separate charts with two
WinChartViewer controls, and you stacked up the WinChartViewer controls. In this case,
if the user zooms on the top chart, your code can immediately see the bottom chart
viewport to the same as that of the top chart, and update the bottom chart as well as
the top chart. This will allow the two charts to be synchronized.

For using symbols in programmable track cursors in your case, there are two methods:

(a) Do not use MultiChart, but use two WinChartViewer controls. Without the MultiChart,
the symbols will work.

(b) If you must use MultiChart, do not use the dynamic layer of the MultiChart, but the
dynamic layer of the underlying XYChart objects. It is because a symbol defines on the
XYChart only works on the XYChart itself, not the MultiChart.

So instead of something like:

            myMultiTrackCursor((MultiChart)viewer.Chart, viewer.PlotAreaMouseX);
            viewer.updateDisplay();
use:

            MultiChart m = (MultiChart)viewer.Chart;

            // Draw cursor on the XYChart
            XYChart c = (XYChart)m.getChart(0);
            myXYTrackCursor(c, viewer.PlotAreaMouseX);

            XYChart c2 = (XYChart)m.getChart(1);
            myXYTrackCursor(c2, viewer.PlotAreaMouseX);

            // Create the a new MultiChart with the updated XYChart objects
            m = new MultiChart(m.getWidth(), m.getHeight());
            m.addChart(0, 0, c);
            m.addChart(0, c.getHeight(), c2);
            viewer.Chart = m;

            viewer.updateDisplay();


For adding a "property" called "unit", this is basically using the chart object to keep track
of custom information. For this type of usage, we suggest your code to keep track of the
information itself. For example, you can have a separate List or array of Dictionary to
keep track of the unit, so that they can be used in your own code to create the charts
or track cursors.


Regards
Peter Kwan

  Re: Zoom in Multichart
Posted by Frank on Dec-05-2015 23:34
Attachments:
Hi Peter,

your answer not understand. I like zooming, no track labels or others, only synchron zoom of x-axis of both charts in a MultiChart.

It's actual equal, mouse over top chart or bottom chart, must be only in area of MultiChart.
The code for zooming is same as in your examples (zoomBar_ValueChanged(...)). But only top, first added chart, change time range.

What is wrong?

Greeting
Frank
MultiChart_Zoom.png
MultiChart_Zoom_not_synchron.png

  Re: Zoom in Multichart
Posted by Frank on Dec-06-2015 05:16
Hi Peter,

good news to my issue. When I create my charts, I must add:

secondChart.xAxis().syncAxis( firstChart.xAxis() );

No more, zooming for binary chart not useful.

Then all running fine.

Greeting
Frank