Home Forums WinForms controls Xceed Chart for WinForms Contour chart with irregular surface data

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19108 |

    I am plotting a contour chart with FrameStyle set to MeshContour.
    Sometimes the data that needs to be plotted is not a proper surface, something like
    Example 1:

      X1 X2 X3
    Y1 -0.122 0.065 0.025
    Y2 0.561 0.022 DBNull

    The missing data points are set to DBNull..
    But in this case the chart is plotted only with X1Y1, X1Y2, X2Y1, X2Y2 (ie. cells colored in green above). X3Y1 is not plotted in the chart even though it has a valid value.

    In case there are atleast 2 Y values for a given X value, the chart seems to be ok
    Example 2:

      X1 X2 X3
    Y1 -0.144 0.023 0.019
    Y2 0.529 0.05 -0.029
    Y3 -0.05 0.035 DBNull

    In this case, all the values are plotted as expected. 

    What is the best way to deal with cases where there is only one Y value containing data for a particular X value (as in example 1). I first set the Grid size as (number of X * number of Y) and then set each of the XY values one by one.

    Imported from legacy forums. Posted by Karlav (had 4283 views)

    User (Old forums)
    Member
    Post count: 23064

    Can you paste a code snippet showing how you setup up the chart and feed the data to it?

    Imported from legacy forums. Posted by André (had 2293 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    Here is the code snippet to set up the chart. The input dataset has 3 columns named, “X”, “Y” and “Data”, having values as per my previous post.

    Thanks for your guidance on this.

    public

    void PlotChart(DataSet inputDataset, string dataTableName, string[] xList, string[] yList)

    {

    //private Xceed.Chart.ChartControl chartControl1; — Added to the Form in design view

    Xceed.Chart.Core.

    Chart _chart = this.chartControl1.Charts[0];

    Xceed.Chart.Core.

    GridSurfaceSeries _surfaceSeries = (Xceed.Chart.Core.GridSurfaceSeries)_chart.Series[0];

    _surfaceSeries.Data.Clear();

    _surfaceSeries.Data.SetGridSize(xList.Length, yList.Length);

    double max = double.MinValue;

    double min = double.MaxValue;

    // PLOT points

    for (int series = 0; series < yList.Length; series++)

    {

    string yLabel = yList[series];

    for (int point = 0; point < xList.Length; point++)

    {

    string xLabel = xList[point];

    DataRow[] rows = inputDataset.Tables[dataTableName].

    Select(

    “X = ‘” + xLabel + “‘ AND Y='” + yLabel + “‘”);

    if (rows.Length > 0)

    {

    double value = (double)rows[0][“Data”];

    if ((double)rows[0][“Data”] > max)

    max = (

    double)rows[0][“Data”];

    if ((double)rows[0][“Data”] < min)

    min = (

    double)rows[0][“Data”];

    _surfaceSeries.Data.SetValue(point, yList.Length – series – 1, value);

    }

    else

    _surfaceSeries.Data.SetValue(point, yList.Length – series – 1,

    DBNull.Value);

    }

    }

    // INIT legend

    _surfaceSeries.AutomaticPalette =

    false;

    _surfaceSeries.Palette.Clear();

    Color[] colors = new Color[]

    {

    Color.DarkBlue,

    Color.Blue,

    Color.DeepSkyBlue,

    Color.Cyan,

    Color.Green,

    Color.YellowGreen,

    Color.Yellow,

    Color.Gold,

    Color.Orange,

    Color.Red,

    Color.DarkRed

    };

    max =

    Math.Ceiling(max * 100d) / 100d; // Take ceiling to include MAX point

    min =

    Math.Floor(min * 100d) / 100d; // Take floor to include MIN point

    for (int i = colors.Length – 1; i >= 0; i–)

    {

    double increment = (max – min) / 10d;

    _surfaceSeries.Palette.Add(

    Math.Round(min + i * increment, 2), colors[ i ]);

    }

     

     

    // INIT Axis

    _surfaceSeries.PaletteFrame =

    false;

    _surfaceSeries.FrameLine.Color =

    Color.Black;

    _surfaceSeries.FrameLine.Pattern = Xceed.Chart.GraphicsCore.

    LinePattern.Solid;

    _surfaceSeries.FrameLine.Width = 1;

    _surfaceSeries.FrameStyle = Xceed.Chart.Core.

    SurfaceFrameStyle.MeshContour;

    _surfaceSeries.FillStyle = Xceed.Chart.Core.

    SurfaceFillStyle.Zone;

    _surfaceSeries.SmoothPalette =

    false;

    _surfaceSeries.Legend.Format =

    “<zone_begin> – <zone_end>”;

    _chart.Axis(Xceed.Chart.Core.

    StandardAxis.PrimaryX).Labels.Clear();

    for (int point = 0; point < xList.Length; point++)

    _chart.Axis(Xceed.Chart.Core.

    StandardAxis.PrimaryX).Labels.Add(xList[point]);

    _chart.Axis(Xceed.Chart.Core.

    StandardAxis.Depth).Labels.Clear();

    for (int series = 0; series < yList.Length; series++)

    _chart.Axis(Xceed.Chart.Core.

    StandardAxis.Depth).Labels.Add(yList[yList.Length – series – 1]);

    this.chartControl1.Refresh();

    }

    Imported from legacy forums. Posted by Karlav (had 2149 views)

    User (Old forums)
    Member
    Post count: 23064

    We don’t see anything special in your code that would explain this.

    Have you tried setting the null values to an actual value, like 0?  There is also the EmptyDataPointAppearance property on the GridSurfaceSeries that could help with this issue.

    Imported from legacy forums. Posted by André (had 2617 views)

    User (Old forums)
    Member
    Post count: 23064

    In my case, 0 could be a valid value, so it will be misleading to set it to 0. Ideally I want to set it to DBNull, and those points on the chart are just shown empty.

    EmptyDataPointAppearance property on GridSurfaceSeries seems to be read-only. Is there any other way to set it?

    Thanks for your help…

    Imported from legacy forums. Posted by Karlav (had 2075 views)

    User (Old forums)
    Member
    Post count: 23064

    FYI, the EmptyDataPointsAppearance ‘property ‘ has ‘subproperties’ FillEffect, LineProps and Markers that are all readable and writable.

    Out of curiosity, how can you end with a 3D point that only has 2 valid values?  (X, Y, no Z or something similar)  

    Imported from legacy forums. Posted by Ghislain (had 2819 views)

    User (Old forums)
    Member
    Post count: 23064

    Just for reference, this behaviour was also discussed here: http://xceed.com/CS/forums/post/4073.aspx

    Imported from legacy forums. Posted by Keith (had 2037 views)

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.