Jump to content
Software FX Community

Mouse events


User (Legacy)

Recommended Posts

I implement a real-time step chart in which Axis X is numerical with only

one series. After appending new values I increase Max property of Axis X

manually and set scroll view to observe the last 100 measurements.

It looks like that from time to time (in about 10% of cases) on left (right)

mouse button down event ChartFX object sets scroll view with minimal and

maximal values of my X values. I set Scrollable property be TRUE and FALSE

however it does not make any difference.

How can I avoid this behaviour?

Thanks,

Mikhail

Link to comment
Share on other sites

I.e. I output a chart with five-minute time window, see graph1.gif.

Eventually (on some mouse event?) it is being output as shown on graph2.gif,

however on the next data update the time interval returns back to five

minutes.

The data update function is as follows:

void CFXGraph::AppendValuesTimeBased(double** pData, unsigned long nSize,

int nSeries) // nSeries = 1, so I have a single series

{

double rMin, rMax, rTime;

int nAppended = m_pChart->NValues;

int count;

double rStartTime = m_pChart->Axis->Item[AXIS_X]->Min;

m_pChart->Axis->Item[AXIS_X]->GetScrollView(&rMin, &rMax);

// obtain current observation window and sometimes rMin == rStartTime

// which means that on the previous data update we had this nasty bag

m_pChart->OpenDataEx(CfxCod(COD_VALUES | COD_REALTIME), nSeries,

nAppended + nSize);

m_pChart->OpenDataEx(CfxCod(COD_XVALUES | COD_REALTIME), nSeries,

nAppended + nSize);

for (int i=0; i<nSeries; i++)

// insert new data

{

ICfxSeriesPtr iSeries = m_pChart->Series->Item[i];

for (unsigned long j=0; j<nSize; j++)

{

iSeries->Yvalue[nAppended + j] = pData[i][j];

rTime = rStartTime + m_crSec * 0.6 * (j + nAppended);

// next observation entry every 0.6 second

iSeries->Xvalue[nAppended + j] = rTime;

}

}

m_pChart->CloseData(static_cast<CfxCod>(COD_XVALUES | COD_REALTIME));

m_pChart->CloseData(static_cast<CfxCod>(COD_VALUES | COD_REALTIME));

nAppended += nSize;

// new size of data array

rTime = rStartTime + m_crSec * 0.6 * (nAppended);

// new right side

m_pChart->Axis->Item[AXIS_X]->Max = rTime;

if (0 < float(nAppended) - m_nScrollableWindow)

// m_nScrollableWindow=500 (5 minutes) defines the size of observation time

window

{

if (rMax + m_crSec*(10 + nSize) > rTime)

// if the user looked at the last entries of the graph, then move

observation window

{

m_pChart->Axis->Item[AXIS_X]->SetScrollView(rTime - m_crSec *

m_nScrollableWindow * 0.6, rTime);

}

else

// otherwise do not change it

{

// in fact in my test this does not happen

m_pChart->Axis->Item[AXIS_X]->SetScrollView(rMin, rMin + m_crSec

* m_nScrollableWindow * 0.6);

}

}

}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...