com.google.gwt.core.client.JsArrayMixed Java Examples
The following examples show how to use
com.google.gwt.core.client.JsArrayMixed.
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: MaterialComboCharts.java From gwt-material-demo with Apache License 2.0 | 6 votes |
private void draw() { JsArrayMixed dataArray = JsonUtils .unsafeEval("[['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua Guinea', 'Rwanda', 'Average'],['2004/05', 165, 938, 522, 998, 450, 614.6],['2005/06', 135, 1120, 599, 1268, 288, 682],['2006/07', 157, 1167, 587, 807, 397, 623],['2007/08', 139, 1110, 615, 968, 215, 609.4],['2008/09', 136, 691, 629, 1026, 366, 569.6]]"); // Prepare the data DataTable dataTable = ChartHelper.arrayToDataTable(dataArray); // Set options ComboChartOptions options = ComboChartOptions.create(); options.setFontName("Tahoma"); options.setTitle("Monthly Coffee Production by Country"); options.setHAxis(HAxis.create("Cups")); options.setVAxis(VAxis.create("Month")); options.setSeriesType(SeriesType.BARS); ComboChartSeries series = ComboChartSeries.create(); series.setType(SeriesType.LINE); options.setSeries(5, series); // Draw the chart chart.draw(dataTable, options); }
Example #2
Source File: MaterialCandleStick.java From gwt-material-demo with Apache License 2.0 | 6 votes |
private void draw() { JsArrayMixed dataArray = JsonUtils.unsafeEval("[['Mon',20,28,38,45],['Tue',31,38,55,66],['Wed',50,55,77,80],['Thu',77,77,66,50],['Fri',68,66,22,15]]"); // Prepare the data DataTable dataTable = ChartHelper.arrayToDataTable(dataArray, true); // Set options CandlestickChartOptions options = CandlestickChartOptions.create(); BackgroundColor bgColor = BackgroundColor.create(); bgColor.setStroke("#2196f3"); bgColor.setFill("#90caf9"); bgColor.setStrokeWidth(2); options.setLegend(Legend.create(LegendPosition.NONE)); options.setFallingColor(bgColor); options.setRisingColor(bgColor); // Draw the chart chart.draw(dataTable, options); }
Example #3
Source File: SummernoteOptions.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
/** * Builds the toolbar. * * @param toolbarGroups * @return */ static final native JsArrayMixed buildToolbar(JsArrayMixed... toolbarGroups) /*-{ var arr = []; for (var i = 0; i < toolbarGroups.length; i++) { arr.push(toolbarGroups[i]); } return arr; }-*/;
Example #4
Source File: SummernoteOptions.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
/** * Creates a new toolbar group. * * @param name * @param buttons * @return */ static final JsArrayMixed newToolbarGroup(String name, ToolbarButton... buttons) { JsArrayString arr = JavaScriptObject.createArray().cast(); for (ToolbarButton button : buttons) { arr.push(button.getId()); } return getToolbarGroup(name, arr); }
Example #5
Source File: AbstractJsonReaderTest.java From gwt-jackson with Apache License 2.0 | 5 votes |
public void testNextJavaScriptObjectNoRootArray() { // safeEval JsonReader reader = newJsonReader( " {\"name\":\"wrapper\",\"jso\": [\"Bob\",\"Morane\", true, null, 145] } " ); reader.beginObject(); assertEquals( "name", reader.nextName() ); assertEquals( "wrapper", reader.nextString() ); assertEquals( "jso", reader.nextName() ); JsArrayMixed array = reader.nextJavaScriptObject( true ).cast(); assertEquals( 5, array.length() ); assertEquals( "Bob", array.getString( 0 ) ); assertEquals( "Morane", array.getString( 1 ) ); assertTrue( array.getBoolean( 2 ) ); assertNull( array.getObject( 3 ) ); assertEquals( 145d, array.getNumber( 4 ) ); reader.endObject(); assertEquals( JsonToken.END_DOCUMENT, reader.peek() ); // unsafeEval reader = newJsonReader( " {\"jso\": [\"Bob\",\"Morane\", true, 145] ,\"name\":\"wrapper\" } " ); reader.beginObject(); assertEquals( "jso", reader.nextName() ); array = reader.nextJavaScriptObject( false ).cast(); assertEquals( 4, array.length() ); assertEquals( "Bob", array.getString( 0 ) ); assertEquals( "Morane", array.getString( 1 ) ); assertTrue( array.getBoolean( 2 ) ); assertEquals( 145d, array.getNumber( 3 ) ); assertEquals( "name", reader.nextName() ); assertEquals( "wrapper", reader.nextString() ); reader.endObject(); assertEquals( JsonToken.END_DOCUMENT, reader.peek() ); }
Example #6
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 #7
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; }
Example #8
Source File: Series.java From lumongo with Apache License 2.0 | 4 votes |
public final native Series setData(JsArrayMixed data)/*-{ this.data = data; }-*/;
Example #9
Source File: Series.java From lumongo with Apache License 2.0 | 4 votes |
public final native JsArrayMixed getData() /*-{ return this.data; }-*/;
Example #10
Source File: Series.java From lumongo with Apache License 2.0 | 4 votes |
public final native Series setMapData(JsArrayMixed mapData)/*-{ this.mapData = mapData; }-*/;
Example #11
Source File: AreaChartData.java From lumongo with Apache License 2.0 | 4 votes |
public final native AreaChartData setData(JsArrayMixed data) /*-{ this.data = data; return this; }-*/;
Example #12
Source File: HighchartsOptions.java From lumongo with Apache License 2.0 | 4 votes |
public final native HighchartsOptions setSeries(JsArrayMixed series) /*-{ this.series = series; }-*/;
Example #13
Source File: HighchartsOptions.java From lumongo with Apache License 2.0 | 4 votes |
public final native JsArrayMixed getSeries() /*-{ return this.series; }-*/;
Example #14
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 #15
Source File: Toolbar.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
JsArrayMixed build() { return SummernoteOptions.buildToolbar(groups.toArray(new JsArrayMixed[0])); }
Example #16
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 #17
Source File: SummernoteOptions.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
private static final native JsArrayMixed getToolbarGroup(String name, JsArrayString buttons) /*-{ return [name, buttons]; }-*/;
Example #18
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; }