use of org.dussan.vaadin.dcharts.data.DataSeries in project cia by Hack23.
the class PartyDataSeriesFactoryImpl method createPartyChartTimeSeriesCurrent.
@Override
public DataSeries createPartyChartTimeSeriesCurrent() {
DataSeries dataSeries = new DataSeries();
final DataContainer<ViewRiksdagenPartySummary, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenPartySummary.class);
for (final ViewRiksdagenPartySummary data : dataContainer.getAllOrderBy(ViewRiksdagenPartySummary_.currentAssignments)) {
if (data != null && data.isActiveParliament()) {
dataSeries = dataSeries.newSeries().add(getPartyName(data.getParty()), data.getTotalActiveParliament());
}
}
return dataSeries;
}
use of org.dussan.vaadin.dcharts.data.DataSeries in project Activiti by Activiti.
the class ChartGenerator method createChart.
protected static Component createChart(JsonNode dataNode, String[] names, Number[] values) {
String type = dataNode.get("type").textValue();
JsonNode xAxisNode = dataNode.get("xaxis");
String xAxis = null;
if (xAxisNode != null) {
xAxis = xAxisNode.textValue();
}
JsonNode yAxisNode = dataNode.get("yaxis");
String yAxis = null;
if (yAxisNode != null) {
yAxis = yAxisNode.textValue();
}
Component chart = null;
if (CHART_TYPE_BAR_CHART.equals(type)) {
DataSeries dataSeries = new DataSeries().add((Object[]) values);
SeriesDefaults seriesDefaults = new SeriesDefaults().setRenderer(SeriesRenderers.BAR);
Axes axes = new Axes().addAxis(new XYaxis().setRenderer(AxisRenderers.CATEGORY).setTicks(new Ticks().add((Object[]) names)));
Highlighter highlighter = new Highlighter().setShow(false);
Options options = new Options().setSeriesDefaults(seriesDefaults).setAxes(axes).setHighlighter(highlighter);
options.setAnimate(true);
options.setAnimateReplot(true);
chart = new DCharts().setDataSeries(dataSeries).setOptions(options);
} else if (CHART_TYPE_PIE_CHART.equals(type)) {
DataSeries dataSeries = new DataSeries().newSeries();
for (int i = 0; i < names.length; i++) {
dataSeries.add(names[i], values[i]);
}
SeriesDefaults seriesDefaults = new SeriesDefaults().setRenderer(SeriesRenderers.PIE);
Options options = new Options().setSeriesDefaults(seriesDefaults);
options.setAnimate(true);
options.setAnimateReplot(true);
Legend legend = new Legend().setShow(true).setPlacement(LegendPlacements.INSIDE);
options.setLegend(legend);
Highlighter highlighter = new Highlighter().setShow(true);
options.setHighlighter(highlighter);
chart = new DCharts().setDataSeries(dataSeries).setOptions(options);
} else if (CHART_TYPE_LINE_CHART.equals(type)) {
AxesDefaults axesDefaults = new AxesDefaults().setLabelRenderer(LabelRenderers.CANVAS);
Axes axes = new Axes().addAxis(new XYaxis().setLabel(xAxis != null ? xAxis : "").setMin(names[0]).setMax(names[values.length - 1]).setDrawMajorTickMarks(true)).addAxis(new XYaxis(XYaxes.Y).setLabel(yAxis != null ? yAxis : "").setDrawMajorTickMarks(true));
Options options = new Options().setAxesDefaults(axesDefaults).setAxes(axes);
DataSeries dataSeries = new DataSeries().newSeries();
for (int i = 0; i < names.length; i++) {
// if (parseLong(names[i]) != null) {
// dataSeries.add(parseLong(names[i]), values[i]);
// } else if (parseDouble(names[i]) != null) {
// dataSeries.add(parseDouble(names[i]), values[i]);
// } else {
// dataSeries.add(names[i], values[i]);
// }
dataSeries.add(names[i], values[i]);
}
Series series = new Series().addSeries(new XYseries().setShowLine(true).setMarkerOptions(new MarkerRenderer().setShadow(true).setSize(7).setStyle(MarkerStyles.CIRCLE)));
options.setSeries(series);
options.setAnimate(true);
options.setAnimateReplot(true);
Highlighter highlighter = new Highlighter().setShow(true);
options.setHighlighter(highlighter);
chart = new DCharts().setDataSeries(dataSeries).setOptions(options);
} else if (CHART_TYPE_LIST.equals(type)) {
GridLayout grid = new GridLayout(2, names.length);
grid.setSpacing(true);
for (int i = 0; i < names.length; i++) {
String name = names[i];
Label nameLabel = new Label(name);
nameLabel.addStyleName(ExplorerLayout.STYLE_LABEL_BOLD);
grid.addComponent(nameLabel, 0, i);
Number value = values[i];
Label valueLabel = new Label(value + "");
grid.addComponent(valueLabel, 1, i);
}
chart = grid;
}
if (chart instanceof DCharts) {
// Needed, otherwise the chart will not be shown
((DCharts) chart).show();
}
return chart;
}
use of org.dussan.vaadin.dcharts.data.DataSeries in project cia by Hack23.
the class CommitteeDataSeriesFactoryImpl method createCommitteeChartTimeSeriesCurrent.
@Override
public DataSeries createCommitteeChartTimeSeriesCurrent() {
DataSeries dataSeries = new DataSeries();
final DataContainer<ViewRiksdagenCommittee, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenCommittee.class);
for (final ViewRiksdagenCommittee data : dataContainer.getAll()) {
if (data.isActive()) {
dataSeries = dataSeries.newSeries().add(data.getEmbeddedId().getDetail(), data.getCurrentMemberSize());
}
}
return dataSeries;
}
use of org.dussan.vaadin.dcharts.data.DataSeries in project cia by Hack23.
the class MinistryDataSeriesFactoryImpl method createChartTimeSeriesTotalDaysServedGovernmentByParty.
@Override
public DataSeries createChartTimeSeriesTotalDaysServedGovernmentByParty() {
DataSeries dataSeries = new DataSeries();
final DataContainer<ViewRiksdagenParty, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenParty.class);
final DataContainer<ViewRiksdagenPartySummary, String> partySummarydataContainer = applicationManager.getDataContainer(ViewRiksdagenPartySummary.class);
partySummarydataContainer.getAll();
for (final ViewRiksdagenParty data : dataContainer.getAll()) {
final ViewRiksdagenPartySummary summary = partySummarydataContainer.load(data.getPartyId());
if (summary != null && summary.isActive()) {
dataSeries = dataSeries.newSeries().add(data.getPartyName(), summary.getTotalDaysServedGovernment());
}
}
return dataSeries;
}
use of org.dussan.vaadin.dcharts.data.DataSeries in project cia by Hack23.
the class PartyDataSeriesFactoryImpl method createChartTimeSeriesCurrentCommitteeByParty.
@Override
public DataSeries createChartTimeSeriesCurrentCommitteeByParty() {
DataSeries dataSeries = new DataSeries();
final DataContainer<ViewRiksdagenParty, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenParty.class);
final DataContainer<ViewRiksdagenPartySummary, String> partySummarydataContainer = applicationManager.getDataContainer(ViewRiksdagenPartySummary.class);
partySummarydataContainer.getAll();
for (final ViewRiksdagenParty data : dataContainer.getAll()) {
final ViewRiksdagenPartySummary summary = partySummarydataContainer.load(data.getPartyId());
if (summary != null && summary.isActive()) {
dataSeries = dataSeries.newSeries().add(data.getPartyName(), summary.getTotalActiveCommittee());
}
}
return dataSeries;
}
Aggregations