簡體   English   中英

如何在Primefaces圖表中更改顏色?

[英]How to change colors in Primefaces chart?

我有幾個問題如何改進這個Primefaces圖表。

在此輸入圖像描述

這是源代碼:

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



    }
}

你能告訴我如何更改圖表大小的顏色,以及“帳戶和組”的顏色嗎? 我還想問你如何在每一列下面添加名字? 現在我只有一個名字“Active Accounts”。 我想單獨命名列。

最好的祝願

PS我在JSF標題中測試了這段代碼,但是它無效:

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

PS 2僅更改圖表的標簽

在此輸入圖像描述

使用seriesColors的屬性<p:barChart

喜歡這個seriesColors="000000, FFFFFF, 2288AA"

關於標題和軸顏色,使用此:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM