buy now
log in
MindFusion

Q: I want to color the background of my chart in three stripes, each one in different color. Any hints how to do it?

A: You can do this by using GridType and GridFills property. Let's say you want to color the background of a vertical bar chart. First, you have to fix the axis scale so that is has 3 intervals, which will result in three grid stripes. Next, add the desired brushes to the GridFills collection to color the stripes:

 barChart1.YAxisSettings.MinValue = 0;
 barChart1.YAxisSettings.MaxValue = 300;
 barChart1.YAxisSettings.Interval = 100;

 //set the type and colors for the grid
 barChart1.GridType = GridType.Horizontal;
 barChart1.GridFills.Add(new SolidColorBrush(Colors.Yellow));
 barChart1.GridFills.Add(new SolidColorBrush(Colors.Orange));
 barChart1.GridFills.Add(new SolidColorBrush(Colors.Red));

Q: I want to create a line chart with several series, one of them must be dashed. What is the best way to do this?

A: Create a new LineSeries for each of the series you want to have. Use the StrokeDashArray, StrokeDashCap etc. properties to customize your dashed series. Add the appropriate stroke for each LineSeries to the LineSeries.Stroke collection. Here is sample code:

 LineSeries series = new LineSeries();
 series.StrokeDashArray = new DoubleCollection() { 1, 2, 0.5, 1 };
 series.StrokeDashCap = PenLineCap.Round;
 series.StrokeDashOffset = 5.0;
 series.Strokes.Add(new SolidColorBrush(Colors.Red));

 

Q: Can I dynamically remove or add series from a radar chart?

A: Of course you can - just remove the desired ChartSeries from the chart.Series collection or add a new one.

 chart.Series.RemoveAt(0);
 chart.Series.Add(...);
 

Copyright © 2001-2024 MindFusion LLC. All rights reserved.
Terms of Use - Contact Us