JQPLOT 堆叠条形图数组输入问题
JQPLOT Stacked Bar Chart array input issue
我正在尝试绘制堆积条形图,并将数据动态传递到图表
当我传递输入时
[1, 0] [0, 1] [0, 0] [0, 1] ["2015-02-16", "2015-02-15"]
在变量 s1,s2,s3,s4,dateArr 中(下面的代码片段)
我绘制了正确的堆叠条形图
但是当数据传递给堆积条形图时如下
[2] [1] [0] [0] ["2015-02-16"]
只绘制第二个数组,第一个被忽略
但是请注意 y 轴从 2 开始,即它识别第一个数组但未绘制相同的数组
这是我用来绘制图表的代码
//plot stacked bar chart function
function plotStack(s1,s2,s3,s4,dateArr) {
if(dateArr.length==0){
s1=[0,0,0,0];
s2=[0,0,0,0];
s3=[0,0,0,0];
s4=[0,0,0,0];
dateArr.push("");
dateArr.push("");
dateArr.push("");
dateArr.push("");
}
$('#graph_stacked').html(''); // redraw the stack
var plotStack = $.jqplot('graph_stacked', [s1, s2, s3, s4], {
// Tell the plot to stack the bars.
stackSeries: true,
captureRightClick: true,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {
barWidth: 40,shadow:true, // Set a 30 pixel width for the bars.
shadowAngle: 90,
highlightMouseDown: true // Highlight bars when mouse button pressed. Disables default highlighting on mouse over.
},
pointLabels: {
show: false
}
},
grid: { background: 'transparent' },
seriesColors: ["#47759e", "#444444", "#777777", "#9b9b9b"],
series: [ {label: 'New'}, {label: 'In Progress'}, {label: 'Requesting Assistance'}, {label: 'Completed'} ],
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: dateArr
},
yaxis: {
// Don't pad out the bottom of the data range. By default,
// axes scaled as if data extended 10% above and below the
// actual range to prevent data points right on grid boundaries.
// Don't want to do that here.
padMin: 0
}
},
legend: {
renderer: $.jqplot.EnhancedLegendRenderer,
show: true,
placement: 'outside',
rendererOptions: {
numberRows: 2,
numberColumns: 2
},
location: 's',
marginTop: '45px',
border: 'none'
},
highlighter: {
show:true,
tooltipLocation: 'n',
showMarker : false,
tooltipAxisX: 20, // exclusive to this version
tooltipAxisY: 20, // exclusive to this version
useAxesFormatters: false,
formatString:'%s, %P',
}
});
newTask.length=0;
inProgressTask.length=0;
reqAssistTask.length=0;
completedTask.length=0;
date.length=0;
stackArrAllNew.length=0;
stackArrAllInProgress.length=0;
stackArrAllReqAss.length=0;
stackArrAllCompTask.length=0;
stackDateAll.length=0;
}
那我做错了什么?
提前致谢
我必须更改解决方案
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: dateArr
},
yaxis: {
// Don't pad out the bottom of the data range. By default,
// axes scaled as if data extended 10% above and below the
// actual range to prevent data points right on grid boundaries.
// Don't want to do that here.
padMin: 0
}
},
至
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: dateArr
}
}
我正在尝试绘制堆积条形图,并将数据动态传递到图表
当我传递输入时
[1, 0] [0, 1] [0, 0] [0, 1] ["2015-02-16", "2015-02-15"]
在变量 s1,s2,s3,s4,dateArr 中(下面的代码片段)
我绘制了正确的堆叠条形图
但是当数据传递给堆积条形图时如下
[2] [1] [0] [0] ["2015-02-16"]
只绘制第二个数组,第一个被忽略
但是请注意 y 轴从 2 开始,即它识别第一个数组但未绘制相同的数组
这是我用来绘制图表的代码
//plot stacked bar chart function
function plotStack(s1,s2,s3,s4,dateArr) {
if(dateArr.length==0){
s1=[0,0,0,0];
s2=[0,0,0,0];
s3=[0,0,0,0];
s4=[0,0,0,0];
dateArr.push("");
dateArr.push("");
dateArr.push("");
dateArr.push("");
}
$('#graph_stacked').html(''); // redraw the stack
var plotStack = $.jqplot('graph_stacked', [s1, s2, s3, s4], {
// Tell the plot to stack the bars.
stackSeries: true,
captureRightClick: true,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {
barWidth: 40,shadow:true, // Set a 30 pixel width for the bars.
shadowAngle: 90,
highlightMouseDown: true // Highlight bars when mouse button pressed. Disables default highlighting on mouse over.
},
pointLabels: {
show: false
}
},
grid: { background: 'transparent' },
seriesColors: ["#47759e", "#444444", "#777777", "#9b9b9b"],
series: [ {label: 'New'}, {label: 'In Progress'}, {label: 'Requesting Assistance'}, {label: 'Completed'} ],
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: dateArr
},
yaxis: {
// Don't pad out the bottom of the data range. By default,
// axes scaled as if data extended 10% above and below the
// actual range to prevent data points right on grid boundaries.
// Don't want to do that here.
padMin: 0
}
},
legend: {
renderer: $.jqplot.EnhancedLegendRenderer,
show: true,
placement: 'outside',
rendererOptions: {
numberRows: 2,
numberColumns: 2
},
location: 's',
marginTop: '45px',
border: 'none'
},
highlighter: {
show:true,
tooltipLocation: 'n',
showMarker : false,
tooltipAxisX: 20, // exclusive to this version
tooltipAxisY: 20, // exclusive to this version
useAxesFormatters: false,
formatString:'%s, %P',
}
});
newTask.length=0;
inProgressTask.length=0;
reqAssistTask.length=0;
completedTask.length=0;
date.length=0;
stackArrAllNew.length=0;
stackArrAllInProgress.length=0;
stackArrAllReqAss.length=0;
stackArrAllCompTask.length=0;
stackDateAll.length=0;
}
那我做错了什么?
提前致谢
我必须更改解决方案
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: dateArr
},
yaxis: {
// Don't pad out the bottom of the data range. By default,
// axes scaled as if data extended 10% above and below the
// actual range to prevent data points right on grid boundaries.
// Don't want to do that here.
padMin: 0
}
},
至
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: dateArr
}
}