|
Area Graph |
Posted by Bill on Jul-17-2020 18:01 |
|
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("");
}
|
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 |
|
How to remove the grindline in the chart?
|
|