Profile Picture

Need a better way to scroll a bar chart

Posted By Steve Clevenger 12 Years Ago
Author
Message
Steve Clevenger
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 7, Visits: 1
The following solution works for me if it helps anyone.

For your reference, my class has defined the following data:
NBarSeries barSeries;
NDataPoint datapoint;

// Scroll implementation contained within the managed code.

bool AddBarDataInternal(double[] safearray, int idx)
{
if (safearray[idx] > 10.0) // setup to scroll
{
// preserve the data point at index zero
NDataPoint zeropoint = barSeries.ComposeDataPoint(0);
int count = barSeries.GetDataPointCount() - 1;
int indx;

for (indx = 0; indx < count; indx++)
{
datapoint = barSeries.ComposeDataPoint(indx + 1);
datapoint[DataPointValue.X] = (double)(indx + 1);
barSeries.StoreDataPoint(indx, datapoint);
} // end for
// Store the index zero data point here
zeropoint[DataPointValue.X] = (double) count + 1;
zeropoint[DataPointValue.Y] = safearray[idx + 1];
barSeries.StoreDataPoint(count, zeropoint);
}
else
barSeries.AddDataPoint(new NDataPoint(safearray[idx], safearray[idx + 1])); // 1..10
nChartControl1.Refresh();

return (true);
}

Steve Clevenger
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 7, Visits: 1

Hello,

I have a relatively simple 3D bar chart which can display 10 bars along the X-axis (i.e. position 1 - 10). If I need to add more than 10 bars, I'd like to shift the existing bars (e.g. bars 2 - 10) one position to the left along the X-axis (dropping out the bar data at position 1) and add the latest bar to the 10th position. My current C# implementation calls ClearDataPoints(), and redraws each bar at its' new X-axis location. This method of scrolling makes for a jerky (and slow) way to update the chart given that I'm doing this from unmanaged code. I don't want (and don't need) to add a horizontal scroll bar. Is there a better way to get the result I seek, or is it as simple as keeping the data history in the managed code?

Thanks,

Steve Clevenger



Similar Topics


Reading This Topic