Search in sources :

Example 1 with ButtonTheme

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

the class RangeSelectorCustomDateParser method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    chart.setTimeline(true);
    Configuration configuration = chart.getConfiguration();
    YAxis yAxis = new YAxis();
    PlotLine plotLine = new PlotLine();
    plotLine.setValue(2);
    plotLine.setWidth(2);
    plotLine.setColor(SolidColor.SILVER);
    yAxis.setPlotLines(plotLine);
    configuration.addyAxis(yAxis);
    DataSeries aaplSeries = new DataSeries();
    for (StockPrices.PriceData data : StockPrices.fetchAaplPriceWithTime()) {
        DataSeriesItem item = new DataSeriesItem();
        item.setX(data.getDate());
        item.setY(data.getPrice());
        aaplSeries.add(item);
    }
    configuration.setSeries(aaplSeries);
    RangeSelector rangeSelector = new RangeSelector();
    rangeSelector.setSelected(4);
    ButtonTheme theme = new ButtonTheme();
    Style style = new Style();
    style.setColor(new SolidColor("#0766d8"));
    style.setFontWeight(FontWeight.BOLD);
    theme.setStyle(style);
    rangeSelector.setButtonTheme(theme);
    Style inputStyle = new Style();
    inputStyle.setColor(new SolidColor("#0766d8"));
    inputStyle.setFontWeight(FontWeight.BOLD);
    rangeSelector.setInputStyle(inputStyle);
    rangeSelector.setInputDateFormat("%H:%M:%S.%L");
    rangeSelector.setInputEditDateFormat("%H:%M:%S.%L");
    // All the data is for 2009 Jan 28, so we don't bother to parse date only parse time
    rangeSelector.setInputDateParser("function(value) {" + "value = value.split(/[:\\.]/);\n" + "return Date.UTC(\n" + "   2009,\n" + "   0,\n" + "   28,\n" + "   parseInt(value[0], 10),\n" + "   parseInt(value[1], 10),\n" + "   parseInt(value[2], 10),\n" + "   parseInt(value[3], 10)" + ");}");
    configuration.setRangeSelector(rangeSelector);
    chart.drawChart(configuration);
    return chart;
}
Also used : StockPrices(com.vaadin.addon.charts.examples.timeline.util.StockPrices) Configuration(com.vaadin.addon.charts.model.Configuration) RangeSelector(com.vaadin.addon.charts.model.RangeSelector) Style(com.vaadin.addon.charts.model.style.Style) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) PlotLine(com.vaadin.addon.charts.model.PlotLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) ButtonTheme(com.vaadin.addon.charts.model.style.ButtonTheme) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 2 with ButtonTheme

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

the class ButtonThemeJSONSerializationTest method toJSON_strokeWidthIsSet_themeSerializedWithDashInProperty.

@Test
public void toJSON_strokeWidthIsSet_themeSerializedWithDashInProperty() {
    ButtonTheme buttonTheme = new ButtonTheme();
    buttonTheme.setStrokeWidth(4);
    String json = toJSON(buttonTheme);
    String expected = "{\"stroke-width\":4}";
    assertEquals(expected, json);
}
Also used : ButtonTheme(com.vaadin.addon.charts.model.style.ButtonTheme) Test(org.junit.Test)

Example 3 with ButtonTheme

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

the class ButtonThemeJSONSerializationTest method toJSON_widthIsDefault_themeSerializedWithoutWidth.

@Test
public void toJSON_widthIsDefault_themeSerializedWithoutWidth() {
    ButtonTheme buttonTheme = new ButtonTheme();
    String json = toJSON(buttonTheme);
    String expected = "{}";
    assertEquals(expected, json);
}
Also used : ButtonTheme(com.vaadin.addon.charts.model.style.ButtonTheme) Test(org.junit.Test)

Example 4 with ButtonTheme

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

the class Timeline method chartsTimelineIntroSnippet2.

public void chartsTimelineIntroSnippet2() {
    RangeSelector rangeSelector = new RangeSelector();
    rangeSelector.setSelected(4);
    ButtonTheme theme = new ButtonTheme();
    Style style = new Style();
    style.setColor(new SolidColor("#0766d8"));
    style.setFontWeight(FontWeight.BOLD);
    theme.setStyle(style);
    rangeSelector.setButtonTheme(theme);
    Chart chart = new Chart();
    chart.setTimeline(true);
    Configuration configuration = chart.getConfiguration();
    configuration.setRangeSelector(rangeSelector);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) RangeSelector(com.vaadin.addon.charts.model.RangeSelector) Style(com.vaadin.addon.charts.model.style.Style) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) ButtonTheme(com.vaadin.addon.charts.model.style.ButtonTheme) Chart(com.vaadin.addon.charts.Chart)

Example 5 with ButtonTheme

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

the class ButtonThemeJSONSerializationTest method toJSON_widthIsNull_themeSerializedWithNullWidth.

@Test
public void toJSON_widthIsNull_themeSerializedWithNullWidth() {
    ButtonTheme buttonTheme = new ButtonTheme();
    buttonTheme.setWidth(null);
    String json = toJSON(buttonTheme);
    String expected = "{\"width\":null}";
    assertEquals(expected, json);
}
Also used : ButtonTheme(com.vaadin.addon.charts.model.style.ButtonTheme) Test(org.junit.Test)

Aggregations

ButtonTheme (com.vaadin.addon.charts.model.style.ButtonTheme)5 Test (org.junit.Test)3 Chart (com.vaadin.addon.charts.Chart)2 Configuration (com.vaadin.addon.charts.model.Configuration)2 RangeSelector (com.vaadin.addon.charts.model.RangeSelector)2 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)2 Style (com.vaadin.addon.charts.model.style.Style)2 StockPrices (com.vaadin.addon.charts.examples.timeline.util.StockPrices)1 DataSeries (com.vaadin.addon.charts.model.DataSeries)1 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)1 PlotLine (com.vaadin.addon.charts.model.PlotLine)1 YAxis (com.vaadin.addon.charts.model.YAxis)1