This is a migrated thread and some comments may be shown as answers.
LineSeries Dashed / Dotted Line Style
2 Answers 97 Views
This is a migrated thread and some comments may be shown as answers.
pratik mehta
Top achievements
Rank 1
pratik mehta asked on 29 Jul 2010, 01:29 PM
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.

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

 

 

2 Answers, 1 is accepted

Sort by
0
pratik mehta
Top achievements
Rank 1
answered on 02 Aug 2010, 09:47 AM
can anyone help me on this?

Thanks

Pratik Mehta

0
Vladimir Milev
Telerik team
answered on 02 Aug 2010, 04:34 PM
Hi pratik mehta,

The recommended approach to styling all elements consistently, including legend items would be the CreateItemStyle delegate. Also, check this blog post for details.

Regards,
Vladimir Milev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
pratik mehta
Top achievements
Rank 1
Answers by
pratik mehta
Top achievements
Rank 1
Vladimir Milev
Telerik team
Share this question
or