XYPlot without vertical axis and horizontal line grid?

帅比萌擦擦* 提交于 2019-12-11 04:36:58

问题


Can I draw only vertical data axis (without axis line( in XYPlot and only horizontal line in grid lines (I know the hack - draw them by white color, that is coincident with background color, may be, there is more pure way) ?


回答1:


You can specify currency formatting on the range axis using setNumberFormatOverride(), as shown here.

NumberFormat currency = NumberFormat.getCurrencyInstance();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setNumberFormatOverride(currency);



回答2:


Here is a simple example.

  // create a dataset...
  XYSeries series = new XYSeries("Random Data");
  series.add(1.0, 500.2);
  series.add(10.0, 694.1);

  // Create an XY Line chart
  XYSeriesCollection data = new XYSeriesCollection(series);
  JFreeChart chart = ChartFactory.createXYLineChart("XY Series Demo",
                                                    null,
                                                    "Y",
                                                    data,
                                                    PlotOrientation.VERTICAL,
                                                    true,
                                                    true,
                                                    false);
  XYPlot plot = (XYPlot) chart.getPlot();
  plot.setDomainGridlinesVisible(false);

The vertical lines are hidden by calling plot.setDomainGridLinesVisible(false).



来源:https://stackoverflow.com/questions/14442404/xyplot-without-vertical-axis-and-horizontal-line-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!