Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
399
XamChart can draw dashed line part of the data points?
posted

Hello,

only a portion of the red line, I want to draw the dashed line.(XAML or Code-Behind)

ColumnChart2D.Series[0].DataPoints[0].Stroke = Brushes.Transparent;
ColumnChart2D.Series[0].DataPoints[0].Fill = Brushes.Red;
ColumnChart2D.Series[0].DataPoints[0].StrokeThickness = 2;

Line color and thickness could be modified in code-behind.
But,I can not change line type of the red line.

Is good in any way.
please help,post your good idea.

regards.

yung

  • 9836
    Verified Answer
    posted

    Hi Yung,

    One option is to use style but it would be applied for all of the Lines in the grid.

    <Grid.Resources>

                <Style TargetType="Line">

                    <Setter Property="StrokeDashArray" Value="5"/>

                </Style>

    </Grid.Resources>

    If you need to set this only for the first Line then you can  try to get a reference for the Line that represents the first point in the visual tree and either set the style above or use the following code:

    private void button1_Click(object sender, RoutedEventArgs e)

    {

    Line firstLine =

    Utilities.GetDescendantFromType(xamChart1, typeof(Line), false) as Line;

      

    DoubleCollection dashes = new DoubleCollection();

    dashes.Add(5);

    dashes.Add(5);

    firstLine.StrokeDashArray = dashes;

    }

    Note that the lines are generated each time when the chart is refreshed so this might be not a good option.

     

    In order to possibly get this feature into a future release, please submit a feature request here