List of usage examples for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesVisibleInLegend
public void setSeriesVisibleInLegend(int series, Boolean visible)
From source file:cmpt305.lab3.gui.controllers.CompareGraphController.java
public CompareGraphController(User main, User... users) { this.main = main; BAR_GRAPH = new DefaultCategoryDataset(); COMPARE_GRAPH = new DefaultCategoryDataset(); JFreeChart t = ChartFactory.createBarChart("SteamWeb", "User", "Time Spent in Each Genre", BAR_GRAPH); addData(main);/*from ww w . j a va 2 s. c o m*/ if (users != null && users.length > 0) { Arrays.asList(users).stream().filter(u -> !u.equals(main)).distinct().forEach(u -> { addData(u); COMPARE.add(u); }); } CategoryPlot plot = t.getCategoryPlot(); plot.setDataset(1, COMPARE_GRAPH); plot.mapDatasetToRangeAxis(1, 1); plot.setRangeAxis(1, new NumberAxis("Compatability")); LineAndShapeRenderer rend = new LineAndShapeRenderer(); rend.setBaseToolTipGenerator((cd, x, y) -> String.format("%s: %f", cd.getColumnKey(y), cd.getValue(x, y))); rend.setSeriesVisibleInLegend(0, false); plot.setRenderer(1, rend); VIEW = new ChartPanel(t); setSize(); }
From source file:org.openfaces.component.chart.impl.configuration.LineAndShapePropertiesConfigurator.java
private void applyPropertiesToCategoryDataSet(LineAndShapeRenderer renderer, CategoryDataset dataSet, LineChartView view, LineProperties lineProperties) { DynamicCategoryGenerator dcg = new DynamicCategoryGenerator(view, lineProperties.getDynamicCondition()); ChartModel chartModel = view.getChart().getModel(); if (chartModel == null) return;//from ww w . j a v a2 s . co m Series[] series = chartModel.getSeries(); if (series == null) return; for (int j = 0; j < series.length; j++) { if (!dcg.generateCondition(dataSet, j, 0)) continue; Boolean hideSeries = lineProperties.getHideSeries(); if (hideSeries != null) { boolean seriesVisible = !hideSeries; renderer.setSeriesVisible(j, seriesVisible); } Boolean shapesVisible = lineProperties.getShapesVisible(); if (shapesVisible != null) renderer.setSeriesShapesVisible(j, shapesVisible); //set style Boolean showInLegend = lineProperties.getShowInLegend(); if (showInLegend != null) renderer.setSeriesVisibleInLegend(j, showInLegend); StyleObjectModel linePropertiesStyleModel = lineProperties.getStyleObjectModel(); if (linePropertiesStyleModel != null && linePropertiesStyleModel.getBorder() != null) { StyleBorderModel model = linePropertiesStyleModel.getBorder(); Color color = model.getColor(); if (color != null) renderer.setSeriesPaint(j, color); renderer.setSeriesLinesVisible(j, Boolean.valueOf(!model.isNone())); renderer.setSeriesStroke(j, PropertiesConverter.toStroke(model)); } } }