Jump to content
Software FX Community

Need to dynamically add series to a real-time graph

User (Legacy)

Recommended Posts

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,



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_pChartFX2->RealTimeStyle = CRT_NOWAITARROW;



} else {

if (nOffset < 20)



//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;


m_pChartFX2->OpenDataEx(COD_VALUES, serCount, 20);


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

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);




Software FX

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...