Search in sources :

Example 11 with XAxis

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

the class BasicLineWithAutoRotation method getChart.

@Override
protected Component getChart() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(false);
    layout.setMargin(false);
    final Chart chart = new Chart(ChartType.LINE);
    chart.setHeight("400px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    XAxis xAxis = configuration.getxAxis();
    xAxis.getLabels().setAutoRotation(new Number[] { -10, -20, -30, -40, 50, -60, -70, -80, -90 });
    ListSeries ls = new ListSeries();
    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);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("New York");
    ls.setData(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5);
    configuration.addSeries(ls);
    layout.addComponent(chart);
    final Slider slider = new Slider("Width (50 - 100)", 50, 100);
    slider.setWidth("200px");
    slider.setValue(100d);
    layout.addComponent(slider);
    layout.addComponent(new Button("Set min width", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            slider.setValue(50d);
        }
    }));
    slider.addValueChangeListener(event -> {
        double newValue = slider.getValue();
        chart.setWidth((float) newValue, Unit.PERCENTAGE);
    });
    return layout;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Slider(com.vaadin.ui.Slider) ListSeries(com.vaadin.addon.charts.model.ListSeries) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) VerticalLayout(com.vaadin.ui.VerticalLayout) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis)

Example 12 with XAxis

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

the class ChartPluginExamples method createHeatMap.

public static Chart createHeatMap() {
    final Chart chart = new Chart(CustomChartTypes.MAP);
    chart.setWidth("800px");
    chart.setHeight("500px");
    final Configuration configuration = chart.getConfiguration();
    ChartModel model = new ChartModel();
    configuration.setChart(model);
    model.setType(CustomChartTypes.MAP);
    model.setBorderWidth(1);
    model.setZoomType(ZoomType.XY);
    model.setInverted(false);
    configuration.getTitle().setText("Vaadin Charts Test for complex highcharts plugin");
    XAxis xAxis = configuration.getxAxis();
    xAxis.setEndOnTick(false);
    xAxis.setGridLineWidth(0);
    xAxis.getLabels().setEnabled(false);
    xAxis.setLineWidth(0);
    xAxis.setMinPadding(0);
    xAxis.setMaxPadding(0);
    xAxis.setStartOnTick(false);
    xAxis.setTickWidth(0);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setEndOnTick(false);
    yAxis.setGridLineWidth(0);
    yAxis.getLabels().setEnabled(false);
    yAxis.setLineWidth(0);
    yAxis.setMinPadding(0);
    yAxis.setMaxPadding(0);
    yAxis.setStartOnTick(false);
    yAxis.setTickWidth(0);
    yAxis.setTitle("");
    yAxis.setReversed(true);
    Legend legend = configuration.getLegend();
    legend.setHorizontalAlign(HorizontalAlign.LEFT);
    legend.setVerticalAlign(VerticalAlign.BOTTOM);
    legend.setFloating(true);
    legend.setLayout(LayoutDirection.VERTICAL);
    configuration.setExporting(false);
    MapSeries series = new MapSeries();
    series.addValueRange(new ValueRange(null, 3, new SolidColor(19, 64, 117, 0.05)));
    series.addValueRange(new ValueRange(3, 10, new SolidColor(19, 64, 117, 0.2)));
    series.addValueRange(new ValueRange(10, 30, new SolidColor(19, 64, 117, 0.4)));
    series.addValueRange(new ValueRange(30, 100, new SolidColor(19, 64, 117, 0.5)));
    series.addValueRange(new ValueRange(100, 300, new SolidColor(19, 64, 117, 0.6)));
    series.addValueRange(new ValueRange(300, 1000, new SolidColor(19, 64, 117, 0.8)));
    series.addValueRange(new ValueRange(1000, null, new SolidColor(19, 64, 117, 1)));
    Random random = new Random();
    for (String c : Locale.getISOCountries()) {
        DataSeriesItem p = new DataSeriesItem(c.toLowerCase(), random.nextInt(1200));
        series.add(p);
    }
    configuration.addSeries(series);
    chart.drawChart(configuration);
    return chart;
}
Also used : ValueRange(com.vaadin.demo.chartplugin.model.ValueRange) Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Random(java.util.Random) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) ChartModel(com.vaadin.addon.charts.model.ChartModel) MapSeries(com.vaadin.demo.chartplugin.model.MapSeries) 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)

Example 13 with XAxis

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

the class PlotBandTest method setup.

@Before
public void setup() {
    Chart chart = new Chart(ChartType.PIE);
    Configuration conf = chart.getConfiguration();
    axis = new XAxis();
    conf.addxAxis(axis);
    plotBand1 = new PlotBand();
    plotBand1.setFrom(1);
    plotBand1.setTo(2);
    plotBand1.setColor(SolidColor.ALICEBLUE);
    plotBand2 = new PlotBand();
    plotBand2.setFrom(2);
    plotBand2.setTo(3);
    plotBand2.setColor(SolidColor.ANTIQUEWHITE);
    plotBand3 = new PlotBand();
    plotBand3.setFrom(3);
    plotBand3.setTo(4);
    plotBand3.setColor(SolidColor.AQUA);
    List<PlotBand> plotbands = new ArrayList<PlotBand>();
    plotbands.add(plotBand1);
    plotbands.add(plotBand2);
    plotbands.add(plotBand3);
    axis.setPlotBands(plotBand1, plotBand2, plotBand3);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ArrayList(java.util.ArrayList) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) Before(org.junit.Before)

Example 14 with XAxis

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

the class ChartConfiguration method axisSnippet1.

public void axisSnippet1(Configuration conf) {
    XAxis xaxis = new XAxis();
    xaxis.setTitle("Axis title");
    conf.addxAxis(xaxis);
}
Also used : XAxis(com.vaadin.addon.charts.model.XAxis)

Example 15 with XAxis

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

the class ChartConfiguration method labelsSnippet1.

public void labelsSnippet1(Configuration conf) {
    XAxis xaxis = new XAxis();
    // ...
    Labels xlabels = xaxis.getLabels();
    // Default
    xlabels.setAlign(HorizontalAlign.CENTER);
    xlabels.getStyle().setColor(SolidColor.GREEN);
    xlabels.getStyle().setFontWeight(FontWeight.BOLD);
    xlabels.setRotation(-45);
    // Every 2 major tick
    xlabels.setStep(2);
}
Also used : Labels(com.vaadin.addon.charts.model.Labels) XAxis(com.vaadin.addon.charts.model.XAxis)

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