1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| public static void displayInGraph(HashMap<String, ArrayList<String>> tagPrefixs, HashMap<String, ArrayList<String>> tagSuffixs, Date startDate, Date endDate)
{
List<NamedPropertyReference> references = getReferences(tagPrefixs,tagSuffixs);
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
//Recupère les historiques
for (int i=0; i<references.size(); i++)
{
HistoryEntry[] entries = xxx.getPropertyValues(references.get(i), startDate, endDate);
for (int j=0; j<entries.length; j++)
{
dataset.addValue(entries[j].value,references.get(i).getName(), new Date(entries[j].timestamp).toString());
System.out.println(entries[j].value+ references.get(i).getName()+ new Date(entries[j].timestamp).toString());
}
}
// Création du graphique
JFreeChart barChart = ChartFactory.createBarChart3D(
"Nombre d'ouverture manuelle",
"Temps en minutes",
"Valeur",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false);
// Affichage du graphique
ChartFrame frame1 = new ChartFrame("Statistiques", barChart);
frame1.setVisible(true);
frame1.setSize(600,600);
// Modification des labels des axes (taille, police)
CategoryPlot plot = barChart.getCategoryPlot();
NumberAxis axe1 = (NumberAxis) plot.getRangeAxis();
axe1.setTickLabelFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 12));
axe1.setLabelFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 12));
Axis axe2 = plot.getDomainAxis();
axe2.setTickLabelFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 8));
axe2.setLabelFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 8));
// Labels des abcisses à la verticale
CategoryAxis axis = plot.getDomainAxis();
axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
} |
Partager