Search in sources :

Example 6 with Pane

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

the class ChartTypes method chartTypesSolidGaugeConfSnippet2.

public void chartTypesSolidGaugeConfSnippet2() {
    Chart chart = new Chart(ChartType.SOLIDGAUGE);
    Configuration conf = chart.getConfiguration();
    Pane pane = conf.getPane();
    Background bkg = new Background();
    // Gray
    bkg.setBackgroundColor(new SolidColor("#eeeeee"));
    // To make it an arc and not circle
    bkg.setInnerRadius("60%");
    // Default - not necessary
    bkg.setOuterRadius("100%");
    // solid or arc
    bkg.setShape("arc");
    pane.setBackground(bkg);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Background(com.vaadin.addon.charts.model.Background) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Pane(com.vaadin.addon.charts.model.Pane) Chart(com.vaadin.addon.charts.Chart)

Example 7 with Pane

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

the class VUMeter method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart();
    chart.setWidth("600px");
    chart.setHeight("200px");
    GradientColor gradient = GradientColor.createLinear(0, 0, 0, 1);
    gradient.addColorStop(0, new SolidColor("#FFF4C6"));
    gradient.addColorStop(0.3, new SolidColor("#FFFFFF"));
    gradient.addColorStop(1, new SolidColor("#FFF4C6"));
    final Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.GAUGE);
    configuration.getChart().setPlotBackgroundColor(gradient);
    configuration.getChart().setPlotBackgroundImage(null);
    configuration.getChart().setPlotBorderWidth(1);
    configuration.setTitle("VU meter");
    Pane pane1 = new Pane(-45, 45);
    Pane pane2 = new Pane(-45, 45);
    pane1.setBackground(new Background[] {});
    pane2.setBackground(new Background[] {});
    pane1.setCenter("25%", "145%");
    pane2.setCenter("75%", "145%");
    pane1.setSize("300px");
    pane2.setSize("300");
    configuration.addPane(pane1);
    configuration.addPane(pane2);
    PlotBand plotBand1 = new PlotBand(0, 6, new SolidColor("#C02316"));
    plotBand1.setInnerRadius("100%");
    plotBand1.setOuterRadius("105%");
    PlotBand plotBand2 = new PlotBand(0, 6, new SolidColor("#C02316"));
    plotBand2.setInnerRadius("100%");
    plotBand2.setOuterRadius("105%");
    YAxis yAxis = new YAxis();
    yAxis.setPane(pane1);
    yAxis.setTitle("VU<br/><span style=\"font-size:8px\">Channel A</span>");
    yAxis.getTitle().setY(-40);
    yAxis.setMin(-20);
    yAxis.setMax(6);
    yAxis.setTickPosition(TickPosition.OUTSIDE);
    yAxis.setMinorTickPosition(TickPosition.OUTSIDE);
    Labels labels = new Labels();
    labels.setDistance(20);
    labels.setRotationPerpendicular();
    yAxis.setLabels(labels);
    yAxis.setPlotBands(plotBand1);
    YAxis yAxis2 = new YAxis();
    yAxis2.setPane(pane2);
    yAxis2.setTitle("VU<br/><span style=\"font-size:8px\">Channel B</span>");
    yAxis2.getTitle().setY(-40);
    yAxis2.setMin(-20);
    yAxis2.setMax(6);
    yAxis2.setTickPosition(TickPosition.OUTSIDE);
    yAxis2.setMinorTickPosition(TickPosition.OUTSIDE);
    labels = new Labels();
    labels.setDistance(20);
    labels.setRotationPerpendicular();
    yAxis2.setLabels(labels);
    yAxis2.setPlotBands(plotBand2);
    configuration.addyAxis(yAxis);
    configuration.addyAxis(yAxis2);
    PlotOptionsGauge gauge = new PlotOptionsGauge();
    gauge.setDataLabels(new DataLabels(false));
    gauge.setDial(new Dial());
    gauge.getDial().setRadius("100%");
    configuration.setPlotOptions(gauge);
    final ListSeries series1 = new ListSeries(-20);
    final ListSeries series2 = new ListSeries(-20);
    series1.setyAxis(0);
    series2.setyAxis(1);
    configuration.setSeries(series1, series2);
    runWhileAttached(chart, new Runnable() {

        final Random r = new Random(0);

        @Override
        public void run() {
            double left = series1.getData()[0].doubleValue();
            double inc = (r.nextDouble() - 0.5) * 3;
            double leftVal = left + inc;
            double rightVal = leftVal + inc / 3;
            if (leftVal < -20 || leftVal > 6) {
                leftVal = left - inc;
            }
            if (rightVal < -20 || rightVal > 6) {
                rightVal = leftVal;
            }
            series1.updatePoint(0, leftVal);
            series2.updatePoint(0, rightVal);
        }
    }, 500, 12000);
    chart.drawChart(configuration);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataLabels(com.vaadin.addon.charts.model.DataLabels) Labels(com.vaadin.addon.charts.model.Labels) Pane(com.vaadin.addon.charts.model.Pane) PlotOptionsGauge(com.vaadin.addon.charts.model.PlotOptionsGauge) Dial(com.vaadin.addon.charts.model.Dial) Random(java.util.Random) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 8 with Pane

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

