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

Message ListMessage List     Post MessagePost Message

  Two questions
Posted by Cho on Jun-11-2018 15:13
Attachments:
Hi,

Q 1.
I want to change the Example "Realtime Chart with Zooming and Scrolling (MFC)" as shown below.
I changed the source code of as shown below but it did not work as expected.

static const int initialFullRange = 60 - 10;

Where should I change it?



Q 2.
// The number of samples per data series used in this demo
static const int sampleSize = 1000;

// The initial full range is set to 60 seconds of data.
static const int initialFullRange = 60;

I want to know the correlation between "initialFullRange" and "sampleSize".
I did not get a clear understanding of these two variables.
I have expressed my understanding as shown below.
Could you explain the supplement?

Regards
Cho
Q1_image.jpg
Q2_image.jpg

  to express more clearly about Question 1.
Posted by Cho on Jun-11-2018 15:19
I want to express more clearly about Question 1.
I always want to update the latest data from the edge of the plot area a little bit before.

  Re: Two questions
Posted by Peter Kwan on Jun-12-2018 03:30
Hi Cho,

Q1. You can consider the gap to be an extension of the x-axis. In this case, you just need to extend the x-axis scale. In the sample code, in the OnChartTimeUpdate method, the original x-axis scale is set with the endDate at the last data point:

double endDate = m_timeStamps[m_currentIndex - 1];

You can extend the endDate for some amount, such as 5 seconds.

double endDate = m_timeStamps[m_currentIndex - 1] + 5;

Note that if you zoom in the chart, the gap will become wider as it is part of the x-axis scale.

Q2. The sampleSize in the sample code refers to the maximum amount of data that the arrays can hold. You can see that the arrays using the sampleSize:

double m_timeStamps[sampleSize];

In a real time chart, the data keeps coming in. If the chart runs for a long time, there will be insufficient memory to store all the data. So we must set a maximum size, which is specified by the sampleSize constant. In the sample code, that limit is set to 10000 points per data series. If the maximum size is reached, the code will remove the oldest 5% of the data, so as to make some space for the new data.

The initialFullRange is the initial x-axis range, which is 60 seconds in the sample code. If the chart grows beyond 60 seconds, the full range will extend automatically.

The sampleSize and the initialFullRange has no correlation. They are independent settings.


Hope this can help.

Regards
Peter Kwan

  Re: Two questions
Posted by Cho on Jun-12-2018 10:06
Hi Peter,

I modified it according to your advice, but when I reached the gap, the graph stopped.

double endDate = m_timeStamps[m_currentIndex - 1] + 5;


But I have successfully implemented the following modification.

Modified code:
Chart::KeepVisibleRange  --->  Chart::ScrollWithMax

// Update the new full data range to include the latest data
bool axisScaleHasChanged = viewer->updateFullRangeH("x", startDate, endDate, Chart::ScrollWithMax);


Thank you for your kind help.

Regards
Cho