use*_*466 7 java charts styles jfreechart
在Java中创建漂亮图表的最佳方法是什么?看起来图表的主要选项是JFreeChart,但不幸的是,默认情况下它们看起来非常简单.
将JFreeChart的示例:http://www.jfree.org/jfreechart/images/PriceVolumeDemo1.png 与其中一个Javascript图表库进行比较,例如http://www.highcharts.com/demo/spline-symbols/grid或http://people.iola.dk/olau/flot/examples/graph-types.html
javascript看起来更好 - 它们有流畅的线条,默认情况下字体很好,而且与JFreeChart相比整体看起来很好看,看起来非常简单.
是否有一个建立在JFreeChart之上的图表库,默认情况下看起来不错,或者是一些示例代码可以使普通的JFreeChart图表(例如折线图)看起来很棒?
Rob*_*bAu 11
我遇到过同样的问题.
此代码使JFreeChart看起来像Highcharts(目前仅支持条形图).它可以很容易地变得更有效:)
String fontName = "Lucida Sans";
JFreeChart chart = ChartFactory.createBarChart(null, "", "", dataset, PlotOrientation.VERTICAL, false, true, false );
StandardChartTheme theme = (StandardChartTheme)org.jfree.chart.StandardChartTheme.createJFreeTheme();
theme.setTitlePaint( Color.decode( "#4572a7" ) );
theme.setExtraLargeFont( new Font(fontName,Font.PLAIN, 16) ); //title
theme.setLargeFont( new Font(fontName,Font.BOLD, 15)); //axis-title
theme.setRegularFont( new Font(fontName,Font.PLAIN, 11));
theme.setRangeGridlinePaint( Color.decode("#C0C0C0"));
theme.setPlotBackgroundPaint( Color.white );
theme.setChartBackgroundPaint( Color.white );
theme.setGridBandPaint( Color.red );
theme.setAxisOffset( new RectangleInsets(0,0,0,0) );
theme.setBarPainter(new StandardBarPainter());
theme.setAxisLabelPaint( Color.decode("#666666") );
theme.apply( chart );
chart.getCategoryPlot().setOutlineVisible( false );
chart.getCategoryPlot().getRangeAxis().setAxisLineVisible( false );
chart.getCategoryPlot().getRangeAxis().setTickMarksVisible( false );
chart.getCategoryPlot().setRangeGridlineStroke( new BasicStroke() );
chart.getCategoryPlot().getRangeAxis().setTickLabelPaint( Color.decode("#666666") );
chart.getCategoryPlot().getDomainAxis().setTickLabelPaint( Color.decode("#666666") );
chart.setTextAntiAlias( true );
chart.setAntiAlias( true );
chart.getCategoryPlot().getRenderer().setSeriesPaint( 0, Color.decode( "#4572a7" ));
BarRenderer rend = (BarRenderer) chart.getCategoryPlot().getRenderer();
rend.setShadowVisible( true );
rend.setShadowXOffset( 2 );
rend.setShadowYOffset( 0 );
rend.setShadowPaint( Color.decode( "#C0C0C0"));
rend.setMaximumBarWidth( 0.1);
Run Code Online (Sandbox Code Playgroud)
http://www.jfree.org/jfreechart/samples.html
在那里您可以找到许多示例(您需要下载 JFreeChart Demo(网络启动))。使用 jFreeChart 进行一些工作后,我正在考虑转向 EasyChart(请关注: http: //www.objectplanet.com/easycharts/examples.html),但实际上它看起来与 jFreeChart 非常相似。JFreeChart很容易编写,我不知道EasyChart。
但根据你的问题,在 JFreeChart 中更改 Font、LineRenderer 或任何设计都没有问题,因此你可以修改它,使其看起来与你从 JavaScript 发布的一模一样。
| 归档时间: |
|
| 查看次数: |
9901 次 |
| 最近记录: |