Cursor tool Query

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
drillright40
Newbie
Newbie
Posts: 57
Joined: Mon Nov 19, 2007 12:00 am

Cursor tool Query

Post by drillright40 » 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.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Post by Sandra » Thu Dec 04, 2008 12:12 pm

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

drillright40
Newbie
Newbie
Posts: 57
Joined: Mon Nov 19, 2007 12:00 am

Cursor tool Query

Post by drillright40 » Mon Dec 08, 2008 5:37 am

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.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Post by Sandra » Tue Dec 09, 2008 9:20 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Dec 09, 2008 2:32 pm

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);
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply