ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 01.01.2026

Просмотров: 2611

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

Vaadin Charts

explicitly inverted with getChart().setInverted() in the chart configuration. An axis has a caption and tick marks at intervals indicating either numeric values or symbolic categories. Some chart types, such as gauge, have only Y-axis, which is circular in the gauge, and some such as a pie chart have none.

Axis objects are created and added to the configuration object with addxAxis() and addyAxis().

XAxis xaxis = new XAxis(); xaxis.setTitle("Axis title"); conf.addxAxis(xaxis);

A chart can have more than one Y-axis, usually when different series displayed in a graph have different units or scales. The association of a data series with an axis is done in the data series object with setyAxis().

For a complete reference of the many configuration parameters for the axes, please refer to the JavaDoc API documentation of Vaadin Charts.

Categories

The X axis displays, in most chart types, tick marks and labels at some numeric interval by default. If the items in a data series have a symbolic meaning rather than numeric, you can associate categories with the data items. The category label is displayed between two axis tick marks and aligned with the data point. In certain charts, such as column chart, where the corresponding values in different data series are grouped under the same category. You can set the category labels with setCategories(), which takes the categories as (an ellipsis) parameter list, or as an iterable. The list should match the items in the data series.

XAxis xaxis = new XAxis(); xaxis.setCategories("Mercury", "Venus", "Earth",

"Mars", "Jupiter", "Saturn", "Uranus", "Neptune");

Labels

The axes display, in most chart types, tick marks and labels at some numeric interval by default. The format and style of labels in an axis is defined in a Labels object, which you can get with getLabels() from the axis.

For a complete reference of the many configuration parameters for the labels, please refer to the JavaDoc API documentation of Vaadin Charts.

Axis Range

The axis range is normally set automatically to fit the data, but can also be set explicitly. The extremes property in the axis configuration defines the minimum and maximum values of the axis range.You can set them either individually with setMin() and setMax(), or together with setExtremes(). Changing the extremes programmatically requires redrawing the chart with drawChart().

19.5.3. Legend

The legend is a box that describes the data series shown in the chart. It is enabled by default and is automatically populated with the names of the data series as defined in the series objects, and the corresponding color symbol of the series.

428

Legend



Vaadin Charts

19.6. Chart Data

Chart data is stored in data series model, which contains visual representation information about the data points in addition to their values. There are a number of different types of series -

DataSeries, ListSeries, AreaListSeries, and RangeSeries.

19.6.1. List Series

The ListSeries is essentially a helper type that makes the handling of simple sequential data easier than with DataSeries. The data points are assumed to be at a constant interval on the X axis, starting from the value specified with the pointStart property (default is 0) at intervals specified with the pointInterval property (default is 1.0). The two properties are defined in the PlotOptions for the series.

The Y axis values are given in a List<Number>, or with ellipsis or an array.

ListSeries series = new ListSeries( "Total Reindeer Population", 181091, 201485, 188105, ...);

series.getPlotOptions().setPointStart(1959); conf.addSeries(series);

You can also add them one by one with the addData() method, which is typical when converting from some other representation.

// Original representation

int data[][] = reindeerData();

//Create a list series with X values starting from 1959 ListSeries series = new ListSeries("Reindeer Population"); series.getPlotOptions().setPointStart(1959);

//Add the data points

for (int row[]: data) series.addData(data[1]);

conf.addSeries(series);

If the chart has multiple Y axes, you can specify the axis for the series by its index number with setyAxis().

19.6.2. Generic Data Series

The DataSeries can represent a sequence of data points at an interval as well as scatter data. Data points are represented with the DataSeriesItem class, which has x and y properties for representing the data value. Each item can be given a category name.

DataSeries series = new DataSeries(); series.setName("Total Reindeer Population"); series.add(new DataSeriesItem(1959, 181091)); series.add(new DataSeriesItem(1960, 201485)); series.add(new DataSeriesItem(1961, 188105)); series.add(new DataSeriesItem(1962, 177206));

// Modify the color of one point series.get(1960, 201485)

.getMarker().setFillColor(SolidColor.RED); conf.addSeries(series);

Chart Data

429