我正在使用 Vaadin 8 图表插件在 gridLayout 中创建仪表,如下面的快照所示。我试图删除图表和标题区域之间的多余间距,如红色突出显示。用于创建仪表的代码片段private Chart gauge(Number newValue, String tooltip) { final Chart chart = new Chart(); final Configuration configuration = chart.getConfiguration(); configuration.getChart().setType(ChartType.GAUGE); configuration.getChart().setAlignTicks(false); configuration.getChart().setWidth(200); configuration.getChart().setHeight(200); configuration.getChart().setSpacingTop(0); configuration.getTitle().setMargin(0); configuration.getChart().setPlotBackgroundColor(SolidColor.GREENYELLOW); configuration.getChart().setPlotBackgroundImage(null); configuration.getChart().setPlotBorderWidth(0); configuration.getChart().setPlotShadow(false); configuration.getChart().setBackgroundColor(null); configuration.getChart().setMarginTop(0); configuration.getChart().setMarginBottom(0); configuration.getPane().setStartAngle(-150); configuration.getPane().setEndAngle(150); YAxis yAxis = new YAxis(); // The limits are mandatory yAxis.setMin(0); yAxis.setMax(100); // Other configuration yAxis.getLabels().setStep(1); yAxis.setTickInterval(10); yAxis.setPlotBands(new PlotBand[] { new PlotBand(0, 40, SolidColor.GREEN), new PlotBand(40, 80, SolidColor.YELLOW), new PlotBand(80, 100, SolidColor.RED) }); configuration.addyAxis(yAxis); final ListSeries series = new ListSeries(tooltip, 80); PlotOptionsGauge plotOptionsGauge = new PlotOptionsGauge(); plotOptionsGauge.setDataLabels(new DataLabels()); // plotOptionsGauge.getDataLabels() // .setFormatter("function() {return '<span style=\"color:#339\">'+ // this.y + ' %</span>';}"); plotOptionsGauge.setTooltip(new SeriesTooltip()); plotOptionsGauge.getTooltip().setValueSuffix(" %"); series.setPlotOptions(plotOptionsGauge); configuration.setSeries(series); series.updatePoint(0, newValue); chart.drawChart(); return chart;}有关如何删除多余空间的任何指示???
添加回答
举报
0/150
提交
取消