📅  最后修改于: 2023-12-03 15:15:27.440000             🧑  作者: Mango
GWT Highcharts是一个强大的图表库,它提供了丰富的图表类型,包括饼图。使用它,您可以将数据可视化为漂亮的饼图,以便更好地传达信息。
PieChart chart = new PieChart();
Series series = chart.createSeries()
.setName("Browser Share")
.addPoint("Firefox", 45.0)
.addPoint("IE", 26.8)
.addPoint("Chrome", 12.8)
.addPoint("Safari", 8.5)
.addPoint("Opera", 6.2);
chart.setSeries(series);
chart.setTitle("Browser market share, April, 2011");
chart.getTooltip()
.setFormatter(new TooltipFormatter() {
@Override
public String format(TooltipData tooltipData) {
return tooltipData.getPointName() + ": " + tooltipData.getYAsDouble() + "%";
}
});
chart.getPlotOptions().getPie()
.setAllowPointSelect(true)
.setCursor("pointer")
.setShowInLegend(true);
chart.getLegend().setLayout(LegendLayout.VERTICAL)
.setAlign(HorizontalAlign.RIGHT)
.setVerticalAlign(VerticalAlign.TOP)
.setX(-100)
.setY(100)
.setFloating(true);
chart.drawChart();
渲染的饼图如下:
<dependency>
<groupId>com.github.eltimn</groupId>
<artifactId>gwt-highcharts</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<inherits name='com.eltimn.highcharts.Highcharts'/>
PieChart chart = new PieChart();
Series series = chart.createSeries()
.setName("Browser Share")
.addPoint("Firefox", 45.0)
.addPoint("IE", 26.8)
.addPoint("Chrome", 12.8)
.addPoint("Safari", 8.5)
.addPoint("Opera", 6.2);
chart.setSeries(series);
chart.setTitle("Browser market share, April, 2011");
chart.getTooltip()
.setFormatter(new TooltipFormatter() {
@Override
public String format(TooltipData tooltipData) {
return tooltipData.getPointName() + ": " + tooltipData.getYAsDouble() + "%";
}
});
chart.getPlotOptions().getPie()
.setAllowPointSelect(true)
.setCursor("pointer")
.setShowInLegend(true);
chart.getLegend().setLayout(LegendLayout.VERTICAL)
.setAlign(HorizontalAlign.RIGHT)
.setVerticalAlign(VerticalAlign.TOP)
.setX(-100)
.setY(100)
.setFloating(true);
chart.drawChart();
GWT Highcharts是一个功能强大,易于使用的图表库,使用它可以轻松制作出漂亮的饼图。它允许用户定制每个图表的样式和功能,并提供了丰富的API和事件,以满足高级需求。如果您正在开发一个需要展示数据的web应用程序,GWT Highcharts是一个非常好的选择。