Search in sources :

Example 56 with XAxis

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

the class PointClickCoordinatesColumnChart method createChart.

@Override
protected Chart createChart() {
    Chart chart = super.createChart();
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Total fruit consumption, grouped by gender");
    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 y = new YAxis();
    y.setMin(0);
    y.setTitle("Rainfall (mm)");
    conf.addyAxis(y);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setBackgroundColor(new SolidColor("#FFFFFF"));
    legend.setAlign(HorizontalAlign.LEFT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(100);
    legend.setY(70);
    legend.setFloating(true);
    legend.setShadow(true);
    conf.setLegend(legend);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.x +': '+ this.y +' mm'");
    conf.setTooltip(tooltip);
    PlotOptionsColumn plot = new PlotOptionsColumn();
    plot.setPointPadding(0.2);
    plot.setBorderWidth(0);
    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) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 57 with XAxis

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

the class PointClickCoordinatesScatterChart method createChart.

@Override
protected Chart createChart() {
    Chart chart = super.createChart();
    Configuration conf = chart.getConfiguration();
    XAxis x = conf.getxAxis();
    x.setGridLineWidth(1);
    x.setExtremes(-3, 3);
    if (getCurrentTheme().getxAxis().getGridLineColor() != null) {
        x.setGridLineColor(getCurrentTheme().getxAxis().getGridLineColor());
    }
    YAxis y = conf.getyAxis();
    y.setExtremes(-1, 1);
    ZAxis z = conf.getzAxis();
    z.setMin(-1);
    z.setMax(1);
    Options3d options3d = new Options3d();
    options3d.setEnabled(true);
    options3d.setAlpha(10);
    options3d.setBeta(30);
    options3d.setDepth(80);
    options3d.setViewDistance(40);
    Frame frame = new Frame();
    Bottom bottom = new Bottom();
    bottom.setSize(1);
    frame.setBottom(bottom);
    options3d.setFrame(frame);
    conf.getChart().setOptions3d(options3d);
    chart.drawChart();
    return chart;
}
Also used : Frame(com.vaadin.addon.charts.model.Frame) Configuration(com.vaadin.addon.charts.model.Configuration) ZAxis(com.vaadin.addon.charts.model.ZAxis) Bottom(com.vaadin.addon.charts.model.Bottom) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) Options3d(com.vaadin.addon.charts.model.Options3d) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 58 with XAxis

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

the class ServerSideEvents method getChart.

@Override
protected Component getChart() {
    eventDetails.setId("eventDetails");
    lastEvent.setId("lastEvent");
    historyLayout.setId("history");
    chart = new Chart();
    chart.setId("chart");
    chart.setWidth("500px");
    final Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.SCATTER);
    configuration.getTitle().setText("Test server side events.");
    configuration.getSubTitle().setText("When an event occurs, the details are shown below the chart");
    configuration.setExporting(true);
    configuration.getChart().setAnimation(false);
    configuration.getChart().setZoomType(ZoomType.XY);
    XAxis xAxis = configuration.getxAxis();
    xAxis.setMinPadding(0.2);
    xAxis.setMaxPadding(0.2);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Value"));
    PlotLine plotline = new PlotLine();
    plotline.setValue(0);
    plotline.setWidth(1);
    plotline.setColor(new SolidColor("#808080"));
    yAxis.setPlotLines(new PlotLine[] { plotline });
    yAxis.setMinPadding(0.2);
    yAxis.setMaxPadding(0.2);
    YAxis yAxis1 = new YAxis();
    yAxis1.setTitle("Another axis");
    yAxis1.setOpposite(true);
    configuration.addyAxis(yAxis1);
    PlotOptionsSeries opt = new PlotOptionsSeries();
    opt.setLineWidth(1);
    opt.setShowCheckbox(true);
    opt.setAllowPointSelect(true);
    configuration.setPlotOptions(opt);
    configuration.setTooltip(new Tooltip(false));
    final DataSeries series1 = createDataSeries(0);
    final DataSeries series2 = createDataSeries(20);
    DataSeries series3 = createDataSeries(100);
    series3.get(0).setY(105);
    series3.get(3).setY(95);
    series3.setName("Another axis");
    series3.setyAxis(1);
    firstDataPoint = series1.get(0);
    firstDataPoint.setSelected(true);
    configuration.setSeries(series1, series2, series3);
    chart.drawChart(configuration);
    final Layout toggles = createControls();
    Layout eventListeners = addEventListeners();
    chart.setSeriesVisibilityTogglingDisabled(false);
    visibilityToggling.setValue(false);
    lastEvent.setCaption("Last event");
    eventDetails.setCaption("Details");
    historyLayout.setCaption("History");
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.addComponent(toggles);
    HorizontalLayout chartAndListeners = new HorizontalLayout(chart, eventListeners);
    chartAndListeners.setSizeUndefined();
    chartAndListeners.setSpacing(true);
    layout.addComponent(chartAndListeners);
    layout.addComponent(lastEvent);
    layout.addComponent(eventDetails);
    layout.addComponent(historyLayout);
    return layout;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Tooltip(com.vaadin.addon.charts.model.Tooltip) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) XAxis(com.vaadin.addon.charts.model.XAxis) HorizontalLayout(com.vaadin.ui.HorizontalLayout) VerticalLayout(com.vaadin.ui.VerticalLayout) Layout(com.vaadin.ui.Layout) HorizontalLayout(com.vaadin.ui.HorizontalLayout) VerticalLayout(com.vaadin.ui.VerticalLayout) PlotLine(com.vaadin.addon.charts.model.PlotLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 59 with XAxis

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

the class LibraryData method updateChart.

private void updateChart() {
    if (series != null) {
        ArrayList<DataSeriesItem> list = new ArrayList<DataSeriesItem>();
        ArrayList<String> categories = new ArrayList<String>();
        for (Helmet.Record r : result.records) {
            int numPages = r.getNumPages();
            if (numPages != -1) {
                String name = String.format("%s, written by %s %s", r.title, r.author, r.description.isEmpty() ? "" : "<br/>" + r.description);
                list.add(new DataSeriesItem(name, numPages));
                categories.add(r.title.length() > 25 ? r.title.substring(0, 25) + "..." : r.title);
            }
        }
        series.setData(list);
        XAxis getyAxes = chart.getConfiguration().getxAxis();
        getyAxes.setCategories(categories.toArray(new String[categories.size()]));
        chart.drawChart(chart.getConfiguration());
    }
}
Also used : ArrayList(java.util.ArrayList) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) XAxis(com.vaadin.addon.charts.model.XAxis)

