Welcome to the Xceed Community | Help
Community Search  
More Search Options

Contour chart with irregular surface data

Sort Posts: Previous Next
  •  04-28-2009, 2:58 AM Post no. 20587

    Contour chart with irregular surface data

    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.

  •  04-28-2009, 2:01 PM Post no. 20604 in reply to 20587

    Re: Contour chart with irregular surface data

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


    André
    Software Developer
    Xceed Software Inc.
  •  05-18-2009, 4:04 AM Post no. 21023 in reply to 20604

    Re: Contour chart with irregular surface data

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

    }

  •  05-21-2009, 1:35 PM Post no. 21103 in reply to 21023

    Re: Contour chart with irregular surface data

    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.


    André
    Software Developer
    Xceed Software Inc.
  •  05-28-2009, 10:47 PM Post no. 21258 in reply to 21103

    Re: Contour chart with irregular surface data

    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...

  •  06-02-2009, 4:43 PM Post no. 21345 in reply to 21258

    Re: Contour chart with irregular surface data

    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)  


    Ghislain
    Technical Support and software developer
    Xceed Software Inc.
    Knowledge Base : http://xceed.com/kb/
    Update Center : http://xceed.com/updates/
    Documentation Center : http://xceed.com/doc/
    For everything else, there is Google
  •  03-19-2011, 8:55 AM Post no. 30063 in reply to 21345

    Re: Contour chart with irregular surface data

    Just for reference, this behaviour was also discussed here: http://xceed.com/CS/forums/post/4073.aspx
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.