List of usage examples for org.jfree.chart.axis NumberAxis createStandardTickUnits
public static TickUnitSource createStandardTickUnits(Locale locale)
From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree.JFreeChartDriver.java
/** create */ public JFreeChartDriver() { super("JFreeChart Driver"); //$NON-NLS-1$ this.m_units = NumberAxis.createStandardTickUnits(Locale.US); }
From source file:com.rapidminer.gui.plotter.charts.SeriesChartPlotter.java
private JFreeChart createChart(XYDataset dataset, boolean createLegend) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, createLegend, // include legend true, // tooltips false // urls );/*from www. ja va 2 s .c o m*/ chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customization... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); DeviationRenderer renderer = new DeviationRenderer(true, false); // colors if (dataset.getSeriesCount() == 1) { renderer.setSeriesStroke(0, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setSeriesPaint(0, getColorProvider().getPointColor(1.0d)); } else { // special case needed for avoiding devision by zero for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setSeriesPaint(i, getColorProvider().getPointColor(1.0d - i / (double) (dataset.getSeriesCount() - 1))); } } // background for bounds if (plotBounds) { float[] dashArray = new float[] { 7, 14 }; renderer.setSeriesStroke(boundsSeriesIndex, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, dashArray, 0)); renderer.setSeriesPaint(boundsSeriesIndex, Color.GRAY.brighter()); renderer.setSeriesFillPaint(boundsSeriesIndex, Color.GRAY); } // alpha renderer.setAlpha(0.25f); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); if (axis[INDEX] < 0) { xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US)); xAxis.setLabel(SERIESINDEX_LABEL); Range range = getRangeForName(SERIESINDEX_LABEL); if (range == null) { xAxis.setAutoRange(true); xAxis.setAutoRangeStickyZero(false); xAxis.setAutoRangeIncludesZero(false); } else { xAxis.setRange(range, true, false); } } else { xAxis.setLabel(dataTable.getColumnName(axis[INDEX])); Range range = getRangeForDimension(axis[INDEX]); if (range == null) { xAxis.setAutoRange(true); xAxis.setAutoRangeStickyZero(false); xAxis.setAutoRangeIncludesZero(false); } else { xAxis.setRange(range, true, false); } } xAxis.setLabelFont(LABEL_FONT_BOLD); xAxis.setTickLabelFont(LABEL_FONT); xAxis.setVerticalTickLabels(isLabelRotating()); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setLabel(VALUEAXIS_LABEL); yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); setYAxisRange(yAxis); yAxis.setLabelFont(LABEL_FONT_BOLD); yAxis.setTickLabelFont(LABEL_FONT); return chart; }
From source file:com.rapidminer.gui.plotter.charts.MultipleScatterPlotter.java
@Override public void updatePlotter() { prepareData();/*from www . ja v a 2 s. c o m*/ JFreeChart chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // URLs ); if (xAxis >= 0) { int size = dataSet.getSeriesCount(); chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // URLs ); // renderer settings XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setUseOutlinePaint(true); renderer.setDrawOutlines(true); for (int i = 0; i < size; i++) { renderer.setSeriesShapesVisible(i, this.showPoints[plotIndexToColumnIndexMap.get(i)]); renderer.setSeriesLinesVisible(i, this.showLines[plotIndexToColumnIndexMap.get(i)]); } renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 7, 7)); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } } // GENERAL CHART SETTINGS int size = dataSet.getSeriesCount(); if (size <= 1) { chart.getXYPlot().getRenderer().setSeriesPaint(0, getColorProvider().getPointColor(1.0d)); } else { for (int i = 0; i < dataSet.getSeriesCount(); i++) { chart.getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); chart.getXYPlot().getRenderer().setSeriesPaint(i, getColorProvider().getPointColor(i / (double) (dataSet.getSeriesCount() - 1))); } } // set the background colors for the chart... chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(false); // general plot settings XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // domain axis if (xAxis >= 0) { if (dataTable.isNominal(xAxis)) { String[] values = new String[dataTable.getNumberOfValues(xAxis)]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(xAxis, i); } plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(xAxis), values)); } else if ((dataTable.isDate(xAxis)) || (dataTable.isDateTime(xAxis))) { DateAxis domainAxis = new DateAxis(dataTable.getColumnName(xAxis)); domainAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setDomainAxis(domainAxis); } else { if (xLogScale) { LogAxis domainAxis = new LogAxis(dataTable.getColumnName(xAxis)); domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); plot.setDomainAxis(domainAxis); } else { NumberAxis domainAxis = new NumberAxis(dataTable.getColumnName(xAxis)); domainAxis.setAutoRangeStickyZero(false); domainAxis.setAutoRangeIncludesZero(false); plot.setDomainAxis(domainAxis); } } } plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD); plot.getDomainAxis().setTickLabelFont(LABEL_FONT); // rotate labels if (isLabelRotating()) { plot.getDomainAxis().setTickLabelsVisible(true); plot.getDomainAxis().setVerticalTickLabels(true); } // range axis plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); // Chart Panel Settings if (panel instanceof AbstractChartPanel) { panel.setChart(chart); } else { panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN); final ChartPanelShiftController controller = new ChartPanelShiftController(panel); panel.addMouseListener(controller); panel.addMouseMotionListener(controller); // react to mouse clicks // ATTENTION: ACTIVATING THIS WILL LEAD TO SEVERE MEMORY LEAKS!!! (see below) panel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { if (e.getTrigger().getClickCount() > 1) { XYItemEntity entity = (XYItemEntity) e.getEntity(); if (entity != null) { String id = idMap.get(new SeriesAndItem(entity.getSeriesIndex(), entity.getItem())); if (id != null) { ObjectVisualizer visualizer = ObjectVisualizerService .getVisualizerForObject(dataTable); visualizer.startVisualization(id); } } } } @Override public void chartMouseMoved(ChartMouseEvent e) { } }); } // tooltips class CustomXYToolTipGenerator implements XYToolTipGenerator { public CustomXYToolTipGenerator() { } @Override public String generateToolTip(XYDataset dataset, int row, int column) { String id = idMap.get(new SeriesAndItem(row, column)); if (id != null) { return "<html><b>Id: " + id + "</b> (" + dataset.getSeriesKey(row) + ", " + Tools.formatIntegerIfPossible(dataset.getXValue(row, column)) + ", " + Tools.formatIntegerIfPossible(dataset.getYValue(row, column)) + ")</html>"; } else { return "<html>(" + dataset.getSeriesKey(row) + ", " + Tools.formatIntegerIfPossible(dataset.getXValue(row, column)) + ", " + Tools.formatIntegerIfPossible(dataset.getYValue(row, column)) + ")</html>"; } } } for (int i = 0; i < dataSet.getSeriesCount(); i++) { plot.getRenderer().setSeriesToolTipGenerator(i, new CustomXYToolTipGenerator()); } }
From source file:com.rapidminer.gui.plotter.charts.BubbleChartPlotter.java
@Override public void updatePlotter() { final DataTable dataTable = getDataTable(); prepareData();/*from ww w. jav a2 s .co m*/ JFreeChart chart = ChartFactory.createBubbleChart(null, // chart title null, // domain axis label null, // range axis label xyzDataSet, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // URLs ); if (axis[X_AXIS] >= 0 && axis[Y_AXIS] >= 0 && axis[BUBBLE_SIZE_AXIS] >= 0) { if (nominal) { int size = xyzDataSet.getSeriesCount(); chart = ChartFactory.createBubbleChart(null, // chart title null, // domain axis label null, // range axis label xyzDataSet, // data PlotOrientation.VERTICAL, // orientation colorColumn >= 0 && size < 100 ? true : false, // include legend true, // tooltips false // URLs ); // renderer settings XYBubbleRenderer renderer = (XYBubbleRenderer) chart.getXYPlot().getRenderer(); renderer.setBaseOutlinePaint(Color.BLACK); if (size > 1) { for (int i = 0; i < size; i++) { renderer.setSeriesPaint(i, getColorProvider(true).getPointColor(i / (double) (size - 1))); renderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 7, 7)); } } else { renderer.setSeriesPaint(0, getColorProvider().getPointColor(1.0d)); renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 7, 7)); } // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } } else { chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label xyzDataSet, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // URLs ); // renderer settings ColorizedBubbleRenderer renderer = new ColorizedBubbleRenderer(this.colors); renderer.setBaseOutlinePaint(Color.BLACK); chart.getXYPlot().setRenderer(renderer); // legend settings chart.addLegend(new LegendTitle(renderer) { private static final long serialVersionUID = 1288380309936848376L; @Override public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params) { if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn) || dataTable.isDateTime(colorColumn)) { drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7), dataTable, colorColumn, minColor, maxColor); return new BlockResult(); } else { final String minColorString = Tools.formatNumber(minColor); final String maxColorString = Tools.formatNumber(maxColor); drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 90), (int) (area.getCenterY() + 7), dataTable.getColumnName(colorColumn), minColorString, maxColorString); return new BlockResult(); } } @Override public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) { draw(g2, area, null); } }); } } // GENERAL CHART SETTINGS // set the background colors for the chart... chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setBackgroundPaint(Color.WHITE); chart.getPlot().setForegroundAlpha(0.7f); XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // domain axis if (axis[X_AXIS] >= 0) { if (dataTable.isNominal(axis[X_AXIS])) { String[] values = new String[dataTable.getNumberOfValues(axis[X_AXIS])]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(axis[X_AXIS], i); } plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(axis[X_AXIS]), values)); } else if (dataTable.isDate(axis[X_AXIS]) || dataTable.isDateTime(axis[X_AXIS])) { DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setDomainAxis(domainAxis); } else { if (logScales[X_AXIS]) { LogAxis domainAxis = new LogAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); plot.setDomainAxis(domainAxis); } else { plot.setDomainAxis(new NumberAxis(dataTable.getColumnName(axis[X_AXIS]))); } } Range range = getRangeForDimension(axis[X_AXIS]); if (range != null) { plot.getDomainAxis().setRange(range, true, false); } else { plot.getDomainAxis().setAutoRange(true); } } plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD); plot.getDomainAxis().setTickLabelFont(LABEL_FONT); // rotate labels if (isLabelRotating()) { plot.getDomainAxis().setTickLabelsVisible(true); plot.getDomainAxis().setVerticalTickLabels(true); } // range axis if (axis[Y_AXIS] >= 0) { if (dataTable.isNominal(axis[Y_AXIS])) { String[] values = new String[dataTable.getNumberOfValues(axis[Y_AXIS])]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(axis[Y_AXIS], i); } plot.setRangeAxis(new SymbolAxis(dataTable.getColumnName(axis[Y_AXIS]), values)); } else if (dataTable.isDate(axis[Y_AXIS]) || dataTable.isDateTime(axis[Y_AXIS])) { DateAxis rangeAxis = new DateAxis(dataTable.getColumnName(axis[Y_AXIS])); rangeAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setRangeAxis(rangeAxis); } else { plot.setRangeAxis(new NumberAxis(dataTable.getColumnName(axis[Y_AXIS]))); } Range range = getRangeForDimension(axis[Y_AXIS]); if (range != null) { plot.getRangeAxis().setRange(range, true, false); } else { plot.getRangeAxis().setAutoRange(true); } } plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); AbstractChartPanel panel = getPlotterPanel(); // Chart Panel Settings if (panel == null) { panel = createPanel(chart); } else { panel.setChart(chart); } // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!! panel.getChartRenderingInfo().setEntityCollection(null); }
From source file:com.rapidminer.gui.plotter.charts.Abstract2DChartPlotter.java
@Override public void updatePlotter() { prepareData();/*from ww w. j av a 2 s .co m*/ JFreeChart chart; if (axis[X_AXIS] >= 0 && axis[Y_AXIS] >= 0) { if (nominal) { int size = dataSet.getSeriesCount(); chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation colorColumn >= 0 && size < 100 ? true : false, // include legend true, // tooltips false // URLs ); // renderer settings try { chart.getXYPlot().setRenderer(getItemRenderer(nominal, size, this.minColor, this.maxColor)); } catch (Exception e) { // do nothing } // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); BlockContainer wrapper = new BlockContainer(new BorderArrangement()); LabelBlock title = new LabelBlock(getDataTable().getColumnName(colorColumn), new Font("SansSerif", Font.BOLD, 12)); title.setPadding(0, 5, 5, 5); wrapper.add(title, RectangleEdge.LEFT); BlockContainer items = legend.getItemContainer(); wrapper.add(items, RectangleEdge.RIGHT); legend.setWrapper(wrapper); } } else { chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // URLs ); // renderer settings try { chart.getXYPlot().setRenderer(getItemRenderer(nominal, -1, minColor, maxColor)); } catch (Exception e) { // do nothing } LegendTitle legendTitle = new LegendTitle(chart.getXYPlot().getRenderer()) { private static final long serialVersionUID = 1288380309936848376L; @Override public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params) { if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn) || dataTable.isDateTime(colorColumn)) { drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7), dataTable, colorColumn, minColor, maxColor); return new BlockResult(); } else { final String minColorString = Tools.formatNumber(minColor); final String maxColorString = Tools.formatNumber(maxColor); drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 75), (int) (area.getCenterY() + 7), getDataTable().getColumnName(colorColumn), minColorString, maxColorString); return new BlockResult(); } } @Override public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) { draw(g2, area, null); } }; BlockContainer wrapper = new BlockContainer(new BorderArrangement()); LabelBlock title = new LabelBlock(getDataTable().getColumnName(colorColumn), new Font("SansSerif", Font.BOLD, 12)); title.setPadding(0, 5, 5, 5); wrapper.add(title, RectangleEdge.LEFT); BlockContainer items = legendTitle.getItemContainer(); wrapper.add(items, RectangleEdge.RIGHT); legendTitle.setWrapper(wrapper); chart.addLegend(legendTitle); } } else { chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // URLs ); } // GENERAL CHART SETTINGS // set the background colors for the chart... chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(false); // general plot settings XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // domain axis if (axis[X_AXIS] >= 0) { if (dataTable.isNominal(axis[X_AXIS])) { String[] values = new String[dataTable.getNumberOfValues(axis[X_AXIS])]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(axis[X_AXIS], i); } plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(axis[X_AXIS]), values)); } else if (dataTable.isDate(axis[X_AXIS]) || dataTable.isDateTime(axis[X_AXIS])) { DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setDomainAxis(domainAxis); } else { if (logScales[X_AXIS]) { LogAxis domainAxis = new LogAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); plot.setDomainAxis(domainAxis); } else { NumberAxis domainAxis = new NumberAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setAutoRangeStickyZero(false); domainAxis.setAutoRangeIncludesZero(false); plot.setDomainAxis(domainAxis); } } } if (axis[X_AXIS] >= 0) { Range range = getRangeForDimension(axis[X_AXIS]); if (range != null) { plot.getDomainAxis().setRange(range, true, false); } else { plot.getDomainAxis().setAutoRange(true); } } plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD); plot.getDomainAxis().setTickLabelFont(LABEL_FONT); // rotate labels if (isLabelRotating()) { plot.getDomainAxis().setTickLabelsVisible(true); plot.getDomainAxis().setVerticalTickLabels(true); } // range axis if (axis[Y_AXIS] >= 0) { if (dataTable.isNominal(axis[Y_AXIS])) { String[] values = new String[dataTable.getNumberOfValues(axis[Y_AXIS])]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(axis[Y_AXIS], i); } plot.setRangeAxis(new SymbolAxis(dataTable.getColumnName(axis[Y_AXIS]), values)); } else if (dataTable.isDate(axis[Y_AXIS]) || dataTable.isDateTime(axis[Y_AXIS])) { DateAxis rangeAxis = new DateAxis(dataTable.getColumnName(axis[Y_AXIS])); rangeAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setRangeAxis(rangeAxis); } else { if (logScales[Y_AXIS]) { LogAxis rangeAxis = new LogAxis(dataTable.getColumnName(axis[Y_AXIS])); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); plot.setRangeAxis(rangeAxis); } else { NumberAxis rangeAxis = new NumberAxis(dataTable.getColumnName(axis[Y_AXIS])); rangeAxis.setAutoRangeStickyZero(false); rangeAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(rangeAxis); } } } plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); if (axis[Y_AXIS] >= 0) { Range range = getRangeForDimension(axis[Y_AXIS]); if (range != null) { plot.getRangeAxis().setRange(range, true, false); } else { plot.getRangeAxis().setAutoRange(true); } } // Chart Panel Settings AbstractChartPanel panel = getPlotterPanel(); if (panel == null) { panel = createPanel(chart); // react to mouse clicks panel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { if (e.getTrigger().getClickCount() > 1) { if (e.getEntity() instanceof XYItemEntity) { XYItemEntity entity = (XYItemEntity) e.getEntity(); if (entity != null) { String id = idMap.get(new SeriesAndItem(entity.getSeriesIndex(), entity.getItem())); if (id != null) { ObjectVisualizer visualizer = ObjectVisualizerService .getVisualizerForObject(dataTable); visualizer.startVisualization(id); } } } } } @Override public void chartMouseMoved(ChartMouseEvent e) { } }); } else { panel.setChart(chart); } // tooltips class CustomXYToolTipGenerator implements XYToolTipGenerator { public CustomXYToolTipGenerator() { } private String formatValue(int axis, double value) { if (dataTable.isNominal(axis)) { // TODO add mapping of value to nominal value return Tools.formatIntegerIfPossible(value); } else if (dataTable.isNumerical(axis)) { return Tools.formatIntegerIfPossible(value); } else if (dataTable.isDate(axis)) { return Tools.createDateAndFormat(value); } else if (dataTable.isTime(axis)) { return Tools.createTimeAndFormat(value); } else if (dataTable.isDateTime(axis)) { return Tools.createDateTimeAndFormat(value); } return "?"; } @Override public String generateToolTip(XYDataset dataset, int row, int column) { String id = idMap.get(new SeriesAndItem(row, column)); if (id != null) { return "<html><b>Id: " + id + "</b> (" + dataset.getSeriesKey(row) + ", " + formatValue(axis[X_AXIS], dataset.getXValue(row, column)) + ", " + formatValue(axis[Y_AXIS], dataset.getYValue(row, column)) + ")</html>"; } else { return "<html>(" + dataset.getSeriesKey(row) + ", " + formatValue(axis[X_AXIS], dataset.getXValue(row, column)) + ", " + formatValue(axis[Y_AXIS], dataset.getYValue(row, column)) + ")</html>"; } } } for (int i = 0; i < dataSet.getSeriesCount(); i++) { plot.getRenderer().setSeriesToolTipGenerator(i, new CustomXYToolTipGenerator()); } }