Example 60 with XAxis

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

the class BasicLineGettingMousePointerPosition method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setId("chart");
    Color[] colors = getThemeColors();
    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(colors[0]);
    primary.getTitle().setStyle(style);
    conf.addyAxis(primary);
    YAxis snd = new YAxis();
    snd.setTitle("Rainfall");
    snd.setOpposite(true);
    style = new Style();
    style.setColor(colors[1]);
    snd.getTitle().setStyle(style);
    conf.addyAxis(snd);
    Tooltip tooltip = new Tooltip(false);
    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);
    legend.setBackgroundColor(new SolidColor("#FFFFFF"));
    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);
    conf.addSeries(series);
    chart.addPointClickListener(new PointClickListener() {

        @Override
        public void onClick(PointClickEvent event) {
            Window win = new Window("PointClickEvent window");
            win.setContent(new Label("Browser client area coordinates: point X:" + event.getAbsoluteX() + " Y:" + event.getAbsoluteY()));
            win.setPositionX(event.getAbsoluteX());
            win.setPositionY(event.getAbsoluteY());
            getUI().addWindow(win);
        }
    });
    chart.addChartClickListener(new ChartClickListener() {

        @Override
        public void onClick(ChartClickEvent event) {
            Window win = new Window("Chart Click Event Window");
            win.setContent(new Label("Browser client area coordinates: point X:" + event.getAbsoluteX() + " Y:" + event.getAbsoluteY()));
            win.setPositionX(event.getAbsoluteX());
            win.setPositionY(event.getAbsoluteY());
            getUI().addWindow(win);
        }
    });
    return chart;
}
Also used : Window(com.vaadin.ui.Window) Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Color(com.vaadin.addon.charts.model.style.Color) Tooltip(com.vaadin.addon.charts.model.Tooltip) PointClickEvent(com.vaadin.addon.charts.PointClickEvent) Label(com.vaadin.ui.Label) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) XAxis(com.vaadin.addon.charts.model.XAxis) ChartClickEvent(com.vaadin.addon.charts.ChartClickEvent) ChartClickListener(com.vaadin.addon.charts.ChartClickListener) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) PointClickListener(com.vaadin.addon.charts.PointClickListener) Style(com.vaadin.addon.charts.model.style.Style) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

XAxis (com.vaadin.addon.charts.model.XAxis)78 Chart (com.vaadin.addon.charts.Chart)71 Configuration (com.vaadin.addon.charts.model.Configuration)65 YAxis (com.vaadin.addon.charts.model.YAxis)63 Tooltip (com.vaadin.addon.charts.model.Tooltip)39 ListSeries (com.vaadin.addon.charts.model.ListSeries)35 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)26 DataSeries (com.vaadin.addon.charts.model.DataSeries)26 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)26 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)26 Legend (com.vaadin.addon.charts.model.Legend)20 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)17 DataLabels (com.vaadin.addon.charts.model.DataLabels)16 Title (com.vaadin.addon.charts.model.Title)16 Labels (com.vaadin.addon.charts.model.Labels)9 Style (com.vaadin.addon.charts.model.style.Style)9 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)8 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)8 ArrayList (java.util.ArrayList)8 Marker (com.vaadin.addon.charts.model.Marker)7