Search code examples
cssjsfprimefacesjqplot

How to change the colour of primfaces Axis?


How can I change the colour of primefaces Axis? I don't see any default colour and I have no idea how to change it.

    public LineChartModel getLineChartModel() {
    LineChartModel model = new LineChartModel();
    model.addSeries(getData());;
    model.setTitle(televotingQuestion.getQuestion());
    model.setSeriesColors("black");
    Axis yAxis = model.getAxis(AxisType.Y);
    yAxis.setMin(0);
    yAxis.setTickInterval("1");
    yAxis.setLabel("Anzahl");
    Axis xAxis = model.getAxis(AxisType.X);
    xAxis.setMin(televotingQuestion.getMinValue());
    xAxis.setMax(televotingQuestion.getMaxValue());
    xAxis.setTickInterval("100");
    return model;
}
<p:chart id="votes" type="line" model="#{televotingNumericManagementBean.lineChartModel}" style="height:700px;"/>

Solution

  • my extender:

    <script>
    
            function colorAxes() {
                this.cfg.axes.yaxis.tickOptions = {
                    textColor : '#ffffff'
                };
                this.cfg.axes.yaxis.labelOptions  = {
                    textColor : '#ffffff'
                };
                this.cfg.axes.xaxis.tickOptions = {
                    textColor: '#ffffff'
                };
            }
        </script>
    

    and that's how I used it in my bean:

      LineChartModel model = new LineChartModel();
        model.addSeries(getData());;
        model.setTitle(televotingQuestion.getQuestion());
        model.setSeriesColors("black");
        model.setExtender("colorAxes");