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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations