ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Negative number label in Contour Chart
Posted by Jose on Feb-27-2014 18:49
Attachments:
Hello,

I am using a contour chart to display some parameter values at different depth.
My problem is that in the colour legend, labels with negative values is appearing, see attached image.

Is there a way to display 0 as the minimun value in the legend but not making fixed axis limits?

All Z values I use to generate the chart are positive:

// The x and y coordinates of the grid
    double[] dataX = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    double[] dataY = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

    // The values at the grid points. In this example, we will compute the values
    // using the formula z = Math.Abs(x * sin(y) + y * sin(x)).
    double[] dataZ = new double[(dataX.Length) * (dataY.Length)];
    for(int yIndex = 0; yIndex < dataY.Length; ++yIndex)
    {
        double y = dataY[yIndex];
        for(int xIndex = 0; xIndex < dataX.Length; ++xIndex)
        {
            double x = dataX[xIndex];
            dataZ[yIndex * (dataX.Length) + xIndex] = Math.Abs(x * Math.Sin(y) + y * Math.Sin(x));
        }
    }


Best Regards
Contour chart.png

  Re: Negative number label in Contour Chart
Posted by Peter Kwan on Feb-27-2014 23:32
Hi Jose,

Your data only contains 11 x 11 points. To plot a contour chart, ChartDirector needs to
know the value of every point in the surface. So ChartDirector must compute the other
points from the 11 x 11 points. Even if the 11 x 11 points are positive, it does not mean
that the other points must be positive. It depends on the interpolation method. See the
thread below for an explanation and one possible solution:

http://www.chartdir.com/forum/download_thread.php?
bn=chartdir_support&thread=1279221290#N1279288428

In ChartDirector 5.1, a new method is introduced that can force the axis to stay within the
range of the 11 x 11 points (the raw data points), even if the interpolated points can be
outside the range. The method is:

myContourLayer.setZBounds(Chart.DataBound, Chart.DataBound);

Hope this can help.

Regards
Peter Kwan

  Re: Negative number label in Contour Chart
Posted by Jose on Mar-03-2014 17:57
Thank you Peter for your prompt reply.

'setZBounds' is the function i needed.