Bar Graphs with two Y-Axis of different scale.

2,042 views
Skip to first unread message

NotionCommotion

unread,
May 20, 2011, 5:07:46 PM5/20/11
to jqplot-users
Wow, this is a very impressive plugin! That being said...

I am trying to create a bar chart. I have two series (total dollars
sold and quantity sold) which are charted against the month. Since
the two series have different units (dollars and just quantity), it
will need two Y-axis and the two will need to be scaled so they have
approximately the same magnitude.

I believe this is possible with a standard line graph, but I am not
sure if it is with a bar graph. Can any one let me know if it is
possible, and if so, give me a couple pointers to get started.

Thanks

NotionCommotion

unread,
May 21, 2011, 11:43:40 AM5/21/11
to jqplot-users
After a little more playing around, yes it could be done.
series:[{label:'Quantity'}, {label:'Dollars' ,yaxis:'y2axis'}],
axes: {yaxis: {autoscale: true},y2axis: {autoscale: true}},





var plot5 = $.jqplot('chart5',
[data_chart5_price,data_chart5_quantity],
{
seriesDefaults:
{
renderer:$.jqplot.BarRenderer
},
series:[{label:'Quantity'}, {label:'Dollars' ,yaxis:'y2axis'}],
axes: {yaxis: {autoscale: true},y2axis: {autoscale: true}},
legend: {show: true,placement: 'outsideGrid'},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: data_chart5_ticks
},
yaxis: {
pad: 1.05,
tickOptions: {formatString: '$%d'}
}
}
});
Reply all
Reply to author
Forward
0 new messages