Search in sources :

Example 31 with SolidColor

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

the class DeclarativeTreemapWithLevels method createSeries.

private TreeSeries createSeries() {
    TreeSeries series = new TreeSeries();
    TreeSeriesItem apples = new TreeSeriesItem("A", "Apples");
    apples.setColor(new SolidColor("#EC2500"));
    TreeSeriesItem bananas = new TreeSeriesItem("B", "Bananas");
    bananas.setColor(new SolidColor("#ECE100"));
    TreeSeriesItem oranges = new TreeSeriesItem("O", "Oranges");
    oranges.setColor(new SolidColor("#EC9800"));
    TreeSeriesItem anneA = new TreeSeriesItem("Anne", apples, 5);
    TreeSeriesItem rickA = new TreeSeriesItem("Rick", apples, 3);
    TreeSeriesItem peterA = new TreeSeriesItem("Peter", apples, 4);
    TreeSeriesItem anneB = new TreeSeriesItem("Anne", bananas, 4);
    TreeSeriesItem rickB = new TreeSeriesItem("Rick", bananas, 10);
    TreeSeriesItem peterB = new TreeSeriesItem("Peter", bananas, 1);
    TreeSeriesItem anneO = new TreeSeriesItem("Anne", oranges, 1);
    TreeSeriesItem rickO = new TreeSeriesItem("Rick", oranges, 3);
    TreeSeriesItem peterO = new TreeSeriesItem("Peter", oranges, 3);
    TreeSeriesItem susanne = new TreeSeriesItem("Susanne", 2);
    susanne.setParent("Kiwi");
    susanne.setColor(new SolidColor("#9EDE00"));
    series.addAll(apples, bananas, oranges, anneA, rickA, peterA, anneB, rickB, peterB, anneO, rickO, peterO, susanne);
    return series;
}
Also used : TreeSeries(com.vaadin.addon.charts.model.TreeSeries) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) TreeSeriesItem(com.vaadin.addon.charts.model.TreeSeriesItem)

Example 32 with SolidColor

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

the class MasterDetailChart method getChart.

@Override
protected Component getChart() {
    VerticalLayout lo = new VerticalLayout();
    lo.setSpacing(false);
    lo.setMargin(false);
    lo.setWidth("100%");
    lo.setHeight("600px");
    final Chart masterChart = getMasterChart();
    final Chart detailChart = getDetailChart();
    masterChart.addChartSelectionListener(new ChartSelectionListener() {

        @Override
        public void onSelection(ChartSelectionEvent event) {
            long start = event.getSelectionStart().longValue();
            long end = event.getSelectionEnd().longValue();
            // set plot band to highlight the selection on the master chart
            PlotBand plotBand1 = new PlotBand();
            PlotBand plotBand2 = new PlotBand();
            plotBand1.setColor(new SolidColor(0, 0, 0, 0.2));
            plotBand2.setColor(new SolidColor(0, 0, 0, 0.2));
            plotBand1.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
            plotBand1.setTo(start);
            plotBand2.setFrom(end);
            plotBand2.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
            masterChart.getConfiguration().getxAxis().setPlotBands(plotBand1, plotBand2);
            masterChart.drawChart();
            List<Number> list = MasterDetailChart.this.getPartialList(start, end);
            Configuration configuration = detailChart.getConfiguration();
            configuration.getChart().setAnimation(false);
            ListSeries detailData = (ListSeries) configuration.getSeries().get(0);
            PlotOptionsLine plotOptionsLine = (PlotOptionsLine) detailData.getPlotOptions();
            plotOptionsLine.setPointStart(start);
            detailData.setData(list);
            detailChart.drawChart(configuration);
        }
    });
    lo.addComponent(detailChart);
    lo.addComponent(masterChart);
    return lo;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) VerticalLayout(com.vaadin.ui.VerticalLayout) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) ArrayList(java.util.ArrayList) List(java.util.List) ChartSelectionEvent(com.vaadin.addon.charts.ChartSelectionEvent) ChartSelectionListener(com.vaadin.addon.charts.ChartSelectionListener) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart)

Example 33 with SolidColor

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

the class MasterDetailChart method getMasterChart.

