2016-04-29 14 views
0

私は私が欲しいものハイチャートの特定の列に異なる色を使用する方法は?

以下の私のhighchartが値を持っているいくつかの異なる色でそれらの列を着色するである必要があり、正確にここに

8.00は私のコード

$(document).ready(function() { }); 
angular.module('myModule', []).service("AttendanceService", function ($http) { 
    this.getdata = function() { 
     return $http({ 
      method: "post", 
      url: "GetAttendanceReport", 
      params: [{ EmpID: $("#nameofEmp").val(), YearID: $("#YearIn").val() }], 
      dataType: "json" 
     }); 
    }; 
}).controller('myController', function ($scope,AttendanceService) { 
    GetAlldata(); 
    function GetAlldata() { 
     var getAttendanceData = AttendanceService.getdata(); 
     getAttendanceData.then(function (Attendances) { 
      Highcharts.chart('container', { 
       chart: { 
         type: 'column', 
         events: { 
          drilldown: function() { 

           this.yAxis[0].addPlotLine({ 
            id: 'p1', 
            value: 8, 
            color: '#ff0000', 
            width: 2, 
            zIndex: 4, 
            label: { 
             text: 'goal' 
            } 
           }) 
          }, 
          drillup: function() { 
           this.yAxis[0].removePlotLine('p1'); 
          } 
         }, 
        } 
       title: { 
        text: 'Attendance Report' + ' ' + $("#YearIn option:selected").text() 
       }, 
       xAxis: { 
        type: 'category' 
       }, 
       yAxis: { 
         title: { 
          text: 'Total Attendance Recorded', 
          plotLines: [{ 
           id: 'p1', 
           value: 8, 
           color: '#ff0000', 
           width: 2, 
           zIndex: 4, 
           label: { 
            text: 'goal' 
           } 
          }] 
         }, 

        } 
       legend: { 
        enabled: false 
       }, 
       plotOptions: { 
        series: { 
         borderWidth: 0, 
         dataLabels: { 
          enabled: true, 
          format: '{point.y:.2f}' 
         } 
        } 
       }, 

       tooltip: { 
        headerFormat: '<span style="font-size:11px">{series.name}</span><br>', 
        pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}mins</b> of total<br/>' 
       }, 

       series: [{ 
        name: 'Attendance', 
        colorByPoint: true, 
        data: [{ 
         name: 'Jan', 
         y: Attendances.data.YearlyReport[0], 
         drilldown: 'Jan' 
        }, { 
         name: 'Feb', 
         y: Attendances.data.YearlyReport[1], 
         drilldown: 'Feb' 
        }, { 
         name: 'March', 
         y: Attendances.data.YearlyReport[2], 
         drilldown: 'March' 
        }, { 
         name: 'April', 
         y: Attendances.data.YearlyReport[3], 
         drilldown: 'April' 
        }, { 
         name: 'May', 
         y: Attendances.data.YearlyReport[4], 
         drilldown: 'May' 
        }, { 
         name: 'June', 
         y: Attendances.data.YearlyReport[5], 
         drilldown: 'June' 
        }, { 
         name: 'July', 
         y: Attendances.data.YearlyReport[6], 
         drilldown: 'July' 
        }, { 
         name: 'Aug', 
         y: Attendances.data.YearlyReport[7], 
         drilldown: 'Aug' 
        }, { 
         name: 'Sep', 
         y: Attendances.data.YearlyReport[8], 
         drilldown: 'Sep' 
        }, { 
         name: 'Oct', 
         y: Attendances.data.YearlyReport[9], 
         drilldown: 'Oct' 
        }, { 
         name: 'Nov', 
         y: Attendances.data.YearlyReport[10], 
         drilldown: 'Nov' 
        }, { 
         name: 'Dec', 
         y: Attendances.data.YearlyReport[11], 
         drilldown: 'Dec' 
        }] 
       }], 
       drilldown: { 
        series: 
         [{ 
         name: 'Jan', 
         id: 'Jan', 
         data: [ 
          [ 
           '1', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 1]) 

          ], 
          [ 
           '2', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 2]) 
          ], 
          [ 
           '3', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 3]) 
          ], 
          [ 
           '4', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 4]) 
          ], 
          [ 
           '5', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 5]) 
          ], 
          [ 
           '6', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 6]) 
          ], 
          [ 
           '7', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 7]) 
          ], 
          [ 
           '8', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 8]) 
          ], 
          [ 
           '9', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 9]) 
          ], 
          [ 
           '10', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 10]) 
          ], 
          [ 
           '11', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 11]) 
          ], 
          [ 
           '12', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 12]) 
          ], 
          [ 
           '13', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 13]) 
          ], 
          [ 
           '14', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 14]) 
          ], 
          [ 
           '15', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 15]) 
          ], 
          [ 
           '16', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 16]) 
          ], 
          [ 
           '17', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 17]) 
          ], 
          [ 
           '18', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 18]) 
          ], 
          [ 
           '19', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 19]) 
          ], 
          [ 
           '20', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 20]) 
          ], 
          [ 
           '21', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 21]) 
          ], 
          [ 
           '22', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 22]) 
          ], 
          [ 
           '23', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 23]) 
          ], 
          [ 
           '24', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 24]) 
          ], 
          [ 
           '25', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 25]) 
          ], 
          [ 
           '26', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 26]) 
          ], 
          [ 
           '27', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 27]) 
          ], 
          [ 
           '28', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 28]) 
          ], 
          [ 
           '29', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 29]) 
          ], 
          [ 
           '30', 
           parseFloat(Attendances.data.MonthlyReport[1 * 33 + 30]) 
          ], 
          [ 
           '31', 
            parseFloat(Attendances.data.MonthlyReport[1 * 33 + 31]) 
          ] 
         ]},and so on] 
       } 
      }); 
     }, function() { 
      alert('Error in getting records'); 
     }); 

    } $("#btnLoad").click(function (event) { 
     GetAlldata(); 
    }); 
    $("#btnBack").click(function (event) { 
     window.location.href = "homepage"; 
    }); 
}); 

enter image description here

ですドリルダウンハイチャートでColumnを使用しました。何か方法はありますか?

答えて

1

あなたは直接このようなあなたのシリーズのデータ​​ポイント属性colorを渡すことができます。

color: '#00ff00'

あなたはその後、自分のデータを巡回する必要があり、これらのポイントの色を交換してください。

JsFiddle

0

この質問はスタックオーバーフローの他の箇所で見つかることがあります:Highcharts Change Bar Color Based on Value。受け入れられた回答を参照してください。回答にはシリーズを繰り返し、その価値に基づいて色を付けるコードがあります。

関連する問題