Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WPF GRAPH DATASOUCE CUSTOM POINT STRUCT

Solved!
Go to solution

graph.DataSource= ChartCollection<PointI>

 

graph.plot=PointPlotRenderer

 

run error:

Could not find conversion from type PointI to type Double.

 

 

public struct PointI : IFormattable
{

public PointI(double x, double y)
{
X = x;
Y = y;
}


public double X { get; set; }

public double Y { get; set; }

public string ToString(string format, IFormatProvider formatProvider)
{
//throw new NotImplementedException();
return string.Format("{0},{1}", X, Y);
}
}

0 Kudos
Message 1 of 2
(3,263 Views)
Solution
Accepted by topic author jiewei_li

To use a custom data type with the graph, you need to also implement a descriptor so the graph knows how to access your data. I have attached a descriptor from another question, translated to C# for your data type.

 

To use the descriptor, add a DataTypeDescriptor attribute to your custom type:


    [DataTypeDescriptor( typeof( PointIDescriptor ) )]
    public struct PointI : IFormattable {
        // ...
    }

~ Paul H
0 Kudos
Message 2 of 2
(3,232 Views)