private Chart getMasterChart() {
    Chart masterChart = new Chart(ChartType.AREA);
    masterChart.setHeight("80px");
    masterChart.setWidth("100%");
    masterChart.setId("master-chart");
    Configuration configuration = masterChart.getConfiguration();
    configuration.getChart().setZoomType(ZoomType.X);
    configuration.getChart().setReflow(false);
    configuration.getChart().setBorderWidth(0);
    configuration.getChart().setBackgroundColor(null);
    configuration.getChart().setMarginLeft(50);
    configuration.getChart().setMarginRight(20);
    configuration.getTitle().setText("");
    configuration.getxAxis().setType(AxisType.DATETIME);
    configuration.getxAxis().setShowLastLabel(true);
    configuration.getxAxis().setMinRange(14 * DAY_IN_MILLIS);
    configuration.getxAxis().setTitle(new AxisTitle(""));
    PlotBand mask = new PlotBand();
    mask.setColor(new SolidColor(0, 0, 0, 0.2));
    mask.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
    mask.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
    configuration.getxAxis().setPlotBands(mask);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setGridLineWidth(0);
    yAxis.setLabels(new Labels(false));
    yAxis.setTitle(new AxisTitle(""));
    yAxis.setMin(0.6);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setEnabled(false);
    configuration.getLegend().setEnabled(false);
    configuration.getCredits().setEnabled(false);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Hover hover = new Hover();
    hover.setLineWidth(1);
    States states = new States();
    states.setHover(hover);
    plotOptions.setStates(states);
    plotOptions.setEnableMouseTracking(false);
    plotOptions.setAnimation(false);
    configuration.setPlotOptions(plotOptions);
    ListSeries ls = new ListSeries();
    PlotOptionsArea masterPlotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor(69, 114, 167, 1));
    fillColor.addColorStop(1, new SolidColor(69, 114, 167, 0.5));
    masterPlotOptions.setFillColor(fillColor);
    masterPlotOptions.setPointInterval(24 * 3600 * 1000);
    masterPlotOptions.setMarker(new Marker(false));
    masterPlotOptions.setPointStart(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
    ls.setPlotOptions(masterPlotOptions);
    ls.setName("USD to EUR");
    ls.setData(FULL_DEMO_DATA_SET);
    configuration.addSeries(ls);
    masterChart.drawChart(configuration);
    return masterChart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Labels(com.vaadin.addon.charts.model.Labels) Marker(com.vaadin.addon.charts.model.Marker) States(com.vaadin.addon.charts.model.States) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) ListSeries(com.vaadin.addon.charts.model.ListSeries) Hover(com.vaadin.addon.charts.model.Hover) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 34 with SolidColor

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

the class ModifyOnePoint method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart();
    chart.setHeight("300px");
    chart.setWidth("100%");
    final Configuration configuration = chart.getConfiguration();
    configuration.setTitle("One point is different");
    configuration.getTooltip().setEnabled(false);
    configuration.getChart().setType(ChartType.SPLINE);
    series = new DataSeries();
    series.add(createBasicPoint(1, 4));
    series.add(new DataSeriesItem(3, 4));
    dataSeriesItem = new DataSeriesItem(4, 4);
    Marker marker = new Marker(true);
    marker.setRadius(10);
    marker.setFillColor(new SolidColor("red"));
    dataSeriesItem.setMarker(marker);
    dataSeriesItem.setName("Special point");
    series.add(dataSeriesItem);
    series.add(new DataSeriesItem(8, 3));
    configuration.setSeries(series);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 35 with SolidColor

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

the class ModifyOnePoint method setup.

@Override
protected void setup() {
    super.setup();
    FormLayout formLayout = new FormLayout();
    formLayout.setCaption("Special point settings, only updated point state is sent to client.");
    formLayout.setMargin(true);
    final Slider sliderX = new Slider();
    sliderX.setMin(3);
    sliderX.setMax(8);
    sliderX.setResolution(1);
    sliderX.setValue(4d);
    sliderX.setCaption("X");
    sliderX.addValueChangeListener(event -> {
        dataSeriesItem.setX(sliderX.getValue());
        series.update(dataSeriesItem);
    });
    sliderX.setWidth("200px");
    formLayout.addComponent(sliderX);
    final Slider sliderY = new Slider();
    sliderY.setMin(0);
    sliderY.setMax(10);
    sliderY.setResolution(1);
    sliderY.setValue(4d);
    sliderY.setCaption("Y");
    sliderY.addValueChangeListener(event -> {
        dataSeriesItem.setY(sliderY.getValue());
        updateItemInChart();
    });
    sliderY.setWidth("200px");
    formLayout.addComponent(sliderY);
    final ColorPicker colorPicker = new ColorPicker();
    colorPicker.setValue(new com.vaadin.shared.ui.colorpicker.Color(255, 0, 0));
    colorPicker.setCaption("Marker color");
    colorPicker.addValueChangeListener(event -> {
        dataSeriesItem.getMarker().setFillColor(new SolidColor(event.getValue().getCSS()));
        updateItemInChart();
    });
    formLayout.addComponent(colorPicker);
    Button c = new Button("Pseudorandom", new Button.ClickListener() {

        Random r = new Random(0);

        @Override
        public void buttonClick(ClickEvent event) {
            sliderX.setValue(r.nextDouble() * 5 + 3);
            sliderY.setValue(r.nextDouble() * 10);
            colorPicker.setValue(new com.vaadin.shared.ui.colorpicker.Color(r.nextInt(255), r.nextInt(255), r.nextInt(255)));
        }
    });
    c.setId("random");
    formLayout.addComponent(c);
    addComponentAsFirst(formLayout);
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Slider(com.vaadin.ui.Slider) ColorPicker(com.vaadin.ui.ColorPicker) ClickEvent(com.vaadin.ui.Button.ClickEvent) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Color(com.vaadin.addon.charts.model.style.Color) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Random(java.util.Random) Button(com.vaadin.ui.Button)

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