use of com.vaadin.addon.charts.model.YAxis in project charts by vaadin.
the class BasicLineWithDataLabels method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.LINE);
configuration.getTitle().setText("Monthly Average Temperature");
configuration.getSubTitle().setText("Source: WorldClimate.com");
configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Temperature (°C)"));
configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
PlotOptionsLine plotOptions = new PlotOptionsLine();
plotOptions.setDataLabels(new DataLabels(true));
plotOptions.setEnableMouseTracking(false);
configuration.setPlotOptions(plotOptions);
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("London");
ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
configuration.addSeries(ls);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.YAxis 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.YAxis in project charts by vaadin.
the class ChartTypes method chartTypesSolidGaugeAxisSnippet1.
public void chartTypesSolidGaugeAxisSnippet1() {
YAxis yaxis = new YAxis();
yaxis.setTitle("Pressure GPa");
// Move 70 px upwards from center
yaxis.getTitle().setY(-80);
// The limits are mandatory
yaxis.setMin(0);
yaxis.setMax(200);
// Configure ticks and labels
// At 0, 100, and 200
yaxis.setTickInterval(100);
// Move 16 px upwards
yaxis.getLabels().setY(-16);
// Disable grid
yaxis.setGridLineWidth(0);
}
use of com.vaadin.addon.charts.model.YAxis in project charts by vaadin.
the class StopJSONSerializationTest method toJSON_axisWithStops_StopsCorrectlySerialized.
@Test
public void toJSON_axisWithStops_StopsCorrectlySerialized() {
YAxis yaxis = new YAxis();
Stop stop1 = new Stop(0.1f, SolidColor.GREEN);
Stop stop2 = new Stop(0.5f, SolidColor.YELLOW);
Stop stop3 = new Stop(0.9f, SolidColor.RED);
yaxis.setStops(stop1, stop2, stop3);
// stops array should look like this
// stops: [
// [0.1, '#55BF3B'], // green
// [0.5, '#DDDF0D'], // yellow
// [0.9, '#DF5353'] // red
// ]
String expected = "{\"stops\":[[0.1,\"#008000\"],[0.5,\"#FFFF00\"],[0.9,\"#FF0000\"]]}";
assertEquals(expected, toJSON(yaxis));
}
use of com.vaadin.addon.charts.model.YAxis in project charts by vaadin.
the class TimeUnitMultiplesJSONSerializationTest method toJSON_axisWithUnits_TimeUnitMultiplesCorrectlySerialized.
@Test
public void toJSON_axisWithUnits_TimeUnitMultiplesCorrectlySerialized() {
YAxis yaxis = new YAxis();
TimeUnitMultiples unitMillisecond = new TimeUnitMultiples(TimeUnit.MILLISECOND, 1, 2, 5, 10, 20, 25, 50, 100, 200, 500);
TimeUnitMultiples unitSecond = new TimeUnitMultiples(TimeUnit.SECOND, 1, 2, 5, 10, 15, 30);
TimeUnitMultiples unitMinute = new TimeUnitMultiples(TimeUnit.MINUTE, 1, 2, 5, 10, 15, 30);
TimeUnitMultiples unitHour = new TimeUnitMultiples(TimeUnit.HOUR, 1, 2, 3, 4, 6, 8, 12);
TimeUnitMultiples unitDay = new TimeUnitMultiples(TimeUnit.DAY, 1);
TimeUnitMultiples unitWeek = new TimeUnitMultiples(TimeUnit.WEEK, 1);
TimeUnitMultiples unitMonth = new TimeUnitMultiples(TimeUnit.MONTH, 1, 3, 6);
TimeUnitMultiples unitYear = new TimeUnitMultiples(TimeUnit.YEAR, null);
yaxis.setUnits(unitMillisecond, unitSecond, unitMinute, unitHour, unitDay, unitWeek, unitMonth, unitYear);
// units array should look like this
// units: [
// ['millisecond', [1, 2, 5, 10, 20, 25, 50, 100, 200, 500]],
// ['second', [1, 2, 5, 10, 15, 30]],
// ['minute',[1, 2, 5, 10, 15, 30]],
// ['hour',[1, 2, 3, 4, 6, 8, 12]],
// ['day',[1]],
// ['week',[1]],
// ['month',[1, 3, 6]],
// ['year',null]
// ]
String expected = "{\"units\":[[\"millisecond\",[1,2,5,10,20,25,50,100,200,500]],[\"second\",[1,2,5,10,15,30]],[\"minute\",[1,2,5,10,15,30]],[\"hour\",[1,2,3,4,6,8,12]],[\"day\",[1]],[\"week\",[1]],[\"month\",[1,3,6]],[\"year\",null]]}";
assertEquals(expected, toJSON(yaxis));
}
Aggregations