I set the range on the chart to be -50 to 150
When I did this I noticed a horizontal line drawn at 0
Is there a way to remove this line?
I have tried
- Looking though the renderer and trying all the set...Paint methods to see if I could just change the color of the line
- Changing options on the plot (CategoryPlot)
- Changing options on the number axis
- Changing options on the domain axis.
- Using a CategoryMarker to draw a line that matches the background color
Here is the code we are using to setup the line chart
Code: Select all
chart = ChartFactory.createLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, true, false);
chart.setBorderVisible(false);
backgroundColor = new Color(255, 250, 212);
chart.setBackgroundPaint(backgroundColor);
chart.setPadding(RectangleInsets.ZERO_INSETS);
renderer = new LineAndShapeRenderer();
renderer.setBaseShapesVisible(true);
renderer.setSeriesShapesVisible(0, true);
renderer.setBaseItemLabelsVisible(false);
seriesColor = new Color(12, 133, 189);
renderer.setSeriesPaint(0, seriesColor);
renderer.setSeriesShape(0, ShapeUtilities.createDiamond(4));
plot = (CategoryPlot) chart.getPlot();
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);
plot.setRangeCrosshairVisible(false);
plot.setOutlineVisible(false);
plot.setRenderer(renderer);
plot.setBackgroundPaint(backgroundColor);
rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// Setting range to allow for the point to be fully visible when it is at the top (100) or bottom (0) of the
// range.
rangeAxis.setRange(-50, 150);
rangeAxis.setAxisLineVisible(false);
rangeAxis.setTickLabelsVisible(false);
rangeAxis.setTickMarksVisible(false);
rangeAxis.setVisible(false);
rangeAxis.setNegativeArrowVisible(false);
plot.getDomainAxis().setTickLabelsVisible(false);
plot.getDomainAxis().setAxisLineVisible(false);
plot.getDomainAxis().setTickMarksVisible(false);
plot.getDomainAxis().setVisible(false);
chartPanel = new ChartPanel(chart);
chartPanel.setOpaque(false);
chartPanel.setMinimumDrawWidth(0);
chartPanel.setMaximumDrawWidth(1000);
chartPanel.setMinimumDrawHeight(0);
chartPanel.setMaximumDrawHeight(1000);
chartPanel.setHorizontalAxisTrace(false);
chartPanel.setVerticalAxisTrace(false);
chartPanel.setRangeZoomable(false);
chartPanel.setDomainZoomable(false);
chartPanel.setBackground(backgroundColor);
frame.add(chartPanel);
frame.setVisible(true);