The value of a data point can be displayed next to the data point location, using the method
GraphSerie.setMarkLegendEnabled(boolean isMarkLegendEnabled). The value is displayed
inside a small window, which can be dismissed passing 'false' to the method
GraphSerie.setMarkLegendOpacityEnabled(boolean isMarkLegendOpacityEnabled).
This feature is only available to applications developed with the Graph class, using
subclasses of GraphSerie.
The following example shows a line series and a bar series, enabling data points legends and
making the line series legends transparent.
import javax.swing.*; import java.awt.*; import com.jinsight.jetchart.*; public class Main extends JFrame { public Main() { Graph graph=new Graph(); String[] labels={"label1","label2","label3","label4"}; graph.setLabels(labels); GraphSet graphSet=graph.getGraphSet(0); Grid grid=graphSet.getGrid(); grid.setEnabled(true); grid.setColor(Color.gray); String[] title={"The JetChart Library","Displaying data points legends"}; graph.setTitle(title); Container ct=getContentPane(); ct.add("Center",graph); LineSerie ls=new LineSerie(); ls.setTitle("Line series 1"); ls.setColor(Color.red); double[] values1={100,130,90,110}; ls.setValues(values1); ls.setMarkLegendEnabled(true); ls.setMarkLegendOpacityEnabled(false); BarSerie bs=new BarSerie(); bs.setTitle("Line series 2"); bs.setColor(Color.blue); double[] values2={50,70,55,70}; bs.setValues(values2); bs.setMarkLegendEnabled(true); graph.addSerie(ls); graph.addSerie(bs); setSize(400,300); setVisible(true); } public static void main(String[] args) { new Main(); } }