Jump to content
JChartFX Community
  • 0

How can we give the user preferred color to the 3Dcharts.


guruvaarun

Question

4 answers to this question

Recommended Posts

  • 0

From the json user gives the color to the individual bars such as

[

                                { "Sales": 2,"Month":"Jan","color":"#000000"},

                                { "Sales": 2,"Month":"Feb" ,"color":"#0afbaf"},

                                { "Sales": 5, "Month": "Mar" ,"color":"#c0f0f0"},

                                { "Sales": 1, "Month": "Apr" ,"color":"#d0f0d0"},

                                { "Sales": 8, "Month": "May" ,"color":"#aaaaaa"},

                                { "Sales": 5, "Month": "Jun" ,"color":"#110101"},

                    ]

 

by using the setcolor() method i can able to change the default color to user specified color. But in the legends i am getting the default color and single value only displayed init.

for more details see this example. http://jsfiddle.net/Fe3Qt/

Link to comment
Share on other sites

  • 0

You need 2 things,

- Use the setMultipleColors so that we know the chart will be displayed one color per point, note that as soon as you do this and even if you do not set your own colors, each point will use a different color.

this.chart.getAllSeries().setMultipleColors(true);

-  Change the index of the series from 0 to -1 inside the loop where you set the colors for each bar, this tells us that the particular attribute applies to all series (in case there is more than 1) so it will appear in the legend box

this.chart.getPoints().getItem(-1,i).setColor(this.config.items.color); 

Regards,

JuanC 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...