You need to apply CategoryAxisRenderer to yaxis (not to xaxis ) :
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer
}
Edit : Add xaxis:{min:0} to axes options if you want to bound xaxis
質問
I've been struggeling with the following for quite some time now.. Hopefully someone can help me out.
What I'm trying to do: Using jqplot I'm trying to combine a horizontal stacked bar chart with a line chart. The stacked bar chart should contain five values. The line chart should cross the stacked bar chart.
What I've come up with so far: I've managed to build the horizontal stacked bar chart and the line crosses it as it should.
The problem: My stacked bar chart now shows three blocks (values: 1, 4 and 16). I should be seeing five blocks (values: 1, 2, 4, 8 and 16).
The code I've used:
<script type="text/javascript">
$(document).ready(function() {
var x1 = [[1,1]];
var x2 = [[2,1]];
var x3 = [[4,1]];
var x4 = [[8,1]];
var x5 = [[16,1]];
var x6 = [[1,0.5],[1,1.5]];
var plot2 = $.jqplot('thema1chart', [x1, x2, x3, x4, x5, x6], {
stackSeries: true,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {
barDirection: 'horizontal'
},
pointLabels: {
show: false,
stackedValue: true
}
},
series: [{shadow: false, color:'#666666'},
{shadow: false, color:'#FFFFFF'},{shadow: false, color:'#b4d2dd'},{shadow: false, color:'#FFFFFF'},{shadow: false, color:'#666666'},
{
shadow: false,
disableStack : true,//otherwise it wil be added to values of previous series
renderer: $.jqplot.LineRenderer,
lineWidth: 2,
label:'Benchmark',
color:'#666666',
showLine:false,
pointLabels: {
show: false
},
markerOptions: {
size: 7, style:"plus"
}}],
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer
}
,
yaxis: {
autoscale: true
}
}
});
});
</script>
Many thanks for any help you could offer!
解決
You need to apply CategoryAxisRenderer to yaxis (not to xaxis ) :
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer
}
Edit : Add xaxis:{min:0} to axes options if you want to bound xaxis