我需要與分貝值堆疊條形圖。所以價值觀是動態的。這裏是我的場景, 系統中有很多用戶,但只有2個用戶活躍到現在。 peter使用了task1和task3,sam使用了task1,task2和task3。每個任務都有開放,待決,取消狀態。因此,彼得我想顯示2個堆疊的酒吧狀態和相同的3堆積酒吧。我無法在高位圖上實現這一點。圖片顯示如下。Highcharts堆積條形圖與分貝值(動態數據)
$(function() {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
x: 0,
text: null,
style: {
fontSize: '13px',
fontWeight: 'Bold',
}
},
credits: {
enabled: false
},
xAxis: {
categories: [
'Sam','Peter',
],
crosshair: true
},
yAxis: [{
min: 0,allowDecimals: false,
title: {
text: 'Opportunities'
}
}],
tooltip: {
headerFormat: '<b> {point.key}</b><br>',//{series.options.stack} :
pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: {point.y}/{point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
depth: 40
}
},
series: [
{name:'task1',data:[1], stack:'Sam'},
{name:'task1',data:[1], stack:'Peter'}, {name:'task2',data:[0], stack:'Peter'},
{name:'task3',data:[1], stack:'Sam'},{name:'task3',data:[0], stack:'Peter'}]
});
});
for (int i = 0; i < dtAccMgrs.Rows.Count; i++)
{
string accMgr = dtAccMgrs.Rows[i]["AccMgr"].ToString();
AccMgrList += "'" + accMgr + "',";
dtData = dtOppr.Select("AccMgr='" + accMgr + "'");
AccMgrDataOpen += "{name:'Open',data:[";
AccMgrDataPending += "{name:'Pending',data:[";
AccMgrDataCancelled += "{name:'Cancelled',data:[";
for (int j = 0; j < dtData.Length; j++)
{
AccMgrDataOpen += dtData[j]["Oppr_Open"];
AccMgrDataPending += dtData[j]["Oppr_Pending"];
AccMgrDataCancelled += dtData[j]["Oppr_Cancelled"];
string open = dtData[j]["Oppr_Open"].ToString();
int OpprTotal = Int32.Parse(open) + Int32.Parse(dtData[j]["Oppr_Pending"].ToString()) + Int32.Parse(dtData[j]["Oppr_Cancelled"].ToString());
}
AccMgrDataOpen += "], stack:'" + accMgr + "'},";
AccMgrDataPending += "], stack:'" + accMgr + "'},";
AccMgrDataCancelled += "], stack:'" + accMgr + "'},";
}
AccMgrDataOpen += "]"; AccMgrDataPending += "]"; AccMgrDataCancelled += "]"; AccMgrList += "]";
AccMgrDataOpen = AccMgrDataOpen.Replace(",]", "]");
AccMgrDataPending = AccMgrDataPending.Replace(",]", "]");
AccMgrDataCancelled = AccMgrDataCancelled.Replace(",]", "]");
你可以從數據庫中添加後JSON數據,或使用http://myjson.com/創造活生生的例子 –
IM通過我的數據在每我的代碼,我沒有得到如何通過堆疊(狀態)傳遞動態多欄(任務)的數據。即時通訊有點混淆,合併2個類型在一個單一的JSON數據。這是我給圖形表示。 – user8158183
其實我從服務器端傳遞數據,請參考上面的代碼,我補充說。 – user8158183