Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin Charts Data Types

Luca Magnotta
5 years ago Jul 21, 2016 4:29pm
Guillermo Alvarez
5 years ago Jul 22, 2016 6:47am
Guillermo Alvarez
5 years ago Jul 22, 2016 6:55am

The second option would look like this:

public class DataSeriesItemWithExtraProperty extends DataSeriesItem {

    private String myData;

    public DataSeriesItemWithExtraProperty(Number x, Number y, String myData) {
        super(x, y);
        this.myData = myData;
        makeCustomized();
    }

    public String getMyData() {
        return myData;
    }

    public void setMyData(String myData) {
        this.myData = myData;
    }
}

And the chart would be like:

Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
conf.getTooltip().setFormatter(
        "'Extra data: <b>' + this.point.myData + '</b>'");

DataSeries series = new DataSeries();
series.add(new DataSeriesItemWithExtraProperty(1, 3, "firstPoint"));
series.add(new DataSeriesItemWithExtraProperty(2, 7, "secondPoint"));
series.add(new DataSeriesItemWithExtraProperty(3, 1, "thirdPoint"));
conf.setSeries(series);

Regards,

Guille

Luca Magnotta
5 years ago Jul 22, 2016 4:41pm