Search in sources :

Example 1 with Crosshair

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

the class SplineWithSymbols method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.SPLINE);
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Temperature"));
    Labels labels = new Labels();
    labels.setFormatter("this.value +'°'");
    yAxis.setLabels(labels);
    configuration.getTooltip().setShared(true);
    configuration.getxAxis().setCrosshair(new Crosshair());
    PlotOptionsSpline plotOptions = new PlotOptionsSpline();
    configuration.setPlotOptions(plotOptions);
    plotOptions.setMarker(new Marker(true));
    plotOptions.getMarker().setRadius(4);
    plotOptions.getMarker().setLineColor(new SolidColor("#666666"));
    plotOptions.getMarker().setLineWidth(1);
    DataSeries ls = new DataSeries();
    plotOptions = new PlotOptionsSpline();
    Marker marker = new Marker();
    marker.setSymbol(MarkerSymbolEnum.SQUARE);
    plotOptions.setMarker(marker);
    ls.setPlotOptions(plotOptions);
    ls.setName("Tokyo");
    ls.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);
    ls.get("26.5").getMarker().setSymbol(new MarkerSymbolUrl("http://www.highcharts.com/demo/gfx/sun.png"));
    configuration.addSeries(ls);
    ls = new DataSeries();
    plotOptions = new PlotOptionsSpline();
    marker = new Marker();
    marker.setSymbol(MarkerSymbolEnum.DIAMOND);
    plotOptions.setMarker(marker);
    ls.setPlotOptions(plotOptions);
    ls.setName("London");
    ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
    ls.get("3.9").getMarker().setSymbol(new MarkerSymbolUrl("http://www.highcharts.com/demo/gfx/snow.png"));
    configuration.addSeries(ls);
    chart.drawChart(configuration);
    return chart;
}
Also used : MarkerSymbolUrl(com.vaadin.addon.charts.model.MarkerSymbolUrl) Configuration(com.vaadin.addon.charts.model.Configuration) Crosshair(com.vaadin.addon.charts.model.Crosshair) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Labels(com.vaadin.addon.charts.model.Labels) DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 2 with Crosshair

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

the class ResizeInsideVaadinComponent method createChart.

private Chart createChart() {
    Chart chart = new Chart(ChartType.AREARANGE);
    chart.setSizeFull();
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Temperature variation by day");
    XAxis axis = new XAxis();
    axis.setType(AxisType.DATETIME);
    axis.setCrosshair(new Crosshair());
    conf.addxAxis(axis);
    conf.addyAxis(new YAxis());
    Tooltip tooltip = new Tooltip();
    tooltip.setShared(true);
    tooltip.setValueSuffix("°C");
    conf.setTooltip(tooltip);
    RangeSeries data = new RangeSeries("Temperatures", getRawData());
    conf.setSeries(data);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) Tooltip(com.vaadin.addon.charts.model.Tooltip) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 3 with Crosshair

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

the class AreaRange method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.AREARANGE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Temperature variation by day");
    conf.getxAxis().setType(DATETIME);
    conf.getxAxis().setCrosshair(new Crosshair());
    conf.addyAxis(new YAxis());
    Tooltip tooltip = new Tooltip();
    tooltip.setShared(true);
    tooltip.setValueSuffix("°C");
    conf.setTooltip(tooltip);
    RangeSeries data = new RangeSeries("Temperatures", getRawData());
    conf.setSeries(data);
    chart.drawChart(conf);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) Tooltip(com.vaadin.addon.charts.model.Tooltip) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 4 with Crosshair

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

the class Migration method exampleResult.

public Chart exampleResult() {
    Chart chart = new Chart();
    Configuration config = chart.getConfiguration();
    config.setTitle("Charts migration");
    config.getTitle().setAlign(HorizontalAlign.LEFT);
    Crosshair xCrossHair = new Crosshair();
    xCrossHair.setColor(SolidColor.BLACK);
    xCrossHair.setDashStyle(DashStyle.SOLID);
    xCrossHair.setWidth(10);
    xCrossHair.setZIndex(0);
    config.getxAxis().setCrosshair(xCrossHair);
    Crosshair yCrossHair = new Crosshair();
    yCrossHair.setColor(new SolidColor("#880000"));
    yCrossHair.setDashStyle(DashStyle.DOT);
    yCrossHair.setWidth(5);
    yCrossHair.setZIndex(1);
    config.getyAxis().setCrosshair(yCrossHair);
    config.getLegend().setEnabled(false);
    config.getTooltip().setEnabled(false);
    ListSeries ls = new ListSeries();
    ls.setName("Data");
    ls.setData(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
    PlotOptionsAreaspline plotOptions = new PlotOptionsAreaspline();
    plotOptions.setColor(SolidColor.BURLYWOOD);
    plotOptions.setDataLabels(new DataLabels(false));
    ls.setPlotOptions(plotOptions);
    config.setSeries(ls);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) PlotOptionsAreaspline(com.vaadin.addon.charts.model.PlotOptionsAreaspline) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart)

Example 5 with Crosshair

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

the class BasicLineWithCustomCrosshairLabels method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setTimeline(true);
    chart.setId("chart");
    Configuration config = chart.getConfiguration();
    config.setTitle("Customized crosshairs");
    config.getChart().setAnimation(false);
    Crosshair xCrossHair = new Crosshair();
    xCrossHair.getLabel().setEnabled(true);
    xCrossHair.getLabel().setBackgroundColor(new SolidColor("#ff0000"));
    xCrossHair.getLabel().setBorderColor(new SolidColor("#ff00ff"));
    xCrossHair.getLabel().setBorderWidth(3);
    config.getxAxis().setCrosshair(xCrossHair);
    Crosshair yCrossHair = new Crosshair();
    yCrossHair.setColor(new SolidColor("#880000"));
    yCrossHair.setDashStyle(DashStyle.DOT);
    yCrossHair.setWidth(5);
    yCrossHair.setZIndex(1);
    config.getyAxis().setCrosshair(yCrossHair);
    ListSeries ls = new ListSeries();
    ls.setName("Data");
    ls.setData(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
    config.setSeries(ls);
    chart.drawChart(config);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart)

Aggregations

Chart (com.vaadin.addon.charts.Chart)6 Configuration (com.vaadin.addon.charts.model.Configuration)6 Crosshair (com.vaadin.addon.charts.model.Crosshair)6 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)4 ListSeries (com.vaadin.addon.charts.model.ListSeries)3 YAxis (com.vaadin.addon.charts.model.YAxis)3 RangeSeries (com.vaadin.addon.charts.model.RangeSeries)2 Tooltip (com.vaadin.addon.charts.model.Tooltip)2 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)1 DataLabels (com.vaadin.addon.charts.model.DataLabels)1 DataSeries (com.vaadin.addon.charts.model.DataSeries)1 Labels (com.vaadin.addon.charts.model.Labels)1 Marker (com.vaadin.addon.charts.model.Marker)1 MarkerSymbolUrl (com.vaadin.addon.charts.model.MarkerSymbolUrl)1 PlotOptionsAreaspline (com.vaadin.addon.charts.model.PlotOptionsAreaspline)1 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)1 XAxis (com.vaadin.addon.charts.model.XAxis)1