Search in sources :

Example 1 with PlotOptionsHeatmap

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

the class PlotOptionsJSONSerializationTest method toString_heatMapTurboThresholdIsSet_plotOptionsSerializedWithTurboThreshold.

@Test
public void toString_heatMapTurboThresholdIsSet_plotOptionsSerializedWithTurboThreshold() {
    PlotOptionsHeatmap plotOptions = new PlotOptionsHeatmap();
    plotOptions.setTurboThreshold(0);
    String json = toJSON(plotOptions);
    String expected = "{\"turboThreshold\":0}";
    assertEquals(expected, json);
}
Also used : PlotOptionsHeatmap(com.vaadin.addon.charts.model.PlotOptionsHeatmap) Test(org.junit.Test)

Example 2 with PlotOptionsHeatmap

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

the class ChartTypes method chartTypesHeatMap.

public void chartTypesHeatMap() {
    Chart chart = new Chart(ChartType.HEATMAP);
    chart.setWidth("600px");
    chart.setHeight("300px");
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Heat Data");
    // Set colors for the extremes
    conf.getColorAxis().setMinColor(SolidColor.AQUA);
    conf.getColorAxis().setMaxColor(SolidColor.RED);
    // Set up border and data labels
    PlotOptionsHeatmap plotOptions = new PlotOptionsHeatmap();
    plotOptions.setBorderColor(SolidColor.WHITE);
    plotOptions.setBorderWidth(2);
    plotOptions.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(plotOptions);
    // Create some data
    HeatSeries series = new HeatSeries();
    // Jan High
    series.addHeatPoint(0, 0, 10.9);
    // Jan Low
    series.addHeatPoint(0, 1, -51.5);
    // Feb High
    series.addHeatPoint(1, 0, 11.8);
    // Dec Low
    series.addHeatPoint(11, 1, -47.0);
    conf.addSeries(series);
    // Set the category labels on the X axis
    XAxis xaxis = new XAxis();
    xaxis.setTitle("Month");
    xaxis.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    conf.addxAxis(xaxis);
    // Set the category labels on the Y axis
    YAxis yaxis = new YAxis();
    yaxis.setTitle("");
    yaxis.setCategories("High C", "Low C");
    conf.addyAxis(yaxis);
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) HeatSeries(com.vaadin.addon.charts.model.HeatSeries) PlotOptionsHeatmap(com.vaadin.addon.charts.model.PlotOptionsHeatmap) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 3 with PlotOptionsHeatmap

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

the class HeatMapExample method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    Configuration config = chart.getConfiguration();
    config.getChart().setType(ChartType.HEATMAP);
    config.getChart().setMarginTop(40);
    config.getChart().setMarginBottom(40);
    config.getTitle().setText("Sales per employee per weekday");
    config.getxAxis().setCategories("Marta", "Mysia", "Misiek", "Maniek", "Miki", "Guillermo", "Jonatan", "Zdzisław", "Antoni", "Zygmunt");
    config.getyAxis().setCategories("Monday", "Tuesday", "Wednesday", "Thursday", "Friday");
    config.getColorAxis().setMin(0);
    config.getColorAxis().setMinColor(SolidColor.WHITE);
    config.getColorAxis().setMaxColor(getThemeColors()[0]);
    config.getLegend().setLayout(LayoutDirection.VERTICAL);
    config.getLegend().setAlign(HorizontalAlign.RIGHT);
    config.getLegend().setMargin(0);
    config.getLegend().setVerticalAlign(VerticalAlign.TOP);
    config.getLegend().setY(25);
    config.getLegend().setSymbolHeight(320);
    HeatSeries rs = new HeatSeries("Sales per employee", getRawData());
    PlotOptionsHeatmap plotOptionsHeatmap = new PlotOptionsHeatmap();
    plotOptionsHeatmap.setDataLabels(new DataLabels());
    plotOptionsHeatmap.getDataLabels().setEnabled(true);
    SeriesTooltip tooltip = new SeriesTooltip();
    tooltip.setHeaderFormat("{series.name}<br/>");
    tooltip.setPointFormat("Amount: <b>{point.value}</b> ");
    plotOptionsHeatmap.setTooltip(tooltip);
    config.setPlotOptions(plotOptionsHeatmap);
    config.setSeries(rs);
    chart.drawChart(config);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) HeatSeries(com.vaadin.addon.charts.model.HeatSeries) PlotOptionsHeatmap(com.vaadin.addon.charts.model.PlotOptionsHeatmap) Chart(com.vaadin.addon.charts.Chart) SeriesTooltip(com.vaadin.addon.charts.model.SeriesTooltip)

Aggregations

PlotOptionsHeatmap (com.vaadin.addon.charts.model.PlotOptionsHeatmap)3 Chart (com.vaadin.addon.charts.Chart)2 Configuration (com.vaadin.addon.charts.model.Configuration)2 DataLabels (com.vaadin.addon.charts.model.DataLabels)2 HeatSeries (com.vaadin.addon.charts.model.HeatSeries)2 SeriesTooltip (com.vaadin.addon.charts.model.SeriesTooltip)1 XAxis (com.vaadin.addon.charts.model.XAxis)1 YAxis (com.vaadin.addon.charts.model.YAxis)1 Test (org.junit.Test)1