« Plots » : différence entre les versions
Aller à la navigation
Aller à la recherche
Aucun résumé des modifications |
Aucun résumé des modifications |
||
Ligne 17 : | Ligne 17 : | ||
double[] yVal = { 0., 2., 4., 9., 16.}; | double[] yVal = { 0., 2., 4., 9., 16.}; | ||
plot.addSerie("nameOfTheSeries", xVal, yVal, null, Color.RED, null); | |||
plot.addSerie("nameOfTheSeries", xVal, yVal, null, Color.RED, null | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Version du 6 novembre 2017 à 09:11
The way to plot inside a GPanel is very simple. These plots will be done thanks to JFreeChart product via the GFreeChartXY class.
First, we have just to instantiate a GFreeChartXY object like this:
boolean addLegendFlag = true;
GFreeChartXY plot = new GFreeChartXY("Main Title",
"XAxis Title",
"YAxis Title", "Sec YAxis Title",
addLegendFlag);
Then, considering xVal and yVal, the both tables including the data to be plotted, we will add them to the plot object :
double[] xVal = { 0., 1., 2., 3., 4.};
double[] yVal = { 0., 2., 4., 9., 16.};
plot.addSerie("nameOfTheSeries", xVal, yVal, null, Color.RED, null);
At last, to display it in the current GPanel], we will use the put() method.
As we use JFreeChart, it is then possible to use all the functionnalities proposed by this product, specially by using the context menu obtained by clicking ont the right button of the mouse.