0
votes

In my php page I have dropdown list of values..For every selection of the value I have to display a pie chart for the selected value.I used phplot.php to draw pie chart.

We have setDataColor() function to set colors or default colors.But Each value in the dropdown has same data,but different numbers.For example,

Dropdown values:student1,student2,student3

In database,

student1:**subj**   **marks**
          eng         10
          maths        0
          sci         30

student2: eng         20
          sci         40

student3: maths       50  

I want colors as eng-'red',maths-'green',sci-'blue'

If we use the phplot function (setDatacolor()) we can pass colors as array(red,green,blue).This would not give desire output for student2 and student3 pie charts,since it follows only order.

But I want every time maths would be green and sci is blue and so on.

Is there any way to do this?

1

1 Answers

0
votes

Do like below :

invoke the function on change of dropdown like below (dropdown value to be send)

var chart_data = getChartData( Student, EngMarks, mathsMarks, scienceMarks);
                var chart = new Highcharts.Chart( chart_data );

     xAxis : {  
             categories : [ 
                    'English',
                     'Maths', 
                     'Science', 
                  ] },

     series : [ {                       type : 'pie',
                                        name : Student,
                                        data : [ 

                                                {
                                                    name : 'English',
                                                    y : EngMarks,
                                                    color : 'Red'
                                                },
                                                {
                                                    name : 'Maths',
                                                    y : mathsMarks,
                                                    color : 'green'
                                                },
                                                {
                                                    name : 'Science',
                                                    y : scienceMarks,
                                                    color : 'blue'
                                                } ]
                                    } ]