如何在Primefaces图表中更改颜色? [英] How to change colors in Primefaces chart?

查看:184
本文介绍了如何在Primefaces图表中更改颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对如何改进此Primefaces图表有几个疑问.

I have several questions how to improve this Primefaces chart.

这是源代码:

<h:form>

<p:barChart id="basic" value="#{DashboardController.categoryModel}" legendPosition="ne"  
            title="Accounts and Groups" min="0" max="200" style="height:400px"
            shadow="true" barPadding="60"/>  

</h:form>

import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.ChartSeries;

@Named("DashboardController")
@SessionScoped
public class Dashboard implements Serializable
{

    /*
     * Call the Oracle JDBC Connection driver
     */
    @Resource(name = "jdbc/Oracle")
    private DataSource ds;
    private CartesianChartModel categoryModel;

    public Dashboard()
    {
        createCategoryModel();
    }

    public CartesianChartModel getCategoryModel()
    {
        return categoryModel;
    }

    private void createCategoryModel()
    {
        categoryModel = new CartesianChartModel();

        // Active Accounts

        ChartSeries ActiveAccounts = new ChartSeries();
        ActiveAccounts.setLabel("Active Accounts");

        ActiveAccounts.set("Active Accounts", 120);

        categoryModel.addSeries(ActiveAccounts);

        // Blocked Accounts

        ChartSeries BlockedAccounts = new ChartSeries();
        BlockedAccounts.setLabel("Blocked Accounts");

        BlockedAccounts.set("Blocked Accounts", 120);

        categoryModel.addSeries(BlockedAccounts);

        // Active Groups

        ChartSeries ActiveGroups = new ChartSeries();
        ActiveGroups.setLabel("Active Groups");

        ActiveGroups.set("Active Groups", 120);

        categoryModel.addSeries(ActiveGroups);

        // Blocked Groups

        ChartSeries BlockedGroups = new ChartSeries();
        BlockedGroups.setLabel("Blocked Groups");

        BlockedGroups.set("Blocked Groups", 120);

        categoryModel.addSeries(BlockedGroups);



    }
}

您能告诉我如何更改图表大小的颜色以及帐户和组"的颜色吗? 我还想问你如何在每列下面添加名称?现在,我只有一个名称活动帐户".我想分别命名列.

Can you tell me how I can change the color of the chart size, also the color of "Accounts and Groups"? I also want to ask you how I can add names below every column? Now I have only one name "Active Accounts". I want to name the columns individually.

最美好的祝愿

P.S,我将此代码测试到了JSF标头中,但无法正常工作:

P.S I tested this code into the JSF header but it's not working:

<script type="text/css">
        .jqplot-title{
        color:red;
        }
    </script>

P.S 2仅更改图表的标签

P.S 2 Only the label of the chart is changed

推荐答案

使用<p:barChart

像这样seriesColors="000000, FFFFFF, 2288AA"

关于标题和轴的颜色,使用此:

about the title and the axis color, use this:

.jqplot-title{
    color: #FF0000;
}
.jqplot-xaxis-label{
    color: #FF0000; 
}
.jqplot-yaxis-label{
    color: #FF0000;
}

这篇关于如何在Primefaces图表中更改颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