2

このようなグラフをプロットします

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

SymbolTypeにと呼ばれる列挙型要素があることに気付きましたUserDefined。これを使用する方法と方法はありますか?

理想的には、独自のSymbolを実装し、それを使用してLineItemを描画できるようにしたいと思います。これは可能であり、どうすればこれを実行できますか?

4

2 に答える 2

4

これは、以前に公開された回答に沿って、カスタムの矢印記号を作成する方法の詳細な図です。

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
        });

このコードを実行すると、次の出力が得られます。

ユーザー定義の下向き矢印記号を使用したグラフ

于 2012-08-09T11:41:33.090 に答える
1

LineItemと一緒にカスタムシンボルを使用する方法を理解しました。これは次の方法です。

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); 

ここで、GetGraphicsPath()は、必要なシンボルの種類に応じて、たとえばGraphicsPath.AddLineメソッドまたはその他のメソッドを使用して基本的に作成するカスタムGraphicsPathオブジェクトを返します。

于 2012-08-09T10:45:27.720 に答える