Docs

Documentation versions (currently viewingVaadin 25)
Documentation translations (currently viewing)

Questa pagina è stata tradotta automaticamente dalla documentazione ufficiale, che si trova in https://vaadin.com/docs. Potrebbe contenere errori, inesattezze, o affermazioni errate. Vaadin non garantisce né rilascia alcuna dichiarazione in merito all’accuratezza, affidabilità, o tempestività della traduzione.

Grafici X-Range

Grafici che visualizzano un intervallo sull’asse X.

I grafici X-Range sono utilizzati per visualizzare un intervallo sull’asse X. Richiedono l’uso di DataSeriesItemXrange per impostare un valore X iniziale e un valore X2 finale. Inoltre, è possibile impostare partialFillAmount per mostrare la percentuale del punto da riempire.

Un grafico X-Range pronto è mostrato in Grafico X-Range.

charts xrange
Grafico X-Range

Il tipo di grafico di un grafico X-Range è ChartType.XRANGE. Le sue opzioni possono essere configurate in un oggetto PlotOptionsXrange.

Source code
Java
// Create a xrange chart
Chart chart = new Chart(ChartType.XRANGE);

// Modify the default configuration
Configuration conf = chart.getConfiguration();
conf.setTitle("X-range");

// Add data
DataSeries series = new DataSeries();
series.setName("Project 1");
series.add(new DataSeriesItemXrange(getInstant(2014, 11, 21),
        getInstant(2014, 12, 2), 0, 0.25));
series.add(new DataSeriesItemXrange(getInstant(2014, 12, 2),
        getInstant(2014, 12, 5), 1));
series.add(new DataSeriesItemXrange(getInstant(2014, 12, 8),
        getInstant(2014, 12, 9), 2));
series.add(new DataSeriesItemXrange(getInstant(2014, 12, 9),
        getInstant(2014, 12, 19), 1));
series.add(new DataSeriesItemXrange(getInstant(2014, 12, 10),
        getInstant(2014, 12, 23), 2));
PlotOptionsXrange options = new PlotOptionsXrange();
options.setBorderColor(SolidColor.GRAY);
options.setPointWidth(20);
options.getDataLabels().setEnabled(true);
series.setPlotOptions(options);
conf.addSeries(series);

// Configure the axes
conf.getxAxis().setType(AxisType.DATETIME);
conf.getyAxis().setTitle("");
conf.getyAxis().setCategories("Prototyping", "Development", "Testing");
conf.getyAxis().setReversed(true);
Source code
Java
// Helper method to create an Instant from year, month and day
private Instant getInstant(int year, int month, int dayOfMonth) {
    return LocalDate.of(year, month, dayOfMonth).atStartOfDay().toInstant(ZoneOffset.UTC);
}

Esempio X-Range

Source code
ChartTypeXrange.java