Java Code Examples for com.google.gwt.core.client.JsArrayMixed#push()
The following examples show how to use
com.google.gwt.core.client.JsArrayMixed#push() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LineChart.java From lumongo with Apache License 2.0 | 4 votes |
public LineChart build() { HighchartsOptions options = HighchartsOptions.create(); ChartOptions chartOptions = ChartOptions.create(); chartOptions.setChartType(ChartType.LINE); options.setChart(chartOptions); JsArrayMixed seriesArray = JsArrayMixed.createArray().cast(); Series series = Series.create(); JsArrayMixed dataList = JsArrayMixed.createArray().cast(); for (String key : data.keySet()) { dataList.push((Integer) data.get(key)); } series.setData(dataList); series.setShowInLegend(false); seriesArray.push(series); options.setSeries(seriesArray); XAxisOptions xAxis = XAxisOptions.create(); xAxis.setCategories(data.keySet()); xAxis.setAllowDecimals(super.xAxisAllowDecimals); options.setXAxis(xAxis); YAxisOptions yAxis = YAxisOptions.create(); yAxis.setTitle(YAxisTitle.create().setText("Count")); yAxis.setMin(0); options.setYAxis(yAxis); yAxis.setAllowDecimals(super.yAxisAllowDecimals); if (null != colors) { options.setColors(colors); } options.setTitle(TitleOptions.create().setText(chartTitle)); options.setExporting(ExportingOptions.create()); options.getExporting().setURL(GWT.getHostPageBaseURL() + "highcharts/export"); options.getExporting().setFilename(chartTitle); options.getExporting().setEnabled(true); LineChart lc = new LineChart(height); if (null != handler) { PlotOptions plotOptions = PlotOptions.create(); SeriesOptions seriesOptions = SeriesOptions.create(); seriesOptions.setPoint(PointOptions.create().setEvents(SeriesEventOptions.create().setClick(lc))); seriesOptions.setCursor(CursorType.POINTER); plotOptions.setSeries(seriesOptions); options.setPlotOptions(plotOptions); lc.setSelectionHandler(handler); } lc.setHighchartOptions(options); lc.setDataSource(dataSource); return lc; }
Example 2
Source File: BarChart.java From lumongo with Apache License 2.0 | 4 votes |
@Override public Highcharts build() { HighchartsOptions options = HighchartsOptions.create(); ChartOptions chartOptions = ChartOptions.create(); chartOptions.setPanning(true); chartOptions.setPanKey("shift"); chartOptions.setChartType(ChartType.BAR); chartOptions.setZoomType(ZoomType.X); chartOptions.setHeight(null == height ? 320 : height); options.setChart(chartOptions); JsArrayMixed seriesArray = JsArrayMixed.createArray().cast(); Series series = Series.create(); JsArrayMixed dataList = JsArrayMixed.createArray().cast(); for (String key : data.keySet()) { dataList.push((Integer) data.get(key)); } series.setData(dataList); series.setShowInLegend(false); seriesArray.push(series); options.setSeries(seriesArray); XAxisOptions xAxis = XAxisOptions.create(); xAxis.setCategories(data.keySet()); xAxis.setAllowDecimals(false); options.setXAxis(xAxis); YAxisOptions yAxis = YAxisOptions.create(); yAxis.setTitle(YAxisTitle.create().setText("Count")); yAxis.setMin(0); yAxis.setAllowDecimals(super.yAxisAllowDecimals); options.setYAxis(yAxis); options.setTitle(TitleOptions.create().setText(chartTitle)); TooltipOptions tooltip = TooltipOptions.create(); tooltip.setFormatter((x, y, series1) -> x + ": " + y); options.setTooltip(tooltip); if (null != colors) { options.setColors(colors); } options.setExporting(ExportingOptions.create()); options.getExporting().setURL(GWT.getHostPageBaseURL() + "highcharts/export"); options.getExporting().setFilename(chartTitle); options.getExporting().setEnabled(true); BarChart chart = new BarChart(null == height ? 320 : height); if (null != handler) { PlotOptions plotOptions = PlotOptions.create(); SeriesOptions seriesOptions = SeriesOptions.create(); seriesOptions.setPoint(PointOptions.create().setEvents(SeriesEventOptions.create().setClick(chart))); seriesOptions.setCursor(CursorType.POINTER); plotOptions.setSeries(seriesOptions); options.setPlotOptions(plotOptions); chart.setSelectionHandler(handler); } chart.setHighchartOptions(options); chart.setDataSource(dataSource); return chart; }
Example 3
Source File: ColumnChart.java From lumongo with Apache License 2.0 | 4 votes |
public ColumnChart build() { HighchartsOptions options = HighchartsOptions.create(); ChartOptions chartOptions = ChartOptions.create(); //chartOptions.setPanning(true); //chartOptions.setPanKey("shift"); chartOptions.setChartType(ChartType.COLUMN); chartOptions.setZoomType(ZoomType.X); //chartOptions.setHeight(null == height ? 320 : height); options.setChart(chartOptions); TitleOptions titleOptions = TitleOptions.create(); titleOptions.setText(chartTitle); options.setTitle(titleOptions); if (null != colors) { options.setColors(colors); } LinkedHashSet<String> categories = new LinkedHashSet<>(); for (String key : data.keySet()) { for (String x : ((Map<String, Integer>) this.data.get(key)).keySet()) { categories.add(x); } } JsArrayMixed d = JsArrayMixed.createArray().cast(); for (String dataName : data.keySet()) { Series entry = Series.create(); entry.setName(dataName); JsArrayMixed entries = JsArrayMixed.createArray().cast(); for (String value : categories) { if (((Map<String, Integer>) data.get(dataName)).containsKey(value)) entries.push(((Map<String, Integer>) data.get(dataName)).get(value)); else entries.push(0); } entry.setData(entries); entry.setShowInLegend(true); d.push(entry); } options.setSeries(d); XAxisOptions xAxis = XAxisOptions.create(); xAxis.setCategories(categories); xAxis.setAllowDecimals(false); xAxis.setTitle(XAxisTitle.create().setText(xAxisLabel)); options.setXAxis(xAxis); YAxisOptions yAxis = YAxisOptions.create(); yAxis.setTitle(YAxisTitle.create().setText(yAxisLabel)); yAxis.setMin(0); yAxis.setAllowDecimals(false); options.setYAxis(yAxis); TooltipOptions tooltip = TooltipOptions.create(); //tooltip.setFormatter((x, y, series1) -> series1.getName() + " <br/> " + yAxisLabel + ": " + y); tooltip.setPointFormat("<span style=\"color:{point.color}\">\u25CF</span> {series.name}: <b>{point.y}</b><br/>"); options.setTooltip(tooltip); PlotOptions plotOptions = PlotOptions.create(); ColumnOptions columnOptions = ColumnOptions.create(); columnOptions.setMaxColumnWidth(100); plotOptions.setColumn(columnOptions); options.setPlotOptions(plotOptions); options.setExporting(ExportingOptions.create()); options.getExporting().setURL(GWT.getHostPageBaseURL() + "highcharts/export"); options.getExporting().setFilename(chartTitle); options.getExporting().setEnabled(true); ColumnChart cc = new ColumnChart(height); if (null != handler) { PointOptions po = PointOptions.create(); ColumnEventOptions ceo = ColumnEventOptions.create(); ceo.setClick(cc); po.setEvents(ceo); columnOptions.setPointOptions(po); cc.setHandler(handler); } cc.setHighchartOptions(options); cc.setDataSource(dataSource); return cc; }
Example 4
Source File: PieChart.java From lumongo with Apache License 2.0 | 4 votes |
public PieChart build() { HighchartsOptions options = HighchartsOptions.create(); ChartOptions chartOptions = ChartOptions.create(); chartOptions.setChartType(ChartType.PIE); options.setChart(chartOptions); JsArrayMixed seriesArray = JsArrayMixed.createArray().cast(); Series series = Series.create(); series.setName(chartTitle); JsArrayMixed dataList = JsArrayMixed.createArray().cast(); for (String key : data.keySet()) { //FIXME: There needs to be a limit to the number of entries in a pie chart. JsArrayMixed values = JsArrayMixed.createArray().cast(); values.push(key); values.push((Integer) data.get(key)); dataList.push(values); } series.setData(dataList); seriesArray.push(series); options.setSeries(seriesArray); options.setTitle(TitleOptions.create().setText(chartTitle)); if (null != colors && !colors.isEmpty()) { options.setColors(colors); } options.setExporting(ExportingOptions.create()); options.getExporting().setURL(GWT.getHostPageBaseURL() + "highcharts/export"); options.getExporting().setFilename(chartTitle); options.getExporting().setEnabled(true); PieChart chart = new PieChart(null == height ? 320 : height); if (null != handler) { PlotOptions plotOptions = PlotOptions.create(); PieOptions pieOptions = PieOptions.create(); pieOptions.setPoint(PointOptions.create().setEvents(PieEventOptions.create().setClick(chart))); pieOptions.setCursor(CursorType.POINTER); plotOptions.setPie(pieOptions); options.setPlotOptions(plotOptions); chart.setDataSelectionHandler(handler); } chart.setDataSource(dataSource); chart.setHighchartOptions(options); chart.setDataSource(dataSource); return chart; }
Example 5
Source File: AreaChart.java From lumongo with Apache License 2.0 | 4 votes |
@Override public Highcharts build() { HighchartsOptions options = HighchartsOptions.create(); ChartOptions chartOptions = ChartOptions.create(); chartOptions.setChartType(ChartType.AREA); options.setChart(chartOptions); XAxisOptions xAxis = XAxisOptions.create(); xAxis.setAllowDecimals(super.xAxisAllowDecimals); options.setXAxis(xAxis); YAxisOptions yAxis = YAxisOptions.create(); yAxis.setTitle(YAxisTitle.create().setText("Count")); yAxis.setMin(0); yAxis.setAllowDecimals(super.yAxisAllowDecimals); options.setYAxis(yAxis); options.setTitle(TitleOptions.create().setText(chartTitle)); TooltipOptions tooltip = TooltipOptions.create(); tooltip.setFormatter((x, y, series1) -> x + ": " + y); options.setTooltip(tooltip); if (null != colors) { options.setColors(colors); } options.setExporting(ExportingOptions.create()); options.getExporting().setURL(GWT.getHostPageBaseURL() + "highcharts/export"); options.getExporting().setFilename(chartTitle); options.getExporting().setEnabled(true); PlotOptions plotOptions = PlotOptions.create(); AreaOptions areaOptions = AreaOptions.create(); MarkerOptions markerOptions = MarkerOptions.create(); markerOptions.setEnabled(false); markerOptions.setSymbol("circle"); markerOptions.setRadius(2); areaOptions.setMarker(markerOptions); areaOptions.setPointStart(0.0); plotOptions.setArea(areaOptions); JsArrayMixed seriesArray = JsArrayMixed.createArray().cast(); Series series = Series.create(); JsArrayMixed dataList = JsArrayMixed.createArray().cast(); for (String key : data.keySet()) { AreaChartData areaData = AreaChartData.create(); areaData.setName(key); JsArrayMixed dataValues = JsArrayMixed.createArray().cast(); for (Double value : (List<Double>) data.get(key)) { dataValues.push(value); } areaData.setData(dataValues); seriesArray.push(areaData); } series.setData(dataList); series.setShowInLegend(false); //seriesArray.push(series); options.setSeries(seriesArray); options.setPlotOptions(plotOptions); AreaChart chart = new AreaChart(null == height ? 320 : height); if (null != handler) { SeriesOptions seriesOptions = SeriesOptions.create(); seriesOptions.setPoint(PointOptions.create().setEvents(SeriesEventOptions.create().setClick(chart))); seriesOptions.setCursor(CursorType.POINTER); plotOptions.setSeries(seriesOptions); options.setPlotOptions(plotOptions); chart.setSelectionHandler(handler); } chart.setHighchartOptions(options); chart.setDataSource(dataSource); return chart; }