Change Color of LineSeries

2 posts, 1 answers
  1. KA
    KA avatar
    7 posts
    Member since:
    Jan 2013

    Posted 21 Mar 2015 Link to this post


    in my project I have a ChartView with up to 5 different LineSeries (loaded dynamically). Now I would like to change the stroke of each LineSeries with the RadColorPicker. Also the LegendItemColor and the AxisColor should change accordingly. Is there a built-in solution for this?

    If not can you give me a little hint which would be the best way to implement this functionality.

    Thank you very much
  2. Answer
    Petar Marchev
    Petar Marchev avatar
    968 posts

    Posted 23 Mar 2015 Link to this post

    Hello KA,

    Essentially, the colors of the legend markers are obtained automatically. Whenever the stroke of the line (representing the line series) changes, the legend marker should automatically get updated. In order to change the stroke of the line, you can chose from 3 different approaches:
    1. Setting the Stroke property of the LineSeries directly.
    2. Using a chart palette.
    3. Using the StrokeShapeStyle property of the series to pass a style targetting a Path and using a Setter for the Stroke property.

    The second and third option may be a little inconvenient in your case so I think that using the Stroke property of the LineSeries is the easiest way to go.

    As for the axes - you can style the axes in more than one way. If you need the same color to be applied to the labels, ticks and axis line, you can use the ElementBrush property of the axis. If you need different colors for the different elements you can use the LabelStyle, MajorTickStyle and LineStroke properties of the axis.

    I hope this information helps. Let us know how it goes.

    Petar Marchev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft banner
Back to Top