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

Message ListMessage List     Post MessagePost Message

  Area Graph
Posted by Bill on Jul-17-2020 18:01
Attachments:
Hi Peter,
    I have a area graph combination of linear and scatter. My problem is that the upper portion should have a color green. but it doesn't get the Y-axis maximum value to put the green color. Below is my code on graph area;

Ymaxvalue = c.yAxis().getMaxValue();

                for (int i = 0; i < NumRows; i++)
                {
                    for (int j = 0; j < NumCols; j++)
                    {
                        if (lblUOM.Text != "%" && RowArray[0, i] == "HIGH LIMIT")
                        {
                            try
                            {
                                HIGH_LIMIT[j] = Math.Round(Ymaxvalue, Convert.ToInt32(lblDecimal.Text));
                            }
                            catch
                            {
                                HIGH_LIMIT[j] = Chart.NoValue;
                            }
                        }
                    }
                }

                AreaLayer layer = c.addAreaLayer2(Chart.Side);
                layer.moveBack();
                layer.setHTMLImageMap("{disable}");
                if (lblIndicator.Text == "HIGH")
                {
                    layer.addDataSet(LOW_LIMIT, Convert.ToInt32(RedBackColor.Replace("#", "0x"), 16), "").setDataName("");
                    layer.addDataSet(MID_LIMIT, Convert.ToInt32(YellowBackColor.Replace("#", "0x"), 16), "").setDataName("");
                    layer.addDataSet(HIGH_LIMIT, Convert.ToInt32(GreenBackColor.Replace("#", "0x"), 16), "").setDataName("");
                }
                else
                {
                    layer.addDataSet(LOW_LIMIT, Convert.ToInt32(GreenBackColor.Replace("#", "0x"), 16), "").setDataName("");
                    layer.addDataSet(MID_LIMIT, Convert.ToInt32(YellowBackColor.Replace("#", "0x"), 16), "").setDataName("");
                    layer.addDataSet(HIGH_LIMIT, Convert.ToInt32(RedBackColor.Replace("#", "0x"), 16), "").setDataName("");
                }
AreaGraph.PNG

  Re: Area Graph
Posted by Peter Kwan on Jul-17-2020 22:35
Hi Bill,

The y-axis scale is computed based on your data values. Now your code tries to set the data values based on the y-axis scale. This is circular reasoning and would not work.

If you just want to fill the background with colors based on the y-values, you can use Axis.addZone. See:

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

For example:

' Set the region between y=32000 and the upper bound to the specified color
c.yAxis().addZone(32000, 9999999, Convert.ToInt32(RedBackColor.Replace("#", "0x"), 16))

You can use 9999999 in addZone because the zone will not affect the axis scale. Only data values in chart Layers can affect the axis scale.

Hope this can help.

Regards
Peter Kwan

  Re: Area Graph
Posted by Bill on Jul-18-2020 04:27
Its worked now. thansk a lot.

  Re: Area Graph
Posted by Bill on Jul-18-2020 04:30
Attachments:
How to remove the grindline in the chart?
Gridline.PNG

  Re: Area Graph
Posted by Peter Kwan on Jul-20-2020 11:49
Hi Bill,

When you call setPlotArea to configure the plot area, you can simply set the grid line color to Chart.Transparent. See:

https://www.advsofteng.com/doc/cdnet.htm#XYChart.setPlotArea.htm

Regards
Peter Kwan