Saturday, 15 February 2014

charts - StackedAreaChart - autorange bug -



charts - StackedAreaChart - autorange bug -

my areachart category axis behaving strange. first of all, info goes way beyond y axis range. secondly, areacharts x axis doesn't start @ far left(first tick) , on sec tick?

this mvce:

public class fxmldocumentcontroller implements initializable { @fxml stackedareachart st; @fxml private label label; @override public void initialize(url url, resourcebundle rb) { // todo } @fxml private void handlebuttonaction(actionevent event) { observablelist<xychart.data> xylist1 = fxcollections.observablearraylist( new xychart.data<>("austria", 30), new xychart.data<>("rr", 40), new xychart.data<>("zz", 40), new xychart.data<>("zq", 50), new xychart.data<>("zr", 33), new xychart.data<>("zw", 44)); st.setanimated(false); xychart.series series1 = new xychart.series(xylist1); st.getdata().addall(series1); } }

if remove line:

new xychart.data<>("zq", 50)

the range ok, tick still strange.

we have 1 time again same bug we've found here. lastly value taking business relationship calculate chart y range. previous bigger values not shown.

a workaround set auto range false, , manually take care of it:

@fxml stackedareachart<string, integer> st; @fxml numberaxis yaxis; @fxml public void handlebuttonaction(actionevent e){ observablelist<xychart.data<string,integer>> xylist1 = fxcollections.observablearraylist( new xychart.data<>("austria", 30), new xychart.data<>("rr", 40), new xychart.data<>("zz", 40), new xychart.data<>("zq", 50), new xychart.data<>("zr", 33), new xychart.data<>("zw", 44)); st.setanimated(false); xychart.series series1 = new xychart.series(xylist1); st.getdata().addall(series1); yaxis.setautoranging(false); yaxis.setlowerbound(math.min(0, xylist1.stream().maptoint(d->d.getyvalue()).min().getasint())); yaxis.setupperbound(xylist1.stream().maptoint(d->d.getyvalue()).max().getasint()); yaxis.settickunit((yaxis.getupperbound()-yaxis.getlowerbound())/10); }

where in fxml file provide fx:id y axis:

<stackedareachart fx:id="st"> <xaxis> <categoryaxis side="bottom" /> </xaxis> <yaxis> <numberaxis fx:id="yaxis" side="left" /> </yaxis> </stackedareachart>

charts javafx

No comments:

Post a Comment