Search in sources :

Example 41 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class ContainerWithLotsOfData method createChart.

public static Chart createChart(Series container) {
    final Chart chart = new Chart();
    final Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.AREA);
    configuration.getTitle().setText("Data from Vaadin Container");
    configuration.getLegend().setEnabled(false);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Exchange rate"));
    yAxis.setMin(0.6);
    yAxis.setStartOnTick(false);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setShared(true);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor("#4572A7"));
    fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
    plotOptions.setFillColor(fillColor);
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Marker marker = plotOptions.getMarker();
    marker.setEnabled(false);
    Hover hoverState = new Hover(true);
    hoverState.setRadius(5);
    hoverState.setLineWidth(1);
    marker.getStates().setHover(hoverState);
    plotOptions.getStates().setHover(new Hover(true));
    plotOptions.setShadow(false);
    configuration.setPlotOptions(plotOptions);
    configuration.setSeries(container);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Hover(com.vaadin.addon.charts.model.Hover) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Marker(com.vaadin.addon.charts.model.Marker) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 42 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class ColumnWithShapedLabels method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Stacked column chart"));
    XAxis xAxis = new XAxis();
    xAxis.setCategories(new String[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" });
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setMin(0);
    yAxis.setTitle(new AxisTitle("Total fruit consumption"));
    conf.addyAxis(yAxis);
    PlotOptionsColumn plotOptions = new PlotOptionsColumn();
    plotOptions.setStacking(Stacking.NORMAL);
    DataLabels labels = new DataLabels(true);
    labels.setBackgroundColor(SolidColor.BURLYWOOD);
    labels.setColor(new SolidColor("white"));
    labels.setShape(Shape.DIAMOND);
    Style style = new Style();
    style.setTextShadow("0 0 3px black");
    labels.setStyle(style);
    plotOptions.setDataLabels(labels);
    conf.setPlotOptions(plotOptions);
    conf.addSeries(new ListSeries("John", new Number[] { 5, 3, 4, 7, 2 }));
    conf.addSeries(new ListSeries("Jane", new Number[] { 2, 2, 3, 2, 1 }));
    conf.addSeries(new ListSeries("Joe", new Number[] { 3, 4, 4, 2, 5 }));
    chart.drawChart(conf);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.addon.charts.model.ListSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Title(com.vaadin.addon.charts.model.Title) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Style(com.vaadin.addon.charts.model.style.Style) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 43 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class DualAxesLineAndColumn method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.getChart().setZoomType(ZoomType.XY);
    conf.setTitle("Average Monthly Temperature and Rainfall in Tokyo");
    conf.setSubTitle("Source: WorldClimate.com");
    XAxis x = new XAxis();
    x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    conf.addxAxis(x);
    YAxis primary = new YAxis();
    primary.setTitle("Temperature");
    Style style = new Style();
    style.setColor(getThemeColors()[1]);
    primary.getTitle().setStyle(style);
    conf.addyAxis(primary);
    YAxis snd = new YAxis();
    snd.setTitle("Rainfall");
    snd.setOpposite(true);
    style = new Style();
    style.setColor(new SolidColor("#4572A7"));
    snd.getTitle().setStyle(style);
    conf.addyAxis(snd);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.x +': '+ this.y + (this.series.name == 'Rainfall' ? ' mm' : '°C')");
    conf.setTooltip(tooltip);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.LEFT);
    legend.setX(120);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setY(100);
    legend.setFloating(true);
    conf.setLegend(legend);
    DataSeries series = new DataSeries();
    series.setPlotOptions(new PlotOptionsColumn());
    series.setName("Rainfall");
    series.setData(49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
    series.setyAxis(1);
    conf.addSeries(series);
    series = new DataSeries();
    PlotOptionsSpline plotOptions = new PlotOptionsSpline();
    series.setPlotOptions(plotOptions);
    series.setName("Temperature");
    series.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
    plotOptions.setColor(getThemeColors()[1]);
    conf.addSeries(series);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) Tooltip(com.vaadin.addon.charts.model.Tooltip) Style(com.vaadin.addon.charts.model.style.Style) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 44 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class StackedBar method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.BAR);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Stacked bar chart");
    XAxis x = new XAxis();
    x.setCategories("Apples", "Oranges", "Pears", "Grapes", "Bananas");
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    y.setTitle("Total fruit consumption");
    conf.addyAxis(y);
    Legend legend = new Legend();
    legend.setBackgroundColor(new SolidColor("#FFFFFF"));
    legend.setReversed(true);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.series.name +': '+ this.y");
    conf.setTooltip(tooltip);
    PlotOptionsSeries plot = new PlotOptionsSeries();
    plot.setStacking(Stacking.NORMAL);
    conf.setPlotOptions(plot);
    conf.addSeries(new ListSeries("John", 5, 3, 4, 7, 2));
    conf.addSeries(new ListSeries("Jane", 2, 2, 3, 2, 1));
    conf.addSeries(new ListSeries("Joe", 3, 4, 4, 2, 5));
    chart.drawChart(conf);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 45 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.

the class ChartWithExternalDataProviderWithChangingData method createChart.

public static Chart createChart(Series ds) {
    final Chart chart = new Chart(ChartType.AREA);
    final Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Data from Vaadin DataProvider");
    configuration.getLegend().setEnabled(false);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Data values"));
    yAxis.setMin(0.6);
    yAxis.setStartOnTick(false);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setShared(true);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor("#4572A7"));
    fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
    plotOptions.setFillColor(fillColor);
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Marker marker = plotOptions.getMarker();
    marker.setEnabled(false);
    Hover hoverState = new Hover(true);
    hoverState.setRadius(5);
    hoverState.setLineWidth(1);
    marker.getStates().setHover(hoverState);
    plotOptions.getStates().setHover(new Hover(true));
    plotOptions.setShadow(false);
    configuration.setPlotOptions(plotOptions);
    configuration.setSeries(ds);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Hover(com.vaadin.addon.charts.model.Hover) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Marker(com.vaadin.addon.charts.model.Marker) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

SolidColor (com.vaadin.addon.charts.model.style.SolidColor)82 Configuration (com.vaadin.addon.charts.model.Configuration)55 Chart (com.vaadin.addon.charts.Chart)54 YAxis (com.vaadin.addon.charts.model.YAxis)40 DataSeries (com.vaadin.addon.charts.model.DataSeries)27 ListSeries (com.vaadin.addon.charts.model.ListSeries)26 XAxis (com.vaadin.addon.charts.model.XAxis)26 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)25 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)19 DataLabels (com.vaadin.addon.charts.model.DataLabels)18 Legend (com.vaadin.addon.charts.model.Legend)17 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)15 Marker (com.vaadin.addon.charts.model.Marker)14 Tooltip (com.vaadin.addon.charts.model.Tooltip)14 Style (com.vaadin.addon.charts.model.style.Style)14 Labels (com.vaadin.addon.charts.model.Labels)12 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)11 Random (java.util.Random)10 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)9 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)8