jsf - 如何更改 Primefaces 图表中的颜色?

标签 jsf jsf-2 primefaces

我有几个问题如何改进这个 Primefaces 图表。

enter image description here

这是源代码:

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



    }
}

你能告诉我如何更改图表大小的颜色,以及“账户和组”的颜色吗? 我还想问你如何在每列下面添加名称?现在我只有一个名字“活跃账户”。我想单独命名列。

祝愿

P.S 我在 JSF header 中测试了这段代码,但它不起作用:

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

P.S 2 只改变了图表的标签

enter image description here

最佳答案

使用 seriesColors <p:barChart 的属性

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

关于标题和坐标轴颜色,使用这个:

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

关于jsf - 如何更改 Primefaces 图表中的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11612558/

相关文章:

java - 从 rich :datatable binding table 获取行

java - p :fileUpload prime faces

java - JSF2 : inject service objects to managedbean from Spring?

jsf - PrimeFaces 3.3.1 p :dialog doesn't shows up. 错误:widgetVar 未定义

jsf - 持久化由 JSF 组件转换器创建的 EJB 实体时如何避免重复的 DB 内容?

javascript - "show more"<h :commandButton> with ajax

java - JPA - 注入(inject)或实例化自定义属性/对象以进行 JSF 写访问?

jsf - 带子表和多项选择的 Primefaces 数据表

css - Primefaces IE p :tree not expanding

javascript - f :ajax doesn't fire for onevent begin event