Reputation: 37
I'm using xChart and I would like to draw three different lines, each one with a different color on the same line chart. Up 'til now all I could do is draw them separately and it's not good at all :/ Tried using addSeries() and setting the line colorlike this:
Series red=chart.addSeries("Red", dataX, dataY).setLineColor(Color.red);
but i can't get rid of the markers :/ Edit: to get rid of the marker here's what I did
SeriesMarker marker= SeriesMarker.NONE;
but how can I display three lines in ONE chart, please ?
Upvotes: 1
Views: 1196
Reputation: 2755
Here's how you do that since V 3.0.0:
// Create Chart
Chart_XY chart = new ChartBuilder_XY().width(800).height(600).xAxisTitle("X").yAxisTitle("Y").build();
// Customize Chart
chart.getStyler().setLegendPosition(LegendPosition.InsideNE);
// Series
chart.addSeries("a", new double[] { 0, 3, 5, 7, 9 }, new double[] { -3, 5, 9, 6, 5 }).setMarker(SeriesMarkers.NONE);
chart.addSeries("b", new double[] { 0, 2, 4, 6, 9 }, new double[] { -1, 6, 4, 0, 4 }).setMarker(SeriesMarkers.NONE);
chart.addSeries("c", new double[] { 0, 1, 3, 8, 9 }, new double[] { -2, -1, 1, 0, 1 }).setMarker(SeriesMarkers.NONE);
Upvotes: 1