We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.

Changing Base of Area Chart's Y val from zero

It appears that the default base of an area chart's Y value is zero instead of the minimum value.
This is a problems for me in trying to plot power levels which are often < 0.

So if I plot an area chart with points like this

Dim series As ChartSeries = New ChartSeries("test", ChartSeriesType.Area)

Then I see one 'triangle' shape as expected

But if I reduce all the Y values by 2 then I see one smaller triangle in the middle and two inverted triangles on each side.

How do I set the area base to me the minimum value and not zero?

areachart_261c96d1.zip

6 Replies

BK Bharathiraja K Syncfusion Team May 28, 2013 02:29 PM UTC

Hi Dennis,

Thanks for using Syncfusion products.

The first point of area chart is always tweaked from nearest value and also this is the default behavior of chart. So it is tweaked from zero. We can set the min and max  range to the chart primary axis dynamically using “Range” property. We suggest you to use the below code snippet to set min and max value to the chart axis.

[CS]

<code>

// Assign the Minimum value of Y-Axis to minY

minY=this.chartControl1.Series[0].Summary.MinY;

// Assign the Maximum value of Y-Axis to maxY

maxY = this.chartControl1.Series[0].Summary.MaxY;

// Customize the Y axis range and interval which has points of type double

this.chartControl1.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;

// Set the Min and Max range to the Primary Y-Axis

this.chartControl1.PrimaryYAxis.Range.Min = minY;

this.chartControl1.PrimaryYAxis.Range.Max = maxY;

</code>

AreaChart.zip

For more details regarding  range and intervals please refer our online document link.

http://help.syncfusion.com/ug/windows%20forms/chart/documents/axisrangeandintervals.htm

Please let us know if you have any concerns.

Thanks,

Bharathiraja K.

DB Dennis Beaugrand May 28, 2013 05:20 PM UTC

Sorry, that did not help - my picture ( attached to my post) still looks the same. I want the area under the line to be the area between the line and the baseline - NOT the area between the line and zero.

See attached output from your code which is upside down and another 'correct' area chart which is simply run using the same code using all positive numbers.

My issue is that both charts should look basically the same since all I did was add to each Y val

Thanks

Area Charts_59c56c37.zip

BK Bharathiraja K Syncfusion Team May 30, 2013 03:28 PM UTC

Hi Dennis,

We have analyzed your screen shots for negative and positive value and also compare with Microsoft excel chart. Both charts are rendering in correct format for positive and negative value. While we give the negative values to  the series, the chart would be render as inverted type and also this is the default behavior. Please check and compare the excel chart with syncfusion chart from the below link.

Please let us know if you have any concerns.

Thanks,

Bharathiraja K.

DB Dennis Beaugrand May 30, 2013 04:14 PM UTC

Microsoft Chart will work this way this if I add a hidden dummy series first - see attached sample.

Is there perhaps a way to offset the displayed Y values? - i.e make it lie.
If so then I could add 100 to each of my real Y values ( so everything is positive) and then display the Y axis offset -100.
For example if my Y value is -25, I would add 100 to it before giving it to chart so it is plotted as +75
Then as long as the Y Axis shows it at gridline '-25' then this will work.

If your Area chart will not do this then how else can I make it look ok?

DB Dennis Beaugrand May 30, 2013 05:26 PM UTC

never mind - I solved it.

Just need to use custom origin

CC1.PrimaryYAxis.CustomOrigin = True
CC1.PrimaryYAxis.Origin = -25
CC1.PrimaryYAxis.Range = New MinMaxInfo(-25, 10, 1)

now -25 is at the bottom of the graph and the area builds from the bottom instead of  zero above.

BK Bharathiraja K Syncfusion Team May 31, 2013 10:22 AM UTC

Hi Dennis,