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

Message ListMessage List     Post MessagePost Message

  Setting Scale for contour plot
Posted by KeithB on May-02-2024 22:33
Everything works fine for the contour plot with a custom gradient, but I can't seem to set the temperature scale.

I have tried axis.setLinearScale(min, max) on the color axis, but that did not seem to do anything.

  Re: Setting Scale for contour plot
Posted by Peter Kwan on May-03-2024 00:31
Hi KeithB,

By "set the temperature scale", do you mean to specify the scale and color of the color axis? There are a few examples at:

https://www.advsofteng.com/doc/cdnet.htm#contourcolor.htm

If you use axis.setLinearScale(min, max) and do not provide the tick increment, ChartDirector will need to automatically determine the tick increment. It may adjust the min and max to make sure they are at a tick position. For example, if you use setLinearScale(20, -19.81247012082), and ChartDirector decides to use 5 as the tick increment, the ticks will be (20, 15, 10, 5, 0, -5, -10, -15, -20). Note that the minimum value will be adjusted to -20 and not -19.81247012082. If you do not want ChartDirector to adjust the scale, you can use axis.setRoundng(false, false).

Best Regards
Peter Kwan

  Re: Setting Scale for contour plot
Posted by KeithB on May-03-2024 01:43
Thanks. The key was setting the Tick Value.
I am trying to copy another temp scale that goes from white to blue, with the white set to the max temp.

My temperatures range from 120.3 to 195.4, and CD kept setting the Max to 200, so my max temp was never pure white as in the other heatmap.

I just had to set the Min, Max, Tick to 120, 196,  (196 to 120)/10 and it came out fine.
Unlike this other image, I am not so graceless as to set the max to 195.4!

Now to set the background to light grey so that I can see where the max temps are!

  Re: Setting Scale for contour plot
Posted by KeithB on May-03-2024 02:56
Attachments:
One more thing:
I am using code based on the contourcrosssection example.
I would like to "zoom in" to the cross section and rather than showing the original full temperature range, show from 160 - 200 to get better detail of the high temperature.

Here is the original and what happens if I setLinearscale() after syncScale()
scaleorig.jpg
setlinearscale.jpg

  Re: Setting Scale for contour plot
Posted by KeithB on Jun-18-2024 22:13
Just bringing this to the top.
Is there anyway to "zoom in" the scale on the cross section views so I get only the temperatures between 170 - 190 degrees and not just the extra scale lines?

  Re: Setting Scale for contour plot
Posted by Peter Kwan on Jun-19-2024 00:19
Attachments:
Hi KeithB,

Starting from the original Contour Chart Cross Section sample code, I modified the syncScale line to directly set the axis scale, and I got the attached image. Does it meet your requirement?

//c.yAxis().syncScale(contourLayer.colorAxis());
c.yAxis().setLinearScale(10, 35, 5);

If you want to have 170 to 190, then you can simply use:

c.yAxis().setLinearScale(170, 190, 5);

Regards
Peter Kwan
CSharpWinCharts_20240619001337.png

  Re: Setting Scale for contour plot
Posted by KeithB on Jun-19-2024 22:21
Attachments:
That did not work for me. With this code - from the Cross Section example - :
private void drawCrossSectionX(WinChartViewer viewer)
{
    // Get data of the vertical cross section data at the given x coordinate
    XYChart mainChart = (XYChart)winChartViewer1.Chart;
    PlotArea p = mainChart.getPlotArea();
    double[] z = contourLayer.getCrossSection(crossHairX, p.getBottomY(), crossHairX,
        p.getTopY());

    // Create XYChat of the same height as the main chart. Align the plot area with that of the
    // main chart.
    XYChart c = new XYChart(150, mainChart.getHeight());
    c.setPlotArea(10, p.getTopY(), c.getWidth() - 22, p.getHeight(), 0xdddddd, -1, -1,
        c.dashLineColor(unchecked((int)0xaf000000), Chart.DotLine), -1);

    // The vertical chart will have the x-axis vertical and y-axis horizontal. Synchroinze the
    // vertical axis (x-axis) with the y-axis of the main chart. Synchroinze the horizontal
    // axis (y-axis) with the color axis.
    c.swapXY();
    c.xAxis().syncAxis(mainChart.yAxis());
    c.yAxis().syncScale(contourLayer.colorAxis());
    c.yAxis().setLinearScale(160, 200, 10);


    // The vertical axis (x-axis) does not need labels as it is aligned with the main chart y-axis.
    c.xAxis().setLabelStyle("normal", 8, Chart.Transparent);

    // Rotate the horizontal axis (y-axis) labels by 270 degrees
    c.yAxis().setLabelStyle("normal", 8, Chart.TextColor, 270);


    if (ckbxXSLine.CheckState == CheckState.Checked)
    {
        LineLayer llayer = c.addLineLayer(z, 0x000000);
        llayer.setBorderColor(Chart.SameAsMainColor);
        llayer.setXData(mainChart.getYValue(p.getBottomY()), mainChart.getYValue(p.getTopY()));

    }
    else
    {
        // Add an area layer using the cross section data and the color scale of the color axis.
        int scaleColor = c.yScaleColor(contourLayer.colorAxis().getColorScale());
        AreaLayer layer = c.addAreaLayer(z, scaleColor);
        layer.setBorderColor(Chart.SameAsMainColor);
        layer.setXData(mainChart.getYValue(p.getBottomY()), mainChart.getYValue(p.getTopY()));
    }

    // Display the chart
    viewer.Chart = c;
    viewer.updateDisplay();
}

I get this:
Untitled.jpg

  Re: Setting Scale for contour plot
Posted by Peter Kwan on Jun-20-2024 00:02
Hi KeithB,

The code you included in your last message seems to be the one for the vertical cross section (the cross section displayed on the right side of the main chart), not the horizontal cross section (the cross section displayed at the bottom side of the main chart).

The axis scale should be:

c.xAxis().syncAxis(mainChart.xAxis());
c.yAxis().setLinearScale(160, 200, 10);

Note that there is no c.swapXY(), otherwise the chart will become vertical. Also, there is no syncScale. (In my last message, note that I comment out the syncScale line.)

Best Regards
Peter Kwan

  Re: Setting Scale for contour plot
Posted by KeithB on Jun-21-2024 04:35
That did it, thanks!