Home Forums WinForms controls Xceed Chart for WinForms SurfaceSeries AutomaticPalette Bug/Flaw

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

    Hello,
    Just like to report a bug (or more likely, a design flaw) in the SurfaceSeries AutomaticPalette feature. This (usually very useful) option usually works well, however the bug occurs when a sufficiently large max/min data range causes the AutomaticPalette to “wrap around” so that the same color appears twice on the grid surface – at different extremes of the axis range. This bug becomes particularly critical when drawing the gridsurface as a flat contour map – You usually end up with Red for both the maximum AND the minimum of the axis range with no way to distinguish them – clearly not a desired result. (would have expected a more sensible solution would use the spectrum of colors and never wrap around and re-use colors).

    The work around hack of a solution is to use custom pallets, but unfortunately the Automatic Max/Min range is not available (see post: http://forums.xceed.com/Forums/ShowPost.aspx?PostID=4469)

    Two questions: Can we specify the min/max color range that AutomaticPalette should use (I could find nothing about this in the documentation)?

    Can this be fixed for the next release? Thanks!

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

    Xceed Support
    Member
    Post count: 5658

    Usually having access to the data, you can find the max/min values. From there, you can use this information to create your own Palette. You cannot change the min/max color range of the AutomaticPalette.

    The <a href=”http://forums.xceed.com/Forums/ShowPost.aspx?PostID=4469″>Automatic Max/Min</a> range feature has already been added to our feature request list.

    Here is a snippet that own you can create your own random color palette and a custom number of steps.

    <code>
    private GridSurfaceSeries m_Surface;
    private Random random;

    public Form1()
    {
    InitializeComponent();
    random = new Random();
    }

    private void Form1_Load( object sender, EventArgs e )
    {
    chartControl1.Settings.RenderDevice = RenderDevice.OpenGL;
    chartControl1.InteractivityOperations.Add( new TrackballDragOperation() );
    chartControl1.Settings.EnableAntialiasing = false;
    chartControl1.Background.FillEffect.SetGradient( GradientStyle.Horizontal, GradientVariant.Variant1, Color.Lavender, Color.LightSteelBlue );

    Chart m_Chart = chartControl1.Charts[ 0 ];
    m_Chart.Width = 60.0f;
    m_Chart.Depth = 60.0f;
    m_Chart.Height = 25.0f;
    m_Chart.View.SetPredefinedProjection( PredefinedProjection.PerspectiveTilted );
    m_Chart.LightModel.SetPredefinedScheme( LightScheme.ShinyTopLeft );

    m_Surface = ( GridSurfaceSeries )m_Chart.Series.Add( SeriesType.GridSurface );
    m_Surface.FrameStyle = SurfaceFrameStyle.Contour;
    m_Surface.FillStyle = SurfaceFillStyle.Zone;
    m_Surface.PositionValue = 10.0;
    m_Surface.Data.SetGridSize( 32, 32 );
    m_Surface.Name = “Surface”;
    m_Surface.Legend.Mode = SeriesLegendMode.SeriesLogic;

    double[] optimum = FillData();

    m_Surface.AutomaticPalette = false;

    m_Surface.Palette = getPalette( optimum[ 0 ], optimum[ 1 ], 10 );

    m_Chart.Axis( StandardAxis.PrimaryY ).Text.Font = new Font( “Arial”, 8 );
    m_Chart.Axis( StandardAxis.PrimaryX ).DimensionScale.NumberOfDataPointsBetweenLabels = 10;
    m_Chart.Axis( StandardAxis.PrimaryX ).DimensionScale.NumberOfDataPointsBetweenTicks = 10;
    m_Chart.Axis( StandardAxis.PrimaryX ).SetMajorShowAtWall( ChartWallType.Floor, false );
    m_Chart.Axis( StandardAxis.Depth ).DimensionScale.NumberOfDataPointsBetweenLabels = 10;
    m_Chart.Axis( StandardAxis.Depth ).DimensionScale.NumberOfDataPointsBetweenTicks = 10;
    }

    private double[] FillData()
    {
    double max = -1000000, min = 1000000;
    double y, x, z;
    int nCountX = m_Surface.Data.GridSizeX;
    int nCountZ = m_Surface.Data.GridSizeZ;

    const double dIntervalX = 30.0;
    const double dIntervalZ = 30.0;
    double dIncrementX = ( dIntervalX / nCountX );
    double dIncrementZ = ( dIntervalZ / nCountZ );

    z = -( dIntervalZ / 2 );

    for( int j = 0; j < nCountZ; j++, z += dIncrementZ )
    {
    x = -( dIntervalX / 2 );

    for( int i = 0; i < nCountX; i++, x += dIncrementX )
    {
    y = ( x * z / 64.0 ) – Math.Sin( z / 2.4 ) * Math.Cos( x / 2.4 );
    y = 10 * Math.Sqrt( Math.Abs( y ) );

    if( y <= 0 )
    {
    y = 1 + Math.Cos( x / 2.4 );
    }

    if( y < min )
    min = y;
    if( y > max )
    max = y;

    m_Surface.Data.SetValue( i, j, y );
    }
    }

    return new double[] { max, min };
    }

    private Palette getPalette( double max, double min, int steps )
    {
    Palette myPalette = new Palette();

    double interval = max – min;
    interval = interval / steps;

    for( int i = 0; i <= steps; i++ )
    {
    double value = Math.Round( min + i * interval, 0 );
    myPalette.Add( value, Color.FromArgb( random.Next( 255 ), random.Next( 255 ), random.Next( 255 ) ) );
    }

    return myPalette;
    }
    </code>

    Imported from legacy forums. Posted by CharlesB (had 3507 views)

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