GetPointerStyle Issue of multiple styles
Posted: Mon Jul 18, 2011 7:28 pm
Hello,
I was trying to display data in the form of point series with each point having its own color and pointer style. I created new class derived from CustomPoint. I used GetPointerStyle event of this class to set Color and Style of each point. However graph is not displaying all data points. some of the points are not visible.
Following is the code example which has same issue.
Also I tried using Points series as
With these examples, my second and third points appears to be invisible on graph.
Please help me with this problem.
Thanks,
Bhausaheb
I was trying to display data in the form of point series with each point having its own color and pointer style. I created new class derived from CustomPoint. I used GetPointerStyle event of this class to set Color and Style of each point. However graph is not displaying all data points. some of the points are not visible.
Following is the code example which has same issue.
Code: Select all
public partial class MainFrm : Form
{
TChart tchart = new TChart();
public MainFrm()
{
tchart.Dock = DockStyle.Fill;
tchart.Aspect.View3D = false;
this.Controls.Add(tchart);
}
protected override void OnLoad(EventArgs e)
{
ValuePoints point = new ValuePoints(tchart.Chart, "TestData");
point.GetPointerStyle += point_GetPointerStyle;
}
void point_GetPointerStyle(CustomPoint series, GetPointerStyleEventArgs e)
{
ValuePoints ser = series as ValuePoints;
if (ser != null && e.ValueIndex >= 0)
{
e.Color = ser.SeriesColors[e.ValueIndex];
e.Style = ser.Styles[e.ValueIndex];
}
}
}
public class ValuePoints : CustomPoint
{
public List<Color> SeriesColors;
public List<PointerStyles> Styles;
public ValuePoints(Chart c, string title)
: base(c)
{
this.Title = title;
this.FillSampleValues(6);
SeriesColors = new List<Color>(new[] { Color.Red, Color.Green, Color.Yellow, Color.Magenta, Color.Yellow, Color.Purple });
Styles = new List<PointerStyles>(new[] { PointerStyles.Sphere, PointerStyles.Cross, PointerStyles.Star, PointerStyles.Triangle, PointerStyles.Rectangle, PointerStyles.DownTriangle });
this.Pointer.HorizSize = this.Pointer.VertSize = 3;
}
public override void DrawValue(int valueIndex)
{
base.DrawValue(valueIndex);
}
}
Code: Select all
protected override void OnLoad(EventArgs e)
{
Points point = new Points(tchart.Chart);
point.FillSampleValues(6);
point.GetPointerStyle += point_GetPointerStyle;
}
void point_GetPointerStyle(CustomPoint series, GetPointerStyleEventArgs e)
{
if (e.ValueIndex >= 0)
{
var SeriesColors = new List<Color>(new[] { Color.Red, Color.Green, Color.Yellow, Color.Magenta, Color.Yellow, Color.Purple });
var Styles = new List<PointerStyles>(new[] { PointerStyles.Sphere, PointerStyles.Cross, PointerStyles.Star, PointerStyles.Triangle, PointerStyles.Rectangle, PointerStyles.DownTriangle });
e.Color = SeriesColors[e.ValueIndex];
e.Style = Styles[e.ValueIndex];
}
}
Please help me with this problem.
Thanks,
Bhausaheb