Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change line colors in primefaces 5.1 line chart

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?

like image 295
user3114967 Avatar asked Dec 25 '22 18:12

user3114967


1 Answers

i suggest reading jqplot documentation

java code

lineModel.setSeriesColors("58BA27,FFCC33,F74A4A,F52F2F,A30303");
lineModel.setExtender("chartExtender");
like image 136
Ömer Faruk Kurt Avatar answered Dec 29 '22 12:12

Ömer Faruk Kurt