Cursor tool Query
Posted: Thu Dec 04, 2008 10:55 am
Hi,
I have a TChart plotting a Histogram for which i have written following code.
Now i want to add a Cursor tool to this TChart, i have written code for it but i am getting an exception on cursorTool.XValue = 9; line.
Please tell me what i am doing wrong.
private void PlotHistogram(IList dataForPlotting, Steema.TeeChart.TChart tChart)
{
//define a Histogram which will be the data for the Chart.
Steema.TeeChart.Styles.Histogram dataHistogram =
new Steema.TeeChart.Styles.Histogram();
//Populate this histogram with the required data.
dataHistogram.Add(dataForPlotting);
//Set its function value to Null.
dataHistogram.Function = null;
tChart.Series.Clear();
//define a histogram which will be the Style for the Chart.
Steema.TeeChart.Styles.Histogram histogramStyle =
new Steema.TeeChart.Styles.Histogram(tChart.Chart);
//Declare a histogram function
Steema.TeeChart.Functions.HistogramFunction histogramFunction =
new Steema.TeeChart.Functions.HistogramFunction();
//Set the Color of the histogram style
histogramStyle.Color = Color.Orange;
//Set the function of the Histogram style to histogram function.
histogramStyle.Function = histogramFunction;
//Set the datasource to the histogram having the data.
histogramStyle.DataSource = dataHistogram;
//Set the Number of bins of the histogram
histogramFunction.NumBins = numOfBins;
//Recalculate the histogram
histogramFunction.Recalculate();
//Make the histogram which is holding data as inactive.
dataHistogram.Active = false;
//Disable the Legend
tChart.Legend.Visible = false;
Steema.TeeChart.Tools.CursorTool cursorTool = new Steema.TeeChart.Tools.CursorTool();
cursorTool.Pen.Width = 2;
cursorTool.Pen.Color = Color.LightGreen;
cursorTool.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
cursorTool.Series = dataHistogram;
tChart.Tools.Add(cursorTool);
cursorTool.XValue = 9;
cursorTool.YValue = 0;
}
Thanks
Sanyog.
I have a TChart plotting a Histogram for which i have written following code.
Now i want to add a Cursor tool to this TChart, i have written code for it but i am getting an exception on cursorTool.XValue = 9; line.
Please tell me what i am doing wrong.
private void PlotHistogram(IList dataForPlotting, Steema.TeeChart.TChart tChart)
{
//define a Histogram which will be the data for the Chart.
Steema.TeeChart.Styles.Histogram dataHistogram =
new Steema.TeeChart.Styles.Histogram();
//Populate this histogram with the required data.
dataHistogram.Add(dataForPlotting);
//Set its function value to Null.
dataHistogram.Function = null;
tChart.Series.Clear();
//define a histogram which will be the Style for the Chart.
Steema.TeeChart.Styles.Histogram histogramStyle =
new Steema.TeeChart.Styles.Histogram(tChart.Chart);
//Declare a histogram function
Steema.TeeChart.Functions.HistogramFunction histogramFunction =
new Steema.TeeChart.Functions.HistogramFunction();
//Set the Color of the histogram style
histogramStyle.Color = Color.Orange;
//Set the function of the Histogram style to histogram function.
histogramStyle.Function = histogramFunction;
//Set the datasource to the histogram having the data.
histogramStyle.DataSource = dataHistogram;
//Set the Number of bins of the histogram
histogramFunction.NumBins = numOfBins;
//Recalculate the histogram
histogramFunction.Recalculate();
//Make the histogram which is holding data as inactive.
dataHistogram.Active = false;
//Disable the Legend
tChart.Legend.Visible = false;
Steema.TeeChart.Tools.CursorTool cursorTool = new Steema.TeeChart.Tools.CursorTool();
cursorTool.Pen.Width = 2;
cursorTool.Pen.Color = Color.LightGreen;
cursorTool.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
cursorTool.Series = dataHistogram;
tChart.Tools.Add(cursorTool);
cursorTool.XValue = 9;
cursorTool.YValue = 0;
}
Thanks
Sanyog.