This question is locked. New answers and comments are not allowed.
Hi,
I want to display some lines in chart as dotted or dashed. I am using below code to display line as dotted as dashed.
In my code i am not generating Legend items manually.
I want to display some lines in chart as dotted or dashed. I am using below code to display line as dotted as dashed.
In my code i am not generating Legend items manually.
private Style GetLineSeriesStyle(int lineType) { Style lineStyle; Style pathStyle; switch (lineType) { case 1: pathStyle = new Style(typeof(System.Windows.Shapes.Path)); pathStyle.Setters.Add(new Setter(Shape.StrokeDashArrayProperty, "2")); pathStyle.Setters.Add(new Setter(Shape.StrokeThicknessProperty, 2)); pathStyle.Setters.Add(new Setter(Shape.StrokeProperty, new SolidColorBrush(Colors.Yellow))); lineStyle = new Style(typeof(Telerik.Windows.Controls.Charting.SelfDrawingSeries)); lineStyle.Setters.Add(new Setter(SelfDrawingSeries.BorderLineStyleProperty, pathStyle)); break; case 2: pathStyle = new Style(typeof(System.Windows.Shapes.Path)); pathStyle.Setters.Add(new Setter(Shape.StrokeDashArrayProperty, "2")); pathStyle.Setters.Add(new Setter(Shape.StrokeThicknessProperty, 2)); pathStyle.Setters.Add(new Setter(Shape.StrokeProperty, new SolidColorBrush(Colors.Red))); lineStyle = new Style(typeof(Telerik.Windows.Controls.Charting.SelfDrawingSeries)); lineStyle.Setters.Add(new Setter(SelfDrawingSeries.BorderLineStyleProperty, pathStyle)); break; default: Random oRandom = new Random(); Color oColor = Color.FromArgb(Convert.ToByte(oRandom.Next(100, 255)), Convert.ToByte(oRandom.Next(100, 255)), Convert.ToByte(oRandom.Next(100, 255)), Convert.ToByte(oRandom.Next(100, 255))); pathStyle = new Style(typeof(System.Windows.Shapes.Path)); pathStyle.Setters.Add(new Setter(Shape.StrokeProperty, new SolidColorBrush(oColor))); pathStyle.Setters.Add(new Setter(Shape.StrokeLineJoinProperty, "2")); pathStyle.Setters.Add(new Setter(Shape.StrokeThicknessProperty, 2)); lineStyle = new Style(typeof(Telerik.Windows.Controls.Charting.SelfDrawingSeries)); lineStyle.Setters.Add(new Setter(SelfDrawingSeries.BorderLineStyleProperty, pathStyle)); break; } return lineStyle; }
Now in follwing example My series color and legend color are mismatching.
i tried by commenting below code
pathStyle.Setters.Add(new Setter(Shape.StrokeProperty, new SolidColorBrush(Colors.Red)));
in above code base. but in that case i am not able to see any line in my chart area.
Can you please let me know hot display dashed ot dotted line without touching Color property.
And i do not want to add Legend manually.
Thanks
Pratik Mehta