the class PolarChart method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.getChart().setPolar(true);
    conf.setTitle("Polar Chart");
    Pane pane = new Pane(0, 360);
    conf.addPane(pane);
    pane.setBackground(new Background[] {});
    XAxis axis = new XAxis();
    axis.setTickInterval(45);
    axis.setMin(0);
    axis.setMax(360);
    Labels labels = new Labels();
    labels.setFormatter("function() {return this.value + '°';}");
    axis.setLabels(labels);
    YAxis yaxs = new YAxis();
    yaxs.setMin(0);
    conf.addxAxis(axis);
    conf.addyAxis(yaxs);
    PlotOptionsSeries series = new PlotOptionsSeries();
    PlotOptionsColumn column = new PlotOptionsColumn();
    series.setPointStart(0);
    series.setPointInterval(45);
    column.setPointPadding(0);
    column.setGroupPadding(0);
    conf.setPlotOptions(series, column);
    ListSeries col = new ListSeries(8, 7, 6, 5, 4, 3, 2, 1);
    ListSeries line = new ListSeries(1, 2, 3, 4, 5, 6, 7, 8);
    ListSeries area = new ListSeries(1, 8, 2, 7, 3, 6, 4, 5);
    col.setPlotOptions(new PlotOptionsColumn());
    col.setName(ChartType.COLUMN.toString());
    line.setPlotOptions(new PlotOptionsLine());
    line.setName(ChartType.LINE.toString());
    area.setPlotOptions(new PlotOptionsArea());
    area.setName(ChartType.AREA.toString());
    conf.setSeries(col, line, area);
    chart.drawChart(conf);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) Labels(com.vaadin.addon.charts.model.Labels) Pane(com.vaadin.addon.charts.model.Pane) 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 9 with Pane

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

the class ChartTypes method chartTypePolarSnippet2.

public void chartTypePolarSnippet2() {
    Chart chart = new Chart(ChartType.LINE);
    // Enable the polar projection
    Configuration conf = chart.getConfiguration();
    // Define the sector of the polar projection
    // Full circle
    Pane pane = new Pane(0, 360);
    conf.addPane(pane);
    // Define the X axis and set its value range
    XAxis axis = new XAxis();
    axis.setMin(0);
    axis.setMax(360);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Pane(com.vaadin.addon.charts.model.Pane) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis)

Example 10 with Pane

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

the class ChartTypes method chartTypesSolidGaugeConfSnippet1.

public void chartTypesSolidGaugeConfSnippet1() {
    Chart chart = new Chart(ChartType.SOLIDGAUGE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Solid Gauge");
    Pane pane = conf.getPane();
    // For positioning tick labels
    pane.setSize("125%");
    // Move center lower
    pane.setCenter("50%", "70%");
    // Make semi-circle
    pane.setStartAngle(-90);
    // Make semi-circle
    pane.setEndAngle(90);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Pane(com.vaadin.addon.charts.model.Pane) Chart(com.vaadin.addon.charts.Chart)

Aggregations

Pane (com.vaadin.addon.charts.model.Pane)10 Chart (com.vaadin.addon.charts.Chart)8 Configuration (com.vaadin.addon.charts.model.Configuration)8 ListSeries (com.vaadin.addon.charts.model.ListSeries)5 YAxis (com.vaadin.addon.charts.model.YAxis)5 Labels (com.vaadin.addon.charts.model.Labels)4 XAxis (com.vaadin.addon.charts.model.XAxis)4 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)3 Background (com.vaadin.addon.charts.model.Background)2 DataLabels (com.vaadin.addon.charts.model.DataLabels)2 PaneList (com.vaadin.addon.charts.model.PaneList)2 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)2 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)2 Random (java.util.Random)2 Test (org.junit.Test)2 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)1 Dial (com.vaadin.addon.charts.model.Dial)1 PlotBand (com.vaadin.addon.charts.model.PlotBand)1 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)1 PlotOptionsGauge (com.vaadin.addon.charts.model.PlotOptionsGauge)1