4

I'm using primefaces 5.1 and tried to create line chart,its working fine. But i want to customize the background color ,grids, line colors.

My XHTML:

<p:chart type="line" model="#{chartViewLine.lineModel1}" style="height:300px; width:570px;"/>

My JAVA file:

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;
}

The above code working fine but I need to change the UI. How can I achieve this?

user3114967
  • 639
  • 5
  • 15
  • 38

1 Answers1

10

i suggest reading jqplot documentation

java code

lineModel.setSeriesColors("58BA27,FFCC33,F74A4A,F52F2F,A30303");
lineModel.setExtender("chartExtender");
Ömer Faruk Kurt
  • 500
  • 3
  • 14