Page 1 of 1

Cursor tool Query

Posted: Thu Dec 04, 2008 10:55 am
by 14047415
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.

Posted: Thu Dec 04, 2008 12:12 pm
by 10050769
Hello drillright40!

We find a bug, when you assigned cursorTool.Series=dataHistogram I recomended that coments this line of code:

Code: Select all

               cursorTool.Pen.Color = Color.LightGreen;
               cursorTool.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
               //cursorTool.Series = dataHistogram;
Can you please check if this solves the problem for you?

About cursorTool.XValue, Narcís explained on this link how you should set its values.

Best Regards
Sandra


Steema Support Central
http://support.steema.com

Cursor tool Query

Posted: Mon Dec 08, 2008 5:37 am
by 14047415
Hi,

1.I checked commenting the line that you suggested, but the problem now is after execution of the following line cursorTool.XValue = 9; also the XValue remains unchanged when seen in the debugger.Because of which the Cursor tool is shown at some undesired location(i.e center) in the Histogram.

Please help.

Thanks
Sanyog.

Posted: Tue Dec 09, 2008 9:20 am
by 10050769
Hi drillright40!

About cursorTool.XValue, Narcís explained on this link how you should set its values, the part of link appear same under code, because you need repeated XValue for chenge the position.

Code: Select all

                cursorTool.XValue = 9;
                cursorTool.YValue = 0;
                cursorTool.XValue = 9;

Best Regards
Sandra



Steema Support Central
http://support.steema.com

Posted: Tue Dec 09, 2008 2:32 pm
by narcis
Hi drillright40,

As an update to CursorTool's issue (TF02013633), we found that it is not a bug. The problem with the code is that the dataHistogram series is not assigned a 'Chart'. This can be done either by adding the instance to the Series collection or passing a Chart in the constructor, e.g.

Code: Select all

      Steema.TeeChart.Styles.Histogram dataHistogram = new
Steema.TeeChart.Styles.Histogram();
      //either
      tChart1.Series.Add(dataHistogram);
      //or
      //Steema.TeeChart.Styles.Histogram dataHistogram = new
Steema.TeeChart.Styles.Histogram(tChart1.Chart);