|
centered positive/negative bar chart |
Posted by Jay on Jun-16-2012 01:40 |
|
Hi Peter,
I've got a line chart with current year numbers and prior year numbers that I've laid over a bar chart with the month by month delta between the two. I'd like to make the horizontal bar chart static with the zero point centered vertically on the chart with a defined scaling. The chart is generating but i can't determine how to get the yaxis2 to be centered regardless of the values being displayed on it, and I haven't found how to make the scaling static. i.e. i'd like to have it always centered and have the scale go +/- 1000 so that month to month the chart displays the same.
I've included representational code below for how I'm generating the bar chart. Can you clue me in as to how to make the bar chart zero point stick at the chart verticle mid point and define a static scale for it? Any help is greatly appreciated!
Jay
Dim layer As SplineLayer = c.addSplineLayer()
layer.addDataSet(table1.getCol(4), &HF5A500, Pfy).setDataSymbol(Chart.DiamondSymbol, 10)
layer.addDataSet(table1.getCol(3), &H808A5, Cfy).setDataSymbol(Chart.CircleSymbol, 8)
c.setPlotArea(60, 40, 490, 300, &HF6F6F6, &HFCFCFC, &HC0C0C0, &H90C0C0C0)
Dim ESBar2 As BarLayer = c.addBarLayer2(Chart.Overlay)
ESBar2.addDataSet(New ArrayMath(tableESdiff.getCol(2)).selectGEZ(Nothing, Chart.NoValue).result(), &H6666FF)
ESBar2.addDataSet(New ArrayMath(tableESdiff.getCol(2)).selectLTZ(Nothing, Chart.NoValue).result(), &HFF6600)
ESBar2.setUseYAxis2()
c.yAxis2().addZone(0, 9999, &HCCCCFF)
c.yAxis2().addZone(-9999, 0, &HFFCCCC)
c.yAxis2().setTitle(Pfy & " - " & Cfy & " Delta")
c.yAxis2().setLabelStyle("Arial Bold", 8, &H505A8)
ESBar2.setAggregateLabelStyle("Arial Bold", 8, layer.yZoneColor(0, &HCC3300, &H3333FF))
ESBar2.setBarGap(0.1)
Call ESBar2.setXData(0.7, 10.7)
ESBar2.setBorderColor(Chart.Transparent, 1) |
Re: centered positive/negative bar chart |
Posted by Peter Kwan on Jun-19-2012 01:56 |
|
Hi Jay,
If you would like yAxis2 to be always -1000 to 1000, please use:
c.yAxis2().setLinearScale(-1000, 1000, 500)
Hope this can help.
Regards
Peter Kwan |
|