Primefaces (Line)ChartModel define Linecolor

UI Components for JSF
Post Reply
JayJay
Posts: 9
Joined: 27 Mar 2013, 11:24

19 Jan 2017, 13:28

Hello,


I will combine a "SelectManyCheckbox" with a LineCharModel.
If a checkbox is activated, a line will be shown in the chart. Thats no problem!

But the linecolor depends on the order of my series.


question/example: is it possible, so set seriesX in the bean always to blue and seriesY always to red?


Primefaces 6.0


JayJay

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

19 Jan 2017, 16:14

First check if you can set the color n the model. If that is not possible, Check how to do that in jQPlot (what PF charts is based upon). Then use the extender function to set it like jqplot wants it.

leander
Posts: 2
Joined: 02 Sep 2015, 17:41

22 Jan 2017, 08:39

ChartModel provides method: public void setSeriesColors(String seriesColors),
You can set the seriesColors dynamically base on the checked items.
just like:

Code: Select all

Map<String,String> colors = new HashMap<String,String>();
colors.put("seriesX", "00008B");
colors.put("seriesY", "8A2BE2");
colors.put(....

String seriesColors = "";
for(String item : checkedItems){
	seriesColors+=colors.get(item)+",";
}
...
chartDataModel.setSeriesColors(seriesColors)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 65 guests