use of com.vaadin.addon.charts.model.Labels in project charts by vaadin.
the class ChartConfiguration method labelsSnippet4.
public void labelsSnippet4(XAxis xaxis) {
Labels xlabels = xaxis.getLabels();
Style xlabelsstyle = new Style();
xlabelsstyle.setColor(SolidColor.GREEN);
xlabels.setStyle(xlabelsstyle);
}
use of com.vaadin.addon.charts.model.Labels in project charts by vaadin.
the class LabelsJSONSerializationTest method toJSON_autoRotationLimitIsSet_labelsSerializedWithAutoRotationLimit.
@Test
public void toJSON_autoRotationLimitIsSet_labelsSerializedWithAutoRotationLimit() throws IOException {
Labels labels = new Labels(true);
labels.setAutoRotationLimit(40);
ObjectMapper om = ChartSerialization.createObjectMapper();
String json = toJSON(labels);
Labels fromJson = om.readValue(json, Labels.class);
assertEquals(40, fromJson.getAutoRotationLimit());
}
use of com.vaadin.addon.charts.model.Labels in project charts by vaadin.
the class Sparkline method configureYAxis.
protected void configureYAxis(YAxis axis) {
axis.setLineWidth(0);
axis.setMinorGridLineWidth(0);
axis.setMinorTickLength(0);
axis.setMinorTickWidth(0);
axis.setGridLineWidth(0);
axis.setMaxPadding(0.1);
axis.setMinPadding(0.1);
axis.setLabels(new Labels(false));
axis.setLineColor(new SolidColor(0, 0, 0, 0));
axis.setTitle("");
axis.setStartOnTick(false);
axis.setEndOnTick(false);
}
use of com.vaadin.addon.charts.model.Labels in project charts by vaadin.
the class SplineInverted method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setWidth("500px");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getChart().setInverted(true);
configuration.getTitle().setText("Atmosphere Temperature by Altitude");
configuration.getSubTitle().setText("According to the Standard Atmosphere Model");
XAxis xAxis = configuration.getxAxis();
xAxis.setReversed(false);
xAxis.setTitle(new AxisTitle("Altitude"));
Labels labels = new Labels();
labels.setFormatter("this.value + 'km'");
labels.setEnabled(true);
xAxis.setLabels(labels);
xAxis.setMaxPadding(0.05);
xAxis.setShowLastLabel(true);
YAxis yAxis = configuration.getyAxis();
yAxis.setLineWidth(2);
yAxis.setTitle(new AxisTitle("Temperature"));
yAxis.getTitle().setAlign(VerticalAlign.MIDDLE);
Labels labelsy = new Labels();
labelsy.setEnabled(true);
labelsy.setFormatter("this.value + '°'");
yAxis.setLabels(labelsy);
configuration.getTooltip().setFormatter("this.x +' km: '+this.y +'°C'");
PlotOptionsSpline plotOptions = new PlotOptionsSpline();
plotOptions.setMarker(new Marker(true));
configuration.setPlotOptions(plotOptions);
Legend legend = configuration.getLegend();
legend.setEnabled(false);
DataSeries series = new DataSeries();
series.setPlotOptions(new PlotOptionsSpline());
series.setName("Temperature");
series.addData(new Number[][] { { 0, 15 }, { 10, -50 }, { 20, -56.5 }, { 30, -46.5 }, { 40, -22.1 }, { 50, -2.5 }, { 60, -27.7 }, { 70, -55.7 }, { 80, -76.5 } });
configuration.setSeries(series);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.Labels in project charts by vaadin.
the class GaugeWithDualAxes method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setWidth("500px");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.GAUGE);
configuration.getChart().setAlignTicks(false);
configuration.getChart().setPlotBackgroundColor(null);
configuration.getChart().setPlotBackgroundImage(null);
configuration.getChart().setPlotBorderWidth(0);
configuration.getChart().setPlotShadow(false);
configuration.setTitle("Speedometer with dual axes");
configuration.getPane().setStartAngle(-150);
configuration.getPane().setEndAngle(150);
YAxis yAxis = new YAxis();
yAxis.setMin(0);
yAxis.setMax(200);
yAxis.setLineColor(new SolidColor("#339"));
yAxis.setTickColor(new SolidColor("#339"));
yAxis.setMinorTickColor(new SolidColor("#339"));
yAxis.setOffset(-25);
yAxis.setLineWidth(2);
Labels labels = new Labels();
labels.setDistance(-20);
labels.setRotationPerpendicular();
labels.setRotation("auto");
yAxis.setLabels(labels);
yAxis.setTickLength(5);
yAxis.setMinorTickLength(5);
yAxis.setEndOnTick(false);
YAxis yAxis2 = new YAxis();
yAxis2.setMin(0);
yAxis2.setMax(124);
yAxis2.setLineColor(new SolidColor("#933"));
yAxis2.setTickColor(new SolidColor("#933"));
yAxis2.setMinorTickColor(new SolidColor("#933"));
yAxis2.setOffset(-20);
yAxis2.setLineWidth(2);
labels = new Labels();
labels.setDistance(12);
labels.setRotationPerpendicular();
yAxis2.setLabels(labels);
yAxis2.setTickLength(5);
yAxis2.setMinorTickLength(5);
yAxis2.setEndOnTick(false);
yAxis2.setTickPosition(TickPosition.OUTSIDE);
yAxis2.setMinorTickPosition(TickPosition.OUTSIDE);
configuration.addyAxis(yAxis);
configuration.addyAxis(yAxis2);
final ListSeries series = new ListSeries("Speed", 80);
PlotOptionsGauge plotOptionsGauge = new PlotOptionsGauge();
plotOptionsGauge.setDataLabels(new DataLabels());
plotOptionsGauge.getDataLabels().setFormatter("function() {return '<span style=\"color:#339\">'+ this.y + ' km/h</span><br/>' + '<span style=\"color:#933\">' + Math.round(this.y * 0.621) + ' mph</span>';}");
GradientColor gradient = GradientColor.createLinear(0, 0, 0, 1);
gradient.addColorStop(0, new SolidColor("#DDD"));
gradient.addColorStop(1, new SolidColor("#FFF"));
plotOptionsGauge.getDataLabels().setBackgroundColor(gradient);
plotOptionsGauge.setTooltip(new SeriesTooltip());
plotOptionsGauge.getTooltip().setValueSuffix(" km/h");
series.setPlotOptions(plotOptionsGauge);
configuration.setSeries(series);
runWhileAttached(chart, new Runnable() {
Random r = new Random(0);
@Override
public void run() {
Integer oldValue = series.getData()[0].intValue();
Integer newValue = (int) (oldValue + (r.nextDouble() - 0.5) * 20.0);
series.updatePoint(0, newValue);
}
}, 5000, 12000);
chart.drawChart(configuration);
return chart;
}
Aggregations