2

I plot a graph like this

LineItem lineItem = new LineItem("label", pointList, Color.Black, SymbolType.Triangle);
lineItem.Line.IsVisible = _graphLineVisible;
zgc.GraphPane.CurveList.Add(lineItem);

I notice that SymbolType have an enum element called UserDefined, is there a way to use this and how?

Ideally I would want to be able to implement my own Symbol and use it to draw a LineItem, is this possible and how could I go on about doing this?

HischT
  • 933
  • 1
  • 9
  • 26

2 Answers2

4

Here is a detailed illustration of how to create custom arrow-down symbols, in line with the previously published answer:

var curve = zgc.GraphPane.AddCurve(null, new[] { 2.1, 2.6, 2.8 }, new[] { 1.8, 1.3, 1.1 }, Color.Blue);

curve.Symbol = new Symbol(SymbolType.UserDefined, Color.Red);
curve.Symbol.UserSymbol = new GraphicsPath(
    new[]
        {
            new PointF(-0.6f, -0.6f), new PointF(-0.6f, 0.6f), new PointF(-1.0f, 0.6f), new PointF(0f, 1.6f), 
            new PointF(1.0f, 0.6f), new PointF(0.6f, 0.6f), new PointF(0.6f, -0.6f),
            new PointF(-0.6f, -0.6f)
        },
    new[]
        {
            (byte)PathPointType.Start, (byte)PathPointType.Line, (byte)PathPointType.Line,
            (byte)PathPointType.Line, (byte)PathPointType.Line, (byte)PathPointType.Line,
            (byte)PathPointType.Line, (byte)PathPointType.Line
        });

Running this code would yield the following output:

Graph with user defined arrow-down symbols

Anders Gustafsson
  • 15,837
  • 8
  • 56
  • 114
1

I figured out how to use custom Symbols together with a LineItem, this is how:

Symbol symbol = new Symbol();
symbol.UserSymbol = GetGraphicsPath();
symbol.Size = 5f;

LineItem lineItem = new LineItem("label", pointList, Color.Black, SymbolType.None);     
lineItem.Line.IsVisible = _graphLineVisible; 
lineItem.Symbol = symbol;
zgc.GraphPane.CurveList.Add(lineItem); 

where GetGraphicsPath() returns a custom GraphicsPath object that you essentially create using for example GraphicsPath.AddLine method or any other method depending on what kind of symbol you want.

HischT
  • 933
  • 1
  • 9
  • 26