jqPlot - 无法将x轴显示为右侧的图例

时间:2013-01-23 10:55:57

标签: jquery jqplot

我正在使用jqPlot作为条形图,我想将x轴显示为图例。

附加截图...

enter image description here

代码:

var s1 = [2.5, 6.3, 7.4, 10]; 
var ticks = ['a', 'b', 'c', 'd']; 
plot2 = $.jqplot('chart2', [s1], { 
seriesDefaults: { 
     renderer:$.jqplot.BarRenderer, rendererOptions:{ varyBarColor : true }, 
     pointLabels: { show: true }, showLabel: true,   }, 
     series: [ {label: 'Cups'}, {label: 'Dishes'}, ], 
     legend: { show: true, placement: 'outside', //rendererOptions: {numberColumns: 2}   }, 
     axes: { xaxis: { renderer: $.jqplot.CategoryAxisRenderer, ticks: ticks }, 
             yaxis:{  tickOptions:{ formatString:'%.2f%' } } }

1 个答案:

答案 0 :(得分:3)

以下是example如何执行此操作:

var s1 = [2.5, 6.3, 7.4, 10]; 
var ticks = ['a', 'b', 'c', 'd']; 
plot2 = $.jqplot('chart1', [s1,[],[],[]], { //give it extra blank series
seriesDefaults: { 
       renderer: $.jqplot.BarRenderer, 
       rendererOptions: { varyBarColor : true }, 
       pointLabels: { show: true }, 
       showLabel: true
     }, 
     series: [ {}, 
               {renderer: $.jqplot.LineRenderer}, // set our empty series to the lineRenderer, so the bar plot isn't padded for room
               {renderer: $.jqplot.LineRenderer},
               {renderer: $.jqplot.LineRenderer} ], 
     legend: { show: true, placement: 'outside', labels: ticks},  // give the legend the tick labels
     axes:   { xaxis: { renderer: $.jqplot.CategoryAxisRenderer, ticks: ticks }}, 
     yaxis:  {  tickOptions:{ formatString:'%.2f%' } }
});

产地:

enter image description here