User (Legacy) Posted November 4, 2004 Report Share Posted November 4, 2004 I have a real-time graph in our windows app using Client/Server 5.1 activex control. It works fine in the case where the number of series doesn't change after initialization. However, there seems to be no way to add a new series after initialization has taken place. I tried to add code to the RealTime MFC example. The code doesn't crash, but it also doesn't add the series to the graph. What is the correct way to do this in a real-time graph? Thanks in advance, Diana //*************************************************** void CCfxRealTime::OnAddone() { // TODO: Add your control notification handler code here // Switch realtime styles when the end of the if (nOffset == 20) { m_pChartFX1->RealTimeStyle = CRT_NOWAITARROW; m_pChartFX1->Refresh(); m_pChartFX2->RealTimeStyle = CRT_NOWAITARROW; m_pChartFX2->Refresh(); nOffset++; } else { if (nOffset < 20) nOffset++; } //insert one point from the left in realtime for each series m_pChartFX1->OpenDataEx((CfxCod) (COD_VALUES | COD_INSERTPOINTS), 2, 1); m_pChartFX1->ValueEx[0][0] = -50 + rand() % 100; m_pChartFX1->ValueEx[1][0] = -50 + rand() % 100; m_pChartFX1->CloseData((CfxCod) (COD_VALUES | COD_REALTIME)); //add one point from the right in realtime for each series m_pChartFX2->OpenDataEx((CfxCod) (COD_VALUES | COD_ADDPOINTS), 2, 1); m_pChartFX2->ValueEx[0][0] = -50 + rand() % 100; m_pChartFX2->ValueEx[1][0] = -50 + rand() % 100; m_pChartFX2->CloseData((CfxCod) (COD_VALUES | COD_REALTIME)); // MY CODE START *************************************************** static int serCount = 2; serCount++; m_pChartFX2->OpenDataEx(COD_VALUES, serCount, 20); m_pChartFX2->CloseData(COD_VALUES); m_pChartFX2->OpenDataEx((CfxCod) (COD_VALUES | COD_ADDPOINTS), 2, 1); m_pChartFX2->ValueEx[serCount-1][0] = -50 + rand() % 100; m_pChartFX2->CloseData((CfxCod) (COD_VALUES | COD_REALTIME)); // MY CODE END *************************************************** } //*************************************************** Link to comment Share on other sites More sharing options...
Software FX Posted November 8, 2004 Report Share Posted November 8, 2004 The way Real-Time charts work is by creating a Circular Buffer that gets allocated only once. If you want to add a series, this buffer will need to be re-allocated and all data will be lost. To do this you need to do: chart1.RealTimeSettings.BufferSize = BufferSize; chart1.OpenData(COD.Values,<new number of series>,0); chart1.CloseData(COD.Values); -- FP Software FX Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.