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

Message ListMessage List     Post MessagePost Message

  How do I create multiple timetrackers on one page?
Posted by Shin on Nov-14-2019 00:41
Attachments:
Hi, I'm shin.

You may not understand because my English is poor.

I used a time tracker example to create a program that puts four time trackers on one page.

However, it is not working normally.

I programmed using mfc.

I created four m_ChartViewer classes to work with each.

When only one chart works, it works normally. However, when there is more than one, abnormal operation occurs.

When you first start with two or more charts, the point moves but no line is visible.

When the point is midway, no single chart is printed at random.

When the point reaches the right end of the chart, the two charts continue to print normally.

At the beginning of the drawChart () function
XYChart * c = new XYChart (600, 150, 0xf4f4f4, 0x000000, 0); At the end of the function, delete viewer-> getChart (); viewer-> setChart (c); Are there any problems with this part?

I hope you can help me.
Error_State.png

  Re: How do I create multiple timetrackers on one page?
Posted by Peter Kwan on Nov-14-2019 15:01
Hi Shin,

For your case, you have 4 charts. Are all the charts update at the same time? For example, all the charts update every 0.2 second. Or all the charts update at different times, such as one chart update every 0.2 second, and another chart updates every 0.76 second?

If the charts update at the same time, you can use a single m_ChartViewer for all the charts. First create a MultiChart. Then add all 4 XYChart objects into the MultiChart to combine them into a large chart. Then add the MultiChart to the m_ChartViewer. You would need to modify the trackLineLegend method to handle MultiChart.

If the charts update at different times, it is better to use multiple m_ChartViewer objects.

I can provide an example to you. Please let me know whether your charts update at the same time or different times?

Regards
Peter Kwan

  Re: How do I create multiple timetrackers on one page?
Posted by Shin on Nov-14-2019 15:23
Thank you for your replay.

It shows one person's data per chart. The change time is the same.

However, some charts may be stuck because they do not receive data.

As you can see in the picture, the two charts are working with data, and the two charts are stuck without receiving data.

In this case, is it better to use multiple m_chartViewers as you said?
Or is it possible to use a single m_ChartViewer?

I want the change time to be the same, but it works for each chart.

I would appreciate it if you provide an example.

Thank you.

  Re: How do I create multiple timetrackers on one page?
Posted by Peter Kwan on Nov-14-2019 16:27
Hi Shin,

If all the charts are updated at the same time, but some charts do not receive data, you can simple use a single m_ChartViewer. For the chart that does not receive data, you can set the data value as Chart::NoValue. For example, the data for one chart can be:

34, 45, 56, 62, 12, ...........

17, 11, Chart::NoValue, 98, 22 ...........

In the above case, the second data series does not receive data value during the 3 period. We can fill the data array with Chart::NoValue. Is this method meet your requirements?

Regards
Peter Kwan

  Re: How do I create multiple timetrackers on one page?
Posted by Shin on Nov-14-2019 18:33
Attachments:
Thank you.

I changed it to multichart and checked it.

drawChart(CChartViewer *viewer)
{
    XYChart *c1 = new XYChart(600, 150, 0xf4f4f4, 0x000000, 0);
    ...
    XYChart *c2 = new XYChart(600, 150, 0xf4f4f4, 0x000000, 0);
    ...
    XYChart *c3 = new XYChart(600, 150, 0xf4f4f4, 0x000000, 0);
    ...
    XYChart *c4 = new XYChart(600, 150, 0xf4f4f4, 0x000000, 0);
    ...

   //create a container 800 x 600 in size
   MultiChart *m = new MultiChart(600, 650);

   //insert first XYChart at (0, 0)
   m->addChart(0, 0, c1);

   //insert first XYChart at (0, 0)
   m->addChart(0, 160, c2);

   //insert first XYChart at (0, 0)
   m->addChart(0, 320, c3);

   //insert first XYChart at (0, 0)
   m->addChart(0, 480, c4);

   // Set the chart image to the WinChartViewer
   delete viewer->getChart();
   viewer->setChart(m);

}

:OnTimer(UINT_PTR nIDEvent)
{
    switch (nIDEvent)
    {
    case DataRateTimer:       // every 250ms
// Is data acquisition timer - get a new data sample
getData();
break;
    case ChartUpdateTimer:  // every 1000ms
        m_ChartViewer.updateViewPort(true, false);
        break;
    }

    CDialog::OnTimer(nIDEvent);
}

:OnViewPortChanged()
{
    drawChart(&m_ChartViewer);
}

The source code has been modified as above.

But the operation is the same as before.

Singularity is outputted by alternating chart 1 and chart 2 when ChartUpdateTimer is set to 250ms and same as DataRateTimer.

Is there an example source that implements this multitime chart in realtimetrack?

If it is, it will help me a lot.

Thank you.
multi-2_1.png

  Re: How do I create multiple timetrackers on one page?
Posted by Peter Kwan on Nov-14-2019 18:41
Attachments:
Hi Shin,

I have attached an example for your reference. To try the example, please unzip it and copy it to the "ChartDirectormfcdemo" subdirectory. This will replace the original "realtimetrack" sample code with the the one I modified to use MultiChart. Please open the ChartDirectormfcdemomfcdemo.sln Visual Studio solution, select "realtimetrack" as the start up project, and compile and run it.

The attached code produces 3 XYChart objects. Two of them have missing data to illustrate how it works.

For your case, I suspect it is related to the data you use. Is it possible to provide an example by modifying the attached realtimetrack sample code, using some simulated data, so I can try to reproduce the problem?

Regards
Peter Kwan
realtimetrack_multichart.zip
realtimetrack_multichart.zip

39.87 Kb

  Re: How do I create multiple timetrackers on one page?
Posted by Shin on Nov-14-2019 19:55
Oops.

You are right. I looked at the getData () part again because it was a data problem, and the m_currentIndex variable was in the for loop in the while loop, which was incorrectly incremented.

It's working fine now.

I bothered you a lot and thank you for your kindness.

The example code ran well. Test code dataB = Chart :: NoValue; The code insertion part was also checked well.

Thank you a lot.