Search in sources :

Example 41 with Tooltip

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

the class BasicBar method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.BAR);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Historic World Population by Region");
    conf.setSubTitle("Source: Wikipedia.org");
    XAxis x = new XAxis();
    x.setCategories("Africa", "America", "Asia", "Europe", "Oceania");
    x.setTitle((String) null);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    AxisTitle title = new AxisTitle("Population (millions)");
    title.setAlign(VerticalAlign.MIDDLE);
    y.setTitle(title);
    conf.addyAxis(y);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.series.name +': '+ this.y +' millions'");
    conf.setTooltip(tooltip);
    PlotOptionsBar plot = new PlotOptionsBar();
    plot.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(plot);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-100);
    legend.setY(100);
    legend.setFloating(true);
    legend.setBorderWidth(1);
    legend.setBackgroundColor(new SolidColor("#FFFFFF"));
    legend.setShadow(true);
    conf.setLegend(legend);
    conf.disableCredits();
    List<Series> series = new ArrayList<Series>();
    series.add(new ListSeries("Year 1800", 107, 31, 635, 203, 2));
    series.add(new ListSeries("Year 1900", 133, 156, 947, 408, 6));
    series.add(new ListSeries("Year 2008", 973, 914, 4054, 732, 34));
    conf.setSeries(series);
    chart.drawChart(conf);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) Tooltip(com.vaadin.addon.charts.model.Tooltip) ArrayList(java.util.ArrayList) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) PlotOptionsBar(com.vaadin.addon.charts.model.PlotOptionsBar) XAxis(com.vaadin.addon.charts.model.XAxis) Series(com.vaadin.addon.charts.model.Series) ListSeries(com.vaadin.addon.charts.model.ListSeries) ListSeries(com.vaadin.addon.charts.model.ListSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 42 with Tooltip

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

the class ColumnWithNativeDrilldown method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart(ChartType.COLUMN);
    chart.setId("chart");
    final Configuration conf = chart.getConfiguration();
    conf.setTitle("Browser market share, April, 2011");
    conf.setSubTitle("Click the columns to view versions. Click again to view brands.");
    conf.getLegend().setEnabled(false);
    XAxis x = new XAxis();
    x.setType(AxisType.CATEGORY);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setTitle("Total percent market share");
    conf.addyAxis(y);
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setCursor(Cursor.POINTER);
    column.setDataLabels(new DataLabels(true));
    column.getDataLabels().setFormatter("this.y +'%'");
    conf.setPlotOptions(column);
    Tooltip tooltip = new Tooltip();
    tooltip.setHeaderFormat("<span style=\"font-size:11px\">{series.name}</span><br>");
    tooltip.setPointFormat("<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>");
    conf.setTooltip(tooltip);
    DataSeries series = new DataSeries();
    series.setName("Browser brands");
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setColorByPoint(true);
    series.setPlotOptions(plotOptionsColumn);
    DataSeriesItem item = new DataSeriesItem("MSIE", 55.11);
    DataSeries drillSeries = new DataSeries("MSIE versions");
    drillSeries.setId("MSIE");
    String[] categories = new String[] { "MSIE 6.0", "MSIE 7.0", "MSIE 8.0", "MSIE 9.0" };
    Number[] ys = new Number[] { 10.85, 7.35, 33.06, 2.81 };
    drillSeries.setData(categories, ys);
    series.addItemWithDrilldown(item, drillSeries);
    item = new DataSeriesItem("Firefox", 21.63);
    drillSeries = new DataSeries("Firefox versions");
    drillSeries.setId("Firefox");
    categories = new String[] { "Firefox 2.0", "Firefox 3.0", "Firefox 3.5", "Firefox 3.6", "Firefox 4.0" };
    ys = new Number[] { 0.20, 0.83, 1.58, 13.12, 5.43 };
    drillSeries.setData(categories, ys);
    series.addItemWithDrilldown(item, drillSeries);
    item = new DataSeriesItem("Chrome", 11.94);
    drillSeries = new DataSeries("Chrome versions");
    drillSeries.setId("Chrome");
    categories = new String[] { "Chrome 5.0", "Chrome 6.0", "Chrome 7.0", "Chrome 8.0", "Chrome 9.0", "Chrome 10.0", "Chrome 11.0", "Chrome 12.0" };
    ys = new Number[] { 0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22 };
    drillSeries.setData(categories, ys);
    series.addItemWithDrilldown(item, drillSeries);
    item = new DataSeriesItem("Safari", 7.15);
    drillSeries = new DataSeries("Safari versions");
    drillSeries.setId("Safari");
    categories = new String[] { "Safari 5.0", "Safari 4.0", "Safari Win 5.0", "Safari 4.1", "Safari/Maxthon", "Safari 3.1", "Safari 4.1" };
    ys = new Number[] { 4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14 };
    drillSeries.setData(categories, ys);
    series.addItemWithDrilldown(item, drillSeries);
    item = new DataSeriesItem("Opera", 2.14);
    drillSeries = new DataSeries("Opera versions");
    drillSeries.setId("Opera");
    categories = new String[] { "Opera 9.x", "Opera 10.x", "Opera 11.x" };
    ys = new Number[] { 0.12, 0.37, 1.65 };
    drillSeries.setData(categories, ys);
    series.addItemWithDrilldown(item, drillSeries);
    conf.addSeries(series);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) Tooltip(com.vaadin.addon.charts.model.Tooltip) XAxis(com.vaadin.addon.charts.model.XAxis) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 43 with Tooltip

