List of usage examples for org.jfree.chart.plot ValueMarker setLabel
public void setLabel(String label)
From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java
/** * Generate a {@link ValueMarker}.//from w ww . jav a2 s. c o m */ private static ValueMarker addValueMarker(String text, double x, boolean domain) { ValueMarker marker = new ValueMarker(x); marker.setPaint(Color.GRAY); marker.setLabel(text); if (domain) { marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } else { marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } return marker; }
From source file:storybook.ui.chart.jfreechart.ChartUtil.java
public static Marker getDateMarker(Date paramDate, String paramString, boolean paramBoolean) { double d = paramDate.getTime(); ValueMarker localValueMarker = new ValueMarker(d, Color.red, new BasicStroke(0.3F)); localValueMarker.setLabel(paramString); localValueMarker.setLabelFont(new Font("SansSerif", 2, 11)); localValueMarker.setLabelAnchor(RectangleAnchor.BOTTOM); if (paramBoolean) { localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } else {//w w w . j av a 2s . co m localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } return localValueMarker; }
From source file:storybook.ui.chart.jfreechart.ChartUtil.java
public static Marker getAverageMarker(double paramDouble) { ValueMarker localValueMarker = new ValueMarker(paramDouble, Color.red, new BasicStroke(0.3F)); localValueMarker.setLabel(I18N.getMsg("msg.common.average")); localValueMarker.setLabelFont(new Font("SansSerif", 2, 11)); localValueMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); return localValueMarker; }
From source file:org.jfree.chart.demo.MarkerDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Marker Demo 2", "X", "Temperature", xydataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainGridlineStroke(new BasicStroke(1.0F)); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeGridlineStroke(new BasicStroke(1.0F)); xyplot.setRangeTickBandPaint(new Color(240, 240, 240)); PeriodAxis periodaxis = new PeriodAxis(null, new Hour(0, 30, 6, 2005), new Hour(23, 30, 6, 2005)); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Hour.class, new SimpleDateFormat("HH")); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("dd-MMM")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis);/*from w w w . j a v a 2 s.c o m*/ ValueAxis valueaxis = xyplot.getRangeAxis(); valueaxis.setRange(0.0D, 100D); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.green); xyitemrenderer.setSeriesStroke(0, new BasicStroke(2.0F)); ValueMarker valuemarker = new ValueMarker(80D); valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); valuemarker.setPaint(Color.red); valuemarker.setStroke(new BasicStroke(2.0F)); valuemarker.setLabel("Temperature Threshold"); valuemarker.setLabelFont(new Font("SansSerif", 0, 11)); valuemarker.setLabelPaint(Color.red); valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); xyplot.addRangeMarker(valuemarker); Hour hour = new Hour(18, 30, 6, 2005); Hour hour1 = new Hour(20, 30, 6, 2005); double d = hour.getFirstMillisecond(); double d1 = hour1.getFirstMillisecond(); IntervalMarker intervalmarker = new IntervalMarker(d, d1); intervalmarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); intervalmarker.setPaint(new Color(150, 150, 255)); intervalmarker.setLabel("Automatic Cooling"); intervalmarker.setLabelFont(new Font("SansSerif", 0, 11)); intervalmarker.setLabelPaint(Color.blue); intervalmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); intervalmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); xyplot.addDomainMarker(intervalmarker, Layer.BACKGROUND); ValueMarker valuemarker1 = new ValueMarker(d, Color.blue, new BasicStroke(2.0F)); ValueMarker valuemarker2 = new ValueMarker(d1, Color.blue, new BasicStroke(2.0F)); xyplot.addDomainMarker(valuemarker1, Layer.BACKGROUND); xyplot.addDomainMarker(valuemarker2, Layer.BACKGROUND); return jfreechart; }
From source file:lu.lippmann.cdb.weka.SilhouetteUtil.java
/** * // w w w. j a v a 2 s. c om * @param sils * @return */ public static JPanel buildSilhouettePanel(final Instances ds, final WekaClusteringResult result) { final Map<Integer, List<Double>> sils = computeSilhouette(ds, result); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createBarChart("Silhouette", "Category", "Value", dataset, PlotOrientation.HORIZONTAL, true, true, false); int nbClass = sils.keySet().size(); int id = 0; double minValue = 0; int counter[][] = new int[nbClass][4]; for (int i = 0; i < nbClass; i++) { final double[] tree = ArrayUtils.toPrimitive(sils.get(i).toArray(new Double[0])); for (double val : tree) { if (val > 0.75) { dataset.addValue(val, "Cluster " + i + " ++", "" + id); counter[i][0]++; } else if (val > 0.50) { dataset.addValue(val, "Cluster " + i + " +", "" + id); counter[i][1]++; } else if (val > 0.25) { dataset.addValue(val, "Cluster " + i + " =", "" + id); counter[i][2]++; } else { dataset.addValue(val, "Cluster " + i + " -", "" + id); counter[i][3]++; } if (val < minValue) { minValue = val; } id++; } } final CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); categoryplot.setBackgroundPaint(Color.WHITE); categoryplot.getDomainAxis().setVisible(false); categoryplot.setDomainGridlinesVisible(false); categoryplot.setRangeGridlinesVisible(false); categoryplot.getRangeAxis().setRange(minValue, 1.0); //Add line markers ValueMarker target = new ValueMarker(0.75); target.setPaint(Color.BLACK); target.setLabel(" ++"); target.setLabelAnchor(RectangleAnchor.TOP_LEFT); target.setLabelTextAnchor(TextAnchor.TOP_LEFT); categoryplot.addRangeMarker(target); target = new ValueMarker(0.5); target.setPaint(Color.BLACK); target.setLabel(" +"); target.setLabelAnchor(RectangleAnchor.TOP_LEFT); target.setLabelTextAnchor(TextAnchor.TOP_LEFT); categoryplot.addRangeMarker(target); target = new ValueMarker(0.25); target.setPaint(Color.BLACK); target.setLabel(" ="); target.setLabelAnchor(RectangleAnchor.TOP_LEFT); target.setLabelTextAnchor(TextAnchor.TOP_LEFT); categoryplot.addRangeMarker(target); target = new ValueMarker(0); target.setPaint(Color.BLACK); target.setLabel(" -"); target.setLabelAnchor(RectangleAnchor.TOP_LEFT); target.setLabelTextAnchor(TextAnchor.TOP_LEFT); categoryplot.addRangeMarker(target); //Remove visual effects on bar final BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setBarPainter(new StandardBarPainter()); //set bar colors int p = 0; final int max = ColorHelper.COLORBREWER_SEQUENTIAL_PALETTES.size(); for (int i = 0; i < nbClass; i++) { final Color[] color = new ArrayList<Color[]>(ColorHelper.COLORBREWER_SEQUENTIAL_PALETTES.values()) .get((max - i) % max); final int nbColors = color.length; for (int k = 0; k < counter[i].length; k++) { if (counter[i][k] > 0) barrenderer.setSeriesPaint(p++, color[(nbColors - k - 3) % nbColors]); } } //remove blank line between bars barrenderer.setItemMargin(-dataset.getRowCount()); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(new Dimension(1200, 900)); chartPanel.setBorder(new TitledBorder("Silhouette plot")); chartPanel.setBackground(Color.WHITE); chart.setTitle(""); return chartPanel; }
From source file:ua.com.fielden.platform.example.swing.booking.BookingChartPanelExample.java
private static Marker createNowMarker(final Date now) { final ValueMarker valuemarker = new ValueMarker(now.getTime()); valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); valuemarker.setPaint(Color.BLACK); valuemarker.setLabel("Today"); valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); valuemarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); return valuemarker; }
From source file:spec.reporter.Utils.java
public static void createBmResultGraph(BenchmarkRecord record) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String iterName = ""; double max = 0; double min = Long.MAX_VALUE; for (int i = 0; i < record.iterRecords.size(); i++) { BenchmarkRecord.IterationRecord iterRecord = (BenchmarkRecord.IterationRecord) record.iterRecords .get(i);/* ww w. j av a 2 s. c o m*/ String shortName = iterRecord.iterName.replaceFirst("ation", ""); if (iterRecord.score > max) { max = iterRecord.score; iterName = shortName; } if (iterRecord.score < min) { min = iterRecord.score; } dataset.addValue(iterRecord.score, " ", shortName); } JFreeChart chart = ChartFactory.createLineChart(" ", "iterations", Constants.WORKLOAD_METRIC, dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(201, 222, 254)); plot.setRangeGridlinePaint(Color.WHITE); if (record.isValidRun() && min != Long.MAX_VALUE) { plot.getRangeAxis().setRange(min - 10, max + 10); } else { plot.getRangeAxis().setRange(0, max + 10); } ValueMarker vm = new ValueMarker(record.maxScore); vm.setLabel(Utils.df.format(record.maxScore)); vm.setLabelAnchor(RectangleAnchor.TOP_LEFT); vm.setLabelTextAnchor(TextAnchor.HALF_ASCENT_LEFT); plot.addRangeMarker(vm); CategoryMarker marker = new CategoryMarker(iterName); marker.setDrawAsLine(true); marker.setPaint(vm.getPaint()); plot.addDomainMarker(marker); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setFillPaint(Color.WHITE); renderer.setSeriesPaint(0, Color.BLUE.darker()); try { ChartUtilities.saveChartAsJPEG(new File(Utils.getFullImageName(record.name + "_results")), chart, 300, 200); } catch (Exception e) { System.out.println("Problems..."); } }
From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java
/** * Creates a chart displaying the radon concentration of a virtual campaign. * Uses red for normal rooms and blue for cellar rooms. * /*from w w w.j a v a 2 s . c o m*/ * @param campaign * The campaign object containing all rooms and radon data. * @param preview * Will hide annotations, labels and headlines if true. * @return A chart displaying the radon concentration of a virtual campaign. */ public static JFreeChart createCampaignChart(OMCampaign campaign, boolean preview) { OMRoom[] rooms = new OMRoom[7]; OMRoom[] tmpRooms = campaign.getRooms(); OMRoom tmpCellar = campaign.getCellar(); String variation = campaign.getVariation(); char[] variationChar = variation.toCharArray(); int cellarPosition = 0; for (int i = 0; i < variationChar.length; i++) { if (variationChar[i] == 'C' || variationChar[i] == 'c') { cellarPosition = i / 2; } } int c = 0; for (int i = 0; i < rooms.length; i++) { if (i == cellarPosition) { rooms[i] = tmpCellar; c++; } else { rooms[i] = tmpRooms[i - c]; } } int start = campaign.getStart(); final int finalStart = start; String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId() + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId() + ", Start: " + finalStart; int count = 168; double[] values = campaign.getValueChain(); XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries roomSeries1 = new XYSeries(" Radon Rooms"); XYSeries cellarSeries = new XYSeries("Radon Cellar"); XYSeries roomSeries2 = new XYSeries("Radon Rooms"); int cellarSeriesStart = cellarPosition * 24; int cellarSeriesEnd = cellarSeriesStart + 24; double cellarMaximum = campaign.getCellarMaximum(); double cellarMaximumKey = 0; double roomMaximum = campaign.getRoomMaximum(); double roomMaximumKey = 0; if (cellarSeriesStart > 0) { for (int i = 0; i < cellarSeriesStart; i++) { roomSeries1.add(finalStart + i, values[i]); if (values[i] == roomMaximum) { roomMaximumKey = i; } } } for (int i = cellarSeriesStart - 1; i < cellarSeriesEnd; i++) { if (i >= 0) { cellarSeries.add(finalStart + i, values[i]); if (values[i] == cellarMaximum) { cellarMaximumKey = i; } } } if (cellarSeriesEnd < count) { for (int i = cellarSeriesEnd - 1; i < count; i++) { roomSeries2.add(finalStart + i, values[i]); if (values[i] == roomMaximum) { roomMaximumKey = i; } } } dataSet.addSeries(roomSeries1); dataSet.addSeries(cellarSeries); dataSet.addSeries(roomSeries2); JFreeChart chart = ChartFactory.createXYLineChart(title, "T [h]", "Rn [Bq/m\u00B3]", dataSet, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); ValueMarker sepMarker; Color sepColor = Color.BLACK; float[] sepDash = { 1, 2 }; Stroke sepStroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, sepDash, 0); RectangleInsets sepLabelInsets = new RectangleInsets(20, -20, 0, 0); Font sepLabelFont = new Font(Font.SANS_SERIF, Font.BOLD, 16); sepMarker = new ValueMarker(finalStart + 0, sepColor, sepStroke); sepMarker.setLabel(rooms[0].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); if (rooms[0].getId() != rooms[1].getId()) { sepMarker = new ValueMarker(finalStart + 23, sepColor, sepStroke); sepMarker.setLabel(rooms[1].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[1].getId() != rooms[2].getId()) { sepMarker = new ValueMarker(finalStart + 47, sepColor, sepStroke); sepMarker.setLabel(rooms[2].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[2].getId() != rooms[3].getId()) { sepMarker = new ValueMarker(finalStart + 71, sepColor, sepStroke); sepMarker.setLabel(rooms[3].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[3].getId() != rooms[4].getId()) { sepMarker = new ValueMarker(finalStart + 95, sepColor, sepStroke); sepMarker.setLabel(rooms[4].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[4].getId() != rooms[5].getId()) { sepMarker = new ValueMarker(finalStart + 119, sepColor, sepStroke); sepMarker.setLabel(rooms[5].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[5].getId() != rooms[6].getId()) { sepMarker = new ValueMarker(finalStart + 143, sepColor, sepStroke); sepMarker.setLabel(rooms[6].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } double positiveCellarDeviation = campaign.getCellarAverage() + campaign.getCellarDeviation(); double negativeCellarDeviation = campaign.getCellarAverage() - campaign.getCellarDeviation(); IntervalMarker cellarDeviation = new IntervalMarker(negativeCellarDeviation, positiveCellarDeviation); float[] dash = { 5, 3 }; cellarDeviation.setPaint(new Color(222, 222, 255, 128)); cellarDeviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(cellarDeviation, Layer.BACKGROUND); ValueMarker arithCellarMarker = new ValueMarker(campaign.getCellarAverage(), new Color(0, 0, 255, 128), new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(arithCellarMarker); XYTextAnnotation amCellarLabel = new XYTextAnnotation("C_AM=" + (int) campaign.getCellarAverage(), finalStart + count, campaign.getCellarAverage() * 1.01); plot.addAnnotation(amCellarLabel); XYTextAnnotation sdCellarLabel = new XYTextAnnotation("C_SD=" + (int) campaign.getCellarDeviation(), finalStart + count, (campaign.getCellarAverage() + campaign.getCellarDeviation()) * 1.01); plot.addAnnotation(sdCellarLabel); ValueMarker maxiCellarMarker = new ValueMarker(cellarMaximum, new Color(0, 0, 255, 128), new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(maxiCellarMarker); XYTextAnnotation maxCellarLabel = new XYTextAnnotation("C_MAX=" + (int) cellarMaximum, finalStart + count, cellarMaximum * 1.01); plot.addAnnotation(maxCellarLabel); XYPointerAnnotation maxCellarPointer = new XYPointerAnnotation("", finalStart + cellarMaximumKey, cellarMaximum, Math.PI * 1.1); plot.addAnnotation(maxCellarPointer); double positiveRoomDeviation = campaign.getRoomAverage() + campaign.getRoomDeviation(); double negativeRoomDeviation = campaign.getRoomAverage() - campaign.getRoomDeviation(); IntervalMarker roomDeviation = new IntervalMarker(negativeRoomDeviation, positiveRoomDeviation); roomDeviation.setPaint(new Color(255, 222, 222, 128)); roomDeviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(roomDeviation, Layer.BACKGROUND); ValueMarker arithRoomMarker = new ValueMarker(campaign.getRoomAverage(), new Color(255, 0, 0, 128), new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(arithRoomMarker); XYTextAnnotation amRoomLabel = new XYTextAnnotation("R_AM=" + (int) campaign.getRoomAverage(), finalStart + count, campaign.getRoomAverage() * 1.01); plot.addAnnotation(amRoomLabel); XYTextAnnotation sdRoomLabel = new XYTextAnnotation("R_SD=" + (int) campaign.getRoomDeviation(), finalStart + count, (campaign.getRoomAverage() + campaign.getRoomDeviation()) * 1.01); plot.addAnnotation(sdRoomLabel); ValueMarker maxiRoomMarker = new ValueMarker(roomMaximum, new Color(255, 0, 0, 128), new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(maxiRoomMarker); XYTextAnnotation maxRoomLabel = new XYTextAnnotation("R_MAX=" + (int) roomMaximum, finalStart + count, roomMaximum * 1.01); plot.addAnnotation(maxRoomLabel); XYPointerAnnotation maxRoomPointer = new XYPointerAnnotation("", finalStart + roomMaximumKey, roomMaximum, Math.PI * 1.1); plot.addAnnotation(maxRoomPointer); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, new Color(255, 0, 0, 128)); renderer.setSeriesPaint(1, new Color(0, 0, 255, 128)); renderer.setSeriesPaint(2, new Color(255, 0, 0, 128)); if (preview) { chart.setTitle(""); plot.clearAnnotations(); } return chart; }
From source file:Business.Chart.ChartBP.java
public ChartBP(final String applicationTitle, String chartTitle, HospitalWorkRequest workRequest) { super(applicationTitle); series6 = new TimeSeries("Blood Pressure"); this.chartTitle = chartTitle; this.workRequest = workRequest; final XYDataset dataset1 = createDatasetBP(workRequest); final JFreeChart chart1 = createChart1(dataset1); final XYPlot plot = chart1.getXYPlot(); HospitalWorkRequest hos1 = (HospitalWorkRequest) workRequest; int age = hos1.getPerson().getAge(); int a = hos1.getPerson().getAboveBPMarker(age); int b = hos1.getPerson().getBelowBPMarker(age); ValueMarker valueMarker = new ValueMarker(a); valueMarker.setLabel("ALERT"); valueMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker.setPaint(Color.blue); ValueMarker valueMarker1 = new ValueMarker(b); valueMarker1.setLabel("ALERT"); valueMarker1.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker1.setPaint(Color.BLUE); plot.addRangeMarker(valueMarker);/*from w w w . j a v a 2s.c o m*/ plot.addRangeMarker(valueMarker1); }
From source file:Business.Chart.Temperature.java
public Temperature(final String applicationTitle, String chartTitle, HospitalWorkRequest workRequest) { super(applicationTitle); series3 = new TimeSeries("Temperature"); this.workRequest = workRequest; this.chartTitle = chartTitle; final XYDataset dataset3 = createDatasetTemperature(workRequest); final JFreeChart chart3 = createChart(dataset3); final XYPlot plot = chart3.getXYPlot(); HospitalWorkRequest hos1 = (HospitalWorkRequest) workRequest; int age = hos1.getPerson().getAge(); int a = hos1.getPerson().getAboveTemperatureRateMarker(age); int b = hos1.getPerson().getBelowTemperatureRateMarker(age); ValueMarker valueMarker = new ValueMarker(a); valueMarker.setLabel("ALERT"); valueMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker.setPaint(Color.blue); ValueMarker valueMarker1 = new ValueMarker(b); valueMarker1.setLabel("ALERT"); valueMarker1.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker1.setPaint(Color.BLUE); plot.addRangeMarker(valueMarker);//www . j a va 2 s. c om plot.addRangeMarker(valueMarker1); final ChartPanel chartPanel = new ChartPanel(chart3); chartPanel.setPreferredSize(new java.awt.Dimension(560, 370)); chartPanel.setMouseZoomable(true, false); setContentPane(chartPanel); getContentPane().repaint(); }