|
RealTime Chart |
Posted by Frank on Dec-23-2015 04:11 |
|
Hi Peter,
I have next issue and can't find a solution. Like your example of real time zooming chart I have implement scroll through database history. The output intervall for half or full step left/right not changed. With each query I get new start and end data for x-axis.
The query of database replace your timer_tick function in example.
Different is the thumbnail viewportcontrol. When I comment out follwing code:
// synchronize axis of viewport with viewer
viewer.syncLinearAxisWithViewPort( "xa", mAnalogChart.xAxis() );
if ( has_yAxis_n[1] && (leftAxis1 != null) )
viewer.syncLinearAxisWithViewPort( "y1", leftAxis1 );
if ( has_yAxis_n[2] && (rightAxis1 != null) )
viewer.syncLinearAxisWithViewPort( "y2", rightAxis1 );
if ( has_yAxis_n[3] && (leftAxis2 != null) )
viewer.syncLinearAxisWithViewPort( "y3", leftAxis2 );
if ( has_yAxis_n[4] && (rightAxis2 != null) )
viewer.syncLinearAxisWithViewPort( "y4", rightAxis2 );
if ( has_yAxis_n[5] && (leftAxis3 != null) )
viewer.syncLinearAxisWithViewPort( "y5", leftAxis3 );
if ( has_yAxis_n[6] && (rightAxis3 != null) )
viewer.syncLinearAxisWithViewPort( "y6", rightAxis3 );
if ( has_yAxis_n[7] && (leftAxis4 != null) )
viewer.syncLinearAxisWithViewPort( "y7", leftAxis4 );
if ( has_yAxis_n[8] && (rightAxis4 != null) )
viewer.syncLinearAxisWithViewPort( "y8", rightAxis4 );
all Graphs will drawing in plotarea. With this code, the axis are frozen.
In my picture I call data of half interval left from start. Start and end time are right and same program variables - drawed left from chart. The trackline followed only to end of graph and also show the right end data.
I wondering that all graphs drawn right in viewportcontrol.
Have you an idea, what wrong?
Greeting
Frank
|
Re: RealTime Chart |
Posted by Peter Kwan on Dec-24-2015 04:18 |
|
Hi Frank,
I assume the code in your last message is part of the code that you use to draw the large
chart (not the thumbnail chart in the ViewportControl).
In the original realtime zooming sample code, there are two timers - the data update time,
and the chart update timer. The data update timer updates the data arrays. The chart
update timer updates the viewport and the chart. It may scroll the chart or not scroll that
chart, depending on whether the user is viewing the latest data or historical data. This is by
setting the viewport updateType to either "ScrollWithMax" or "KeepVisibleRange".
For your case, to diagnose the problem, please first unlink the ViewPortControl. In the
ViewPortControl property page, the "Viewer" property can be set to winChartViewer1 or
something similar. Please set it to none instead. If you are setting the
ViewPortControl.Viewer property in code, please set it to null. In this way, the
viewportcontrol should not affect the chart. If the issue is the same, it may be due to the
way your code updates the data and updates the chart. In this case, is it possible to send
your code to me or at latest provide the code that you use to update the viewport when
new data come in?
Regards
Peter Kwan |
Re: RealTime Chart |
Posted by Frank on Dec-29-2015 03:28 |
|
Hi Peter,
removing of Viewer from ViewPortControl has no effect - same behavior. Only removing of axis synchronizations redraw correct chart.
I have no more ideas.
Other issue. How I can show new y-range after load new data, when y-data out of "old" range and y-axis without linear scaling (mean auto scaling)? Other way is reset zoom after load new data - but also need new scaling range for y-axis. How restart autoscaling of y-axis for new dataset?
Greeting
Frank
|
Re: RealTime Chart |
Posted by Peter Kwan on Dec-29-2015 21:59 |
|
Hi Frank,
The purpose of syncLinearAxisWithViewPort is to configure the axis scale in accordance
to the viewport and the full scale. For example, if the full scale is 0 to 1000, and the
viewport is showing the top half, then the axis scale will be set to 500 to 1000.
It means the code like the followings may have some issues:
mAnalogChart.xAxis().setDateScale( viewPortStartDate, viewPortEndDate );
viewer.syncLinearAxisWithViewPort( "xa", mAnalogChart.xAxis() );
The first line of the above code asks ChartDirector to set the x-axis to a date/time scale
from viewPortStartDate to viewPortEndDate. The second line asks ChartDirector to set
the x-axis to a linear scale as according to the viewport and the full range, which may
not be the same as viewPortStartDate to viewPortEndDate. In this case, these two lines
can be contradictory, and the second line will be final x-axis scale. The first line would
then have no effect.
The same applies for code like:
leftAxis2.setLinearScale( trendIdent.yMin, trendIdent.yMax );
viewer.syncLinearAxisWithViewPort( "y3", leftAxis2 );
If the above two lines turn out to be contradictory, the first line will have no effect.
In the special case that the full range is not defined, the second line cannot configure
the axis scale based on the full range and viewport. In this case, it will "learn" the full
range based on the current axis range, which is set by the first line.
In your code, it does not set the full range for the y-axis. So, the first time the above
code is run, it will learn the full range based on the setLinearScale line. Thereafter, the
first line will have no effect. For example, if the trendIdent.yMin, trendIdent.yMax has
changed to other values, the first line cannot set the y-axis scale to the newer values
because the second line will decide the scale.
If you would like to reset the full range, just use setFullRange to set both the upper and
lower limit to 0. It means there is no range. In this case, the second line will re-learn the
full range.
Hope this can help.
Regards
Peter Kwan |
Re: RealTime Chart |
Posted by Frank on Dec-30-2015 03:52 |
|
Hi Peter,
from time to time must discuss the own source code. Now it running, but must Change other points.
As first I correct line
viewer.syncDateAxisWithViewPort( "xa", mAnalogChart.xAxis() );
from
viewer.syncLinearAxisWithViewPort( "xa", mAnalogChart.xAxis() );
You hve right, no linear data. This is a date axis.
For binary Charts I had use right function.
Now I have Change/activate the lines
int updateType = Chart.ScrollWithMin;
and correct the following line
bool xAxisScaleHasChanged = WinChartViewer1.updateFullRangeH( "xa", startDate, endDate, updateType );
from
bool xAxisScaleHasChanged = WinChartViewer1.updateFullRangeH( "x", startDate, endDate, updateType );
Now I use same alias Name for x-axis. That's all.
I'm happy.
What is magic of alias names?
Best regards
Frank |
|