use of com.vaadin.addon.charts.model.Tooltip 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 44 with Tooltip

use of com.vaadin.addon.charts.model.Tooltip 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)

Example 45 with Tooltip

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

the class ColumnRangeResourceUsage method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMNRANGE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Resource usage");
    conf.getChart().setInverted(true);
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Printer", "Coffee mahine");
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setTitle("Time");
    yAxis.setType(AxisType.DATETIME);
    conf.addyAxis(yAxis);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.series.name +': '+ Highcharts.dateFormat('%H:%M', this.point.low) + ' - ' + Highcharts.dateFormat('%H:%M', this.point.high)");
    conf.setTooltip(tooltip);
    PlotOptionsColumnrange columnRange = new PlotOptionsColumnrange();
    columnRange.setGrouping(false);
    DataLabelsRange dataLabels = new DataLabelsRange(true);
    dataLabels.setFormatter("this.y == this.point.low ? '' : this.series.name");
    dataLabels.setInside(true);
    dataLabels.setColor(new SolidColor("white"));
    columnRange.setDataLabels(dataLabels);
    conf.setPlotOptions(columnRange);
    Calendar instance = Calendar.getInstance();
    instance.set(Calendar.MILLISECOND, 0);
    instance.set(2013, 6, 7, 12, 00, 00);
    DataSeries a = new DataSeries();
    a.setName("Team Alpha");
    PlotOptionsColumnrange o = new PlotOptionsColumnrange();
    o.setColor(new SolidColor(255, 60, 125, 0.8));
    a.setPlotOptions(o);
    DataSeries b = new DataSeries();
    o = new PlotOptionsColumnrange();
    o.setColor(new SolidColor(60, 125, 255, 0.8));
    b.setPlotOptions(o);
    b.setName("Team Beta");
    DataSeriesItem item;
    item = new DataSeriesItem();
    item.setName("Printer");
    item.setLow(instance.getTimeInMillis());
    instance.roll(Calendar.HOUR_OF_DAY, 3);
    item.setHigh(instance.getTimeInMillis());
    a.add(item);
    item = new DataSeriesItem();
    item.setName("Printer");
    instance.roll(Calendar.HOUR_OF_DAY, 1);
    item.setLow(instance.getTimeInMillis());
    instance.roll(Calendar.HOUR_OF_DAY, 1);
    item.setHigh(instance.getTimeInMillis());
    b.add(item);
    instance.set(2013, 6, 7, 12, 00, 00);
    item = new DataSeriesItem();
    item.setName("Coffee mahine");
    item.setLow(instance.getTimeInMillis());
    instance.roll(Calendar.HOUR_OF_DAY, 2);
    item.setHigh(instance.getTimeInMillis());
    b.add(item);
    item = new DataSeriesItem();
    item.setName("Coffee mahine");
    instance.roll(Calendar.HOUR_OF_DAY, -1);
    item.setLow(instance.getTimeInMillis());
    instance.roll(Calendar.HOUR_OF_DAY, 4);
    item.setHigh(instance.getTimeInMillis());
    a.add(item);
    conf.setSeries(a, b);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumnrange(com.vaadin.addon.charts.model.PlotOptionsColumnrange) DataLabelsRange(com.vaadin.addon.charts.model.DataLabelsRange) Tooltip(com.vaadin.addon.charts.model.Tooltip) Calendar(java.util.Calendar) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

Tooltip (com.vaadin.addon.charts.model.Tooltip)46 Chart (com.vaadin.addon.charts.Chart)44 Configuration (com.vaadin.addon.charts.model.Configuration)42 XAxis (com.vaadin.addon.charts.model.XAxis)39 YAxis (com.vaadin.addon.charts.model.YAxis)39 ListSeries (com.vaadin.addon.charts.model.ListSeries)24 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)20 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)16 DataSeries (com.vaadin.addon.charts.model.DataSeries)16 Legend (com.vaadin.addon.charts.model.Legend)14 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)14 DataLabels (com.vaadin.addon.charts.model.DataLabels)13 Title (com.vaadin.addon.charts.model.Title)12 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)10 Series (com.vaadin.addon.charts.model.Series)7 Style (com.vaadin.addon.charts.model.style.Style)7 Labels (com.vaadin.addon.charts.model.Labels)5 DataLabelsRange (com.vaadin.addon.charts.model.DataLabelsRange)4 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)4 PlotOptionsColumnrange (com.vaadin.addon.charts.model.PlotOptionsColumnrange)4