我正在使用primefaces 5.1并试图创建折线图,它的工作正常。 但我想自定义背景颜色,网格,线条颜色。
我的XHTML:
<p:chart type="line" model="#{chartViewLine.lineModel1}" style="height:300px; width:570px;"/>
我的JAVA文件:
private LineChartModel lineModel1;
@PostConstruct
public void init() {
createLineModels();
}
public LineChartModel getLineModel1() {
return lineModel1;
}
private void createLineModels() {
lineModel1 = initLinearModel();
lineModel1.setLegendCols(3);
lineModel1.setLegendPosition("e");
Axis yAxis = lineModel1.getAxis(AxisType.Y);
yAxis.setMin(0);
yAxis.setMax(10);
}
private LineChartModel initLinearModel() {
LineChartModel model = new LineChartModel();
LineChartSeries series1 = new LineChartSeries();
series1.setLabel("Series 1");
series1.set(1, 2);
series1.set(2, 1);
series1.set(3, 3);
LineChartSeries series2 = new LineChartSeries();
series2.setLabel("Series 2");
series2.set(1, 6);
series2.set(2, 3);
series2.set(3, 2);
model.addSeries(series1);
model.addSeries(series2);
return model;
}
上面的代码工作正常,但我需要更改UI。我怎样才能做到这一点?