Issue with GetPointerStyle and setting pointer colors in Mon
Posted: Fri Jul 06, 2012 8:03 pm
Below is an example that calls the GetPointerStyle method to set different colors for the pointer based on the pointer index. Even though the pointer indices start with 0, the color for the first pointer is never set because it seems to set the colors for the pointer after the index in question.
However, the pointer pen color seems to work as expected. Could you please let me know on what I am doing wrong. Thanks.
public void InitChart()
{
newChart = new TChart();
newChart.Frame = new RectangleF(0,10,320,300);
newChart.Header.Visible = false;
newChart.Legend.Visible = false;
newChart.Axes.Visible = false;
this.View.AddSubview(newChart);
Steema.TeeChart.Themes.CustomTheme backgroundTheme = new Steema.TeeChart.Themes.ClassicTheme(newChart.Chart);
backgroundTheme.Apply();
newChart.Walls.Back.Gradient.Visible = false;
newChart.Walls.Back.Color = UIColor.Black.CGColor;
newChart.Panel.Color = UIColor.Black.CGColor;
newChart.Aspect.View3D = false;
newChart.Chart.Aspect.ZoomScrollStyle = Steema.TeeChart.Drawing.Aspect.ZoomScrollStyles.Manual;
newChart.Panning.Allow = ScrollModes.Horizontal;
newSeries = new Steema.TeeChart.Styles.Line();
newSeries.LinePen.Width = 2;
newSeries.Pointer.Visible = true;
newSeries.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
newSeries.Pointer.HorizSize = 10;
newSeries.Pointer.VertSize = 10;
newSeries.Pointer.Pen.Color = UIColor.White.CGColor;
newSeries.Color = UIColor.White.CGColor;
newSeries.Add (2);
newSeries.Add (1);
newSeries.Add(4);
newSeries.GetPointerStyle += HandleGetPointerStyle;
newChart.Series.Add (newSeries);
}
void HandleGetPointerStyle (Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
{
newSeries.Pointer.Color = GetColorForIndex(e.ValueIndex);
newSeries.Pointer.Pen.Color = GetColorForIndex(e.ValueIndex);
}
private MonoTouch.CoreGraphics.CGColor GetColorForIndex(int index)
{
MonoTouch.CoreGraphics.CGColor color = UIColor.White.CGColor;
if( index <= 1)
color = UIColor.Red.CGColor;
else if( index <= 2)
color = UIColor.Orange.CGColor;
else if( index <= 3)
color = UIColor.Yellow.CGColor;
else if( index <= 4)
color = UIColor.Green.CGColor;
return color;
}
However, the pointer pen color seems to work as expected. Could you please let me know on what I am doing wrong. Thanks.
public void InitChart()
{
newChart = new TChart();
newChart.Frame = new RectangleF(0,10,320,300);
newChart.Header.Visible = false;
newChart.Legend.Visible = false;
newChart.Axes.Visible = false;
this.View.AddSubview(newChart);
Steema.TeeChart.Themes.CustomTheme backgroundTheme = new Steema.TeeChart.Themes.ClassicTheme(newChart.Chart);
backgroundTheme.Apply();
newChart.Walls.Back.Gradient.Visible = false;
newChart.Walls.Back.Color = UIColor.Black.CGColor;
newChart.Panel.Color = UIColor.Black.CGColor;
newChart.Aspect.View3D = false;
newChart.Chart.Aspect.ZoomScrollStyle = Steema.TeeChart.Drawing.Aspect.ZoomScrollStyles.Manual;
newChart.Panning.Allow = ScrollModes.Horizontal;
newSeries = new Steema.TeeChart.Styles.Line();
newSeries.LinePen.Width = 2;
newSeries.Pointer.Visible = true;
newSeries.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
newSeries.Pointer.HorizSize = 10;
newSeries.Pointer.VertSize = 10;
newSeries.Pointer.Pen.Color = UIColor.White.CGColor;
newSeries.Color = UIColor.White.CGColor;
newSeries.Add (2);
newSeries.Add (1);
newSeries.Add(4);
newSeries.GetPointerStyle += HandleGetPointerStyle;
newChart.Series.Add (newSeries);
}
void HandleGetPointerStyle (Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
{
newSeries.Pointer.Color = GetColorForIndex(e.ValueIndex);
newSeries.Pointer.Pen.Color = GetColorForIndex(e.ValueIndex);
}
private MonoTouch.CoreGraphics.CGColor GetColorForIndex(int index)
{
MonoTouch.CoreGraphics.CGColor color = UIColor.White.CGColor;
if( index <= 1)
color = UIColor.Red.CGColor;
else if( index <= 2)
color = UIColor.Orange.CGColor;
else if( index <= 3)
color = UIColor.Yellow.CGColor;
else if( index <= 4)
color = UIColor.Green.CGColor;
return color;
}