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