Search in sources :

Example 1 with DataLabelsFunnel

use of com.vaadin.addon.charts.model.DataLabelsFunnel in project charts by vaadin.

the class FunnelChartExample method getChart.

@Override
protected Component getChart() {
    DataSeries dataSeries = new DataSeries("Unique users");
    dataSeries.add(new DataSeriesItem("Website visits", 15654));
    dataSeries.add(new DataSeriesItem("Downloads", 4064));
    dataSeries.add(new DataSeriesItem("Requested price list", 1987));
    dataSeries.add(new DataSeriesItem("Invoice sent", 976));
    dataSeries.add(new DataSeriesItem("Finalized", 846));
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Sales funnel");
    conf.getLegend().setEnabled(false);
    PlotOptionsFunnel options = new PlotOptionsFunnel();
    options.setReversed(false);
    options.setNeckWidth("30%");
    options.setNeckHeight("30%");
    options.setWidth("70%");
    DataLabelsFunnel dataLabels = new DataLabelsFunnel();
    dataLabels.setFormat("<b>{point.name}</b> ({point.y:,.0f})");
    options.setDataLabels(dataLabels);
    dataSeries.setPlotOptions(options);
    conf.addSeries(dataSeries);
    return chart;
}
Also used : DataLabelsFunnel(com.vaadin.addon.charts.model.DataLabelsFunnel) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsFunnel(com.vaadin.addon.charts.model.PlotOptionsFunnel) DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) Chart(com.vaadin.addon.charts.Chart)

Example 2 with DataLabelsFunnel

use of com.vaadin.addon.charts.model.DataLabelsFunnel in project charts by vaadin.

the class PyramidChartExample method getChart.

@Override
protected Component getChart() {
    DataSeries dataSeries = new DataSeries("Unique users");
    dataSeries.add(new DataSeriesItem("Website visits", 15654));
    dataSeries.add(new DataSeriesItem("Downloads", 4064));
    dataSeries.add(new DataSeriesItem("Requested price list", 1987));
    dataSeries.add(new DataSeriesItem("Invoice sent", 976));
    dataSeries.add(new DataSeriesItem("Finalized", 846));
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Sales pyramid");
    conf.getLegend().setEnabled(false);
    PlotOptionsPyramid options = new PlotOptionsPyramid();
    // With default (90%), long labels in this example may be cut
    options.setWidth(70, Unit.PERCENTAGE);
    // in pixels
    // options.setWidth(400);
    DataLabelsFunnel dataLabels = new DataLabelsFunnel();
    dataLabels.setFormat("<b>{point.name}</b> ({point.y:,.0f})");
    options.setDataLabels(dataLabels);
    dataSeries.setPlotOptions(options);
    conf.addSeries(dataSeries);
    return chart;
}
Also used : DataLabelsFunnel(com.vaadin.addon.charts.model.DataLabelsFunnel) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsPyramid(com.vaadin.addon.charts.model.PlotOptionsPyramid) DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) Chart(com.vaadin.addon.charts.Chart)

Example 3 with DataLabelsFunnel

use of com.vaadin.addon.charts.model.DataLabelsFunnel in project charts by vaadin.

the class ChartTypes method chartTypesFunnel.

public void chartTypesFunnel() {
    Chart chart = new Chart(ChartType.FUNNEL);
    chart.setWidth("500px");
    chart.setHeight("350px");
    // Modify the default configuration a bit
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Monster Utilization");
    conf.getLegend().setEnabled(false);
    // Give more room for the labels
    conf.getChart().setSpacingRight(120);
    // Configure the funnel neck shape
    PlotOptionsFunnel options = new PlotOptionsFunnel();
    options.setNeckHeight(20, Sizeable.Unit.PERCENTAGE);
    options.setNeckWidth(20, Sizeable.Unit.PERCENTAGE);
    // Style the data labels
    DataLabelsFunnel dataLabels = new DataLabelsFunnel();
    dataLabels.setFormat("<b>{point.name}</b> ({point.y:,.0f})");
    dataLabels.setSoftConnector(false);
    dataLabels.setColor(SolidColor.BLACK);
    options.setDataLabels(dataLabels);
    conf.setPlotOptions(options);
    // Create the range series
    DataSeries series = new DataSeries();
    series.add(new DataSeriesItem("Monsters Met", 340));
    series.add(new DataSeriesItem("Engaged", 235));
    series.add(new DataSeriesItem("Killed", 187));
    series.add(new DataSeriesItem("Tinned", 70));
    series.add(new DataSeriesItem("Eaten", 55));
    conf.addSeries(series);
}
Also used : DataLabelsFunnel(com.vaadin.addon.charts.model.DataLabelsFunnel) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsFunnel(com.vaadin.addon.charts.model.PlotOptionsFunnel) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Aggregations

Chart (com.vaadin.addon.charts.Chart)3 Configuration (com.vaadin.addon.charts.model.Configuration)3 DataLabelsFunnel (com.vaadin.addon.charts.model.DataLabelsFunnel)3 DataSeries (com.vaadin.addon.charts.model.DataSeries)3 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)3 PlotOptionsFunnel (com.vaadin.addon.charts.model.PlotOptionsFunnel)2 PlotOptionsPyramid (com.vaadin.addon.charts.model.PlotOptionsPyramid)1