-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am trying to combine the two different series into a single chart. Is there a way to do it?
All my dataset are coming directly from a database.
Normally, I can just set chart.setModel(getData.getXYModel), but Series does not support setModel function.
Series ensembleSeries = new Series();
ensembleSeries.setType("spline");
ensembleSeries.setData(getData.getXYModel()); <-- Error here: does not support setModel()
Series boxplotSeries = new Series();
boxplotSeries.setType("boxplot");
boxplotSeries.setData(getData.getBoxplotModel()); <-- error here: does not support setModel()
chart.addSeries(ensembleSeries);
chart.addSeries(boxplotSeries);
Thanks for any info.
The different ChartModels are only useful to manage a chart with the same series. For charts with different series you have to add the Point
objects directly.
The setData
method has several overloaded versions. In the example below I used setData(Point... data)
...
chart.setTitle("boxplot with datetime axis");
chart.getXAxis().setType("datetime");
Series ensembleSeries = new Series();
ensembleSeries.setType("spline");
ensembleSeries.setData(splineData());
Series boxPlotSeries = new Series();
boxPlotSeries.setType("boxplot");
boxPlotSeries.setData(boxplotData());
chart.addSeries(ensembleSeries);
chart.addSeries(boxPlotSeries);
...
private Point[] splineData() {
Point[] data = new Point[5];
data[0] = new Point(date(-8), 35);
data[1] = new Point(date(-4), 34);
data[2] = new Point(date(0), 30);
data[3] = new Point(date(2), 25);
data[4] = new Point(date(4), 15);
return data;
}
private Point[] boxplotData() {
Point[] data = new Point[6];
data[0] = boxPlotPoint(date(-8), 12, 22, 35, 48, 56);
data[1] = boxPlotPoint(date(-5), 12, 22, 35, 48, 56);
data[2] = boxPlotPoint(date(-3), 12, 22, 35, 48, 56);
data[3] = boxPlotPoint(date(-2), 12, 22, 35, 48, 56);
data[4] = boxPlotPoint(date(-1), 13, 23, 37, 41, 43);
data[5] = boxPlotPoint(date(0), 10, 20, 30, 40, 50);
return data;
}
private Point boxPlotPoint(Number datetime,
Number low, Number q1, Number med, Number q3, Number high) {
Point p = new Point();
p.setX(datetime);
p.setHigh(low);
p.setQ1(q1);
p.setMedian(med);
p.setQ3(q3);
p.setLow(high);
return p;
}
private long date(int dayOffset) {
return LocalDateTime.now().plusDays(dayOffset).toInstant(ZoneOffset.UTC).toEpochMilli();
}
}
Asked: 2020-09-25 14:10:12 +0800
Seen: 9 times
Last updated: Sep 28 '20
ZK Long operation with hibernate issue
[Announcement] ZK 8.6 Introductory Session Open for Registration
how to set the global font-size
I configured iceblue_c theme, but it did not work. Please advise. Thank you
request hot fix for CE version for issue ZK-4127
Can you set min-width for columns in the grid that identify hflex=1?