申し訳ありませんが、ここに問題のより良い説明があります。まず、asp.net/vb.net を使用しています。カテゴリごとに 2 つのシリーズを持つ Highcharts で動作するグラフを取得しようとしています。列の値を確認していますが、そこにある値に基づいて列の色を設定したいと考えています。
ASPX
<script type="text/javascript">
$(document).ready(function () {
$(function () {
$('#summary_chart').highcharts({
chart: {
type: 'column'
},
title: {
text: ' ',
align: 'left'
},
xAxis: {
categories: [<%= UserString %>]
},
yAxis: {
min: 0,
max: 9,
title: {
text: 'Grade'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' + '<td style="padding:0"><b>{point.y}</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
colors: [<%= ColorString %>],
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0,
colorByPoint: true
}
},
series: [{
name: 'Grade1',
data: [<%= Grade1String %>]
}, {
name: 'Grade2',
data: [<%= Grade2String %>]
}]
});
});
});
コードビハインド
' Building User String
For Each oRow In oTable
UserString += "'" & oRow.UserID & "',"
Next
' Building Grade1 Values
For Each oRow In oTable
If oRow.SkillDisplay = "Grade1" Then
Grade1String += "" & oRow.Grade & ","
' Determine colors to assign values
Select Case oRow.Grade
Case 1
ColorString += "'#FFC0CB',"
Case 2
ColorString += "'#000',"
Case 3
ColorString += "'#000',"
Case 4
ColorString += "'#FFA500',"
Case 5
ColorString += "'#FFA500',"
Case 6
ColorString += "'#008000',"
Case 7
ColorString += "'#659CEF',"
Case 8
ColorString += "'#0000FF',"
Case 9
ColorString += "'#0000FF',"
Case Else
ColorString += "'#fff',"
End Select
ElseIf oRow.SkillDisplay = "Grade2" Then
Grade2String += "" & oRow.Grade & ","
' Determine colors to assign values
Select Case oRow.Grade
Case 1
ColorString += "'#FFC0CB',"
Case 2
ColorString += "'#000',"
Case 3
ColorString += "'#000',"
Case 4
ColorString += "'#FFA500',"
Case 5
ColorString += "'#FFA500',"
Case 6
ColorString += "'#008000',"
Case 7
ColorString += "'#659CEF',"
Case 8
ColorString += "'#0000FF',"
Case 9
ColorString += "'#0000FF',"
Case Else
ColorString += "'#fff',"
End Select
End If
Next
'Remove last comma in string
UserString = UserString.Remove(UserString.Length - 1)
Grade1String = Grade1String.Remove(Grade1String.Length - 1)
Grade2tring = Grade2String.Remove(Grade2String.Length - 1)
ColorString = ColorString.Remove(ColorString.Length - 1)