ChartMarker

ChartMarker class

Represents a chart data marker.

To learn more, visit the Working with Charts documentation article.

public class ChartMarker

Properties

NameDescription
Format { get; }Provides access to fill and line formatting of this marker.
Size { get; set; }Gets or sets chart marker size. Default value is 7.
Symbol { get; set; }Gets or sets chart marker symbol.

Examples

Shows how to work with data points on a line chart.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.InsertChart(ChartType.Line, 500, 350);
Chart chart = shape.Chart;

Assert.That(chart.Series.Count, Is.EqualTo(3));
Assert.That(chart.Series[0].Name, Is.EqualTo("Series 1"));
Assert.That(chart.Series[1].Name, Is.EqualTo("Series 2"));
Assert.That(chart.Series[2].Name, Is.EqualTo("Series 3"));

// Emphasize the chart's data points by making them appear as diamond shapes.
foreach (ChartSeries series in chart.Series)
    ApplyDataPoints(series, 4, MarkerSymbol.Diamond, 15);

// Smooth out the line that represents the first data series.
chart.Series[0].Smooth = true;

// Verify that data points for the first series will not invert their colors if the value is negative.
using (IEnumerator<ChartDataPoint> enumerator = chart.Series[0].DataPoints.GetEnumerator())
{
    while (enumerator.MoveNext())
    {
        Assert.That(enumerator.Current.InvertIfNegative, Is.False);
    }
}

ChartDataPoint dataPoint = chart.Series[1].DataPoints[2];
dataPoint.Format.Fill.Color = Color.Red;

// For a cleaner looking graph, we can clear format individually.
dataPoint.ClearFormat();

// We can also strip an entire series of data points at once.
chart.Series[2].DataPoints.ClearFormat();

doc.Save(ArtifactsDir + "Charts.ChartDataPoint.docx");

Shows how to work with data points on a line chart (ApplyDataPoints).

/// <summary>
/// Applies a number of data points to a series.
/// </summary>
private static void ApplyDataPoints(ChartSeries series, int dataPointsCount, MarkerSymbol markerSymbol, int dataPointSize)
{
    for (int i = 0; i < dataPointsCount; i++)
    {
        ChartDataPoint point = series.DataPoints[i];
        point.Marker.Symbol = markerSymbol;
        point.Marker.Size = dataPointSize;

        Assert.That(point.Index, Is.EqualTo(i));
    }
}

See Also