Search in sources :

Example 11 with XYseries

use of org.dussan.vaadin.dcharts.base.elements.XYseries in project cia by Hack23.

the class PoliticianDataManagerImpl method createPersonLineChart.

@Override
public void createPersonLineChart(final AbstractOrderedLayout content, final String personId) {
    final List<ViewRiksdagenVoteDataBallotPoliticianSummaryDaily> list = dataChartManager.findByValue(personId);
    final Series series = new Series().addSeries(new XYseries().setLabel(WON)).addSeries(new XYseries().setLabel(PARTY_REBEL)).addSeries(new XYseries().setLabel(ABSENT)).addSeries(new XYseries().setLabel(NUMBER_BALLOTS));
    final DataSeries dataSeries = new DataSeries().newSeries();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    if (list != null) {
        addPoliticianIndicatorData(list, dataSeries, simpleDateFormat);
    }
    addChart(content, "Ballot indicators", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsPersonLineChart(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) DCharts(org.dussan.vaadin.dcharts.DCharts) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) ViewRiksdagenVoteDataBallotPoliticianSummaryDaily(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily) SimpleDateFormat(java.text.SimpleDateFormat)

Example 12 with XYseries

use of org.dussan.vaadin.dcharts.base.elements.XYseries in project cia by Hack23.

the class AdminChartDataManagerImpl method createApplicationActionEventPageModeDailySummaryChart.

@Override
public void createApplicationActionEventPageModeDailySummaryChart(final AbstractOrderedLayout content, final String page) {
    final Map<String, List<ViewApplicationActionEventPageModeDailySummary>> map = getApplicationActionEventPageModeDailySummaryMap(page);
    final DataSeries dataSeries = new DataSeries();
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DD_MMM_YYYY, Locale.ENGLISH);
    final Series series = new Series();
    for (final Entry<String, List<ViewApplicationActionEventPageModeDailySummary>> entry : map.entrySet()) {
        if (entry.getKey() != null) {
            series.addSeries(new XYseries().setLabel(entry.getKey()));
            dataSeries.newSeries();
            final List<ViewApplicationActionEventPageModeDailySummary> list = entry.getValue();
            for (final ViewApplicationActionEventPageModeDailySummary item : list) {
                if (item != null) {
                    dataSeries.add(simpleDateFormat.format(item.getEmbeddedId().getCreatedDate()), item.getHits());
                }
            }
        }
    }
    addChart(content, "Page Action Events daily Summary", new DCharts().setDataSeries(dataSeries).setOptions(getChartOptions().createOptionsXYDateFloatLogYAxisLegendOutside(series)).show(), true);
}
Also used : DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) ViewApplicationActionEventPageModeDailySummary(com.hack23.cia.model.internal.application.data.impl.ViewApplicationActionEventPageModeDailySummary) List(java.util.List) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) DCharts(org.dussan.vaadin.dcharts.DCharts) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) SimpleDateFormat(java.text.SimpleDateFormat)

Example 13 with XYseries

use of org.dussan.vaadin.dcharts.base.elements.XYseries in project cia by Hack23.

the class ChartTest method addSerieTest.

/**
 * Adds the serie test.
 */
@Test
public void addSerieTest() {
    final XYseries label = new XYseriesFix();
    label.setLabel("sune");
    toJsonString(label);
    assertNotNull("Problem with toJsonString, no label", label);
}
Also used : XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) Test(org.junit.Test)

Example 14 with XYseries

use of org.dussan.vaadin.dcharts.base.elements.XYseries 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;
}
Also used : Options(org.dussan.vaadin.dcharts.options.Options) MarkerRenderer(org.dussan.vaadin.dcharts.base.renderers.MarkerRenderer) Legend(org.dussan.vaadin.dcharts.options.Legend) Ticks(org.dussan.vaadin.dcharts.data.Ticks) Label(com.vaadin.ui.Label) JsonNode(com.fasterxml.jackson.databind.JsonNode) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries) AxesDefaults(org.dussan.vaadin.dcharts.options.AxesDefaults) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Series(org.dussan.vaadin.dcharts.options.Series) SeriesDefaults(org.dussan.vaadin.dcharts.options.SeriesDefaults) GridLayout(com.vaadin.ui.GridLayout) DataSeries(org.dussan.vaadin.dcharts.data.DataSeries) Axes(org.dussan.vaadin.dcharts.options.Axes) DCharts(org.dussan.vaadin.dcharts.DCharts) Component(com.vaadin.ui.Component) XYaxis(org.dussan.vaadin.dcharts.base.elements.XYaxis) Highlighter(org.dussan.vaadin.dcharts.options.Highlighter)

Example 15 with XYseries

use of org.dussan.vaadin.dcharts.base.elements.XYseries in project cia by Hack23.

the class DecisionChartDataManagerImpl method addDecisionTypeByOrgData.

/**
 * Adds the decision type by org data.
 *
 * @param simpleDateFormat
 *            the simple date format
 * @param dataSeries
 *            the data series
 * @param series
 *            the series
 * @param map
 *            the map
 */
private static void addDecisionTypeByOrgData(final SimpleDateFormat simpleDateFormat, final DataSeries dataSeries, final Series series, final Map<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> map) {
    for (final Entry<String, List<ViewRiksdagenCommitteeDecisionTypeOrgDailySummary>> entry : map.entrySet()) {
        if (!EMPTY_STRING.equals(entry.getKey())) {
            final XYseries label = new XYseries();
            label.setLabel(entry.getKey());
            series.addSeries(label);
            dataSeries.newSeries();
            for (final ViewRiksdagenCommitteeDecisionTypeOrgDailySummary item : entry.getValue()) {
                if (item != null) {
                    dataSeries.add(simpleDateFormat.format(item.getEmbeddedId().getDecisionDate()), item.getTotal());
                }
            }
        }
    }
}
Also used : ViewRiksdagenCommitteeDecisionTypeOrgDailySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary) List(java.util.List) XYseries(org.dussan.vaadin.dcharts.base.elements.XYseries)

Aggregations

XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)19 DCharts (org.dussan.vaadin.dcharts.DCharts)13 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)13 Series (org.dussan.vaadin.dcharts.options.Series)13 List (java.util.List)11 SimpleDateFormat (java.text.SimpleDateFormat)9 ViewRiksdagenVoteDataBallotPartySummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummaryDaily)3 GovernmentBodyAnnualSummary (com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary)2 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Country (com.hack23.cia.model.external.worldbank.data.impl.Country)1 WorldBankData (com.hack23.cia.model.external.worldbank.data.impl.WorldBankData)1 ViewRiksdagenCommitteeDecisionTypeDailySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeDailySummary)1 ViewRiksdagenCommitteeDecisionTypeOrgDailySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionTypeOrgDailySummary)1 ViewRiksdagenVoteDataBallotPartySummary (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummary)1 ViewRiksdagenVoteDataBallotPoliticianSummaryDaily (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPoliticianSummaryDaily)1 ViewRiksdagenDocumentTypeDailySummary (com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenDocumentTypeDailySummary)1 ViewRiksdagenOrgDocumentDailySummary (com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenOrgDocumentDailySummary)1 ViewRiksdagenPartyDocumentDailySummary (com.hack23.cia.model.internal.application.data.document.impl.ViewRiksdagenPartyDocumentDailySummary)1