JFreeChart: One Axis Distribution Chart -
i'm using jfreechart , i'd have chart 1 dimension only: x-axis (that indicates milliseconds) , shapes (that rapresents events).
i created xylinechart , xyplot hidden y-axis :
this.chart = chartfactory.createxylinechart( "","","",dataset,plotorientation.vertical, false, true,false); xyplot plot = (xyplot) chart.getplot(); plot.setbackgroundpaint( color.lightgray ); plot.setdomaingridlinepaint( color.white ); plot.setrangegridlinepaint( color.white ); plot.setrangegridlinesvisible(false); plot.setdomaincrosshairvisible( true ); plot.setrangecrosshairvisible( false ); numberaxis range = (numberaxis) plot.getrangeaxis(); range.setvisible(false); range.setrange(0.0, 1.0); range.settickunit(new numbertickunit(0.5));
in dataset used fixed y-coordinate.
i obtained result:
image 1 http://imageshack.us/a/img46/4935/pointsuw.jpg
but i'd have this:
image 2 http://img521.imageshack.us/img521/3721/points2.jpg
if resize panel, entire chart resized (title, numbers, shapes). i'd resize "grey area" only.
obviously it's better if , appropriate chart type exist.
thanks lot.
the entire chart resized in case width / height below configurable threshold.
i have modified example adding code chartpanel , using 2 methods chartpanel.setminimumdrawwidth(int)
, chartpanel.setminimumdrawwidth(int)
set these thresholds.
this.chart = chartfactory.createxylinechart( "","","",dataset,plotorientation.vertical, false, true,false); xyplot plot = (xyplot) chart.getplot(); plot.setbackgroundpaint( color.lightgray ); plot.setdomaingridlinepaint( color.white ); plot.setrangegridlinepaint( color.white ); plot.setrangegridlinesvisible(false); plot.setdomaincrosshairvisible( true ); plot.setrangecrosshairvisible( false ); numberaxis range = (numberaxis) plot.getrangeaxis(); range.setvisible(false); range.setrange(0.0, 1.0); range.settickunit(new numbertickunit(0.5)); chartpanel chartpanel = new chartpanel(this.chart); chart.setminimumdrawheight(10); chart.setminimumdrawwidth(10);
Comments
Post a Comment