[英]jqplot bar chart multiple series on one datapoint
I'm trying to get a jqplot
chart to display a bunch of data in different colored bars with a key on the right, but the scaling doesn't seem to work properly. 我正在尝试获取一个
jqplot
图表,以使用右侧的键在不同的彩色栏中显示一堆数据,但是缩放似乎无法正常工作。 My data looks like this: 我的数据如下所示:
data:[[1.03],[1.02],[1.05],[1.02],[1.011]],
labels:["Imperial Stout","Lager","Porter","Etc","etc"],
I can try to let it auto scale, and it cuts off half of the bars like this: 我可以试着让它自动缩放,这样可以减少一半的条形:
(jsfiddle)
(jsfiddle)
I tried setting the axis scale from 0.8 to 1.2, but it clusters all of the bars in the center leaving a ton of empty space on the chart like this: 我尝试将轴比例设置为0.8到1.2,但是它将中心的所有条形图聚集在一起,在图表上留下了大量空白,如下所示:
(jsfiddle)
(jsfiddle)
Is there a way to get this to display correctly? 有没有办法让它正确显示?
I can't put them in one series because the legend just labels that as "Series 1". 我不能将它们放在一个系列中,因为图例只是将其标记为“系列1”。
You can add the following option to xaxis
: 您可以将以下选项添加到
xaxis
:
renderer: $.jqplot.CategoryAxisRenderer,
and tickOptions
could be set to show: false
if you don't want an extraneous tickmark under the diagram. 和
tickOptions
可以设置为show: false
如果您不希望图表下有多余的刻度线,则为show: false
。
What worked for me was configuring the xaxis
as follows: 对我
xaxis
是按如下方式配置xaxis
:
xaxis: {
label: input.xaxis,
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ['']
},
By default, the axis rendered is a $.jqplot.LinearAxisRenderer
, which tries to render a numeric axis, hence the problems you were having. 默认情况下,渲染的轴是
$.jqplot.LinearAxisRenderer
,它尝试渲染数字轴,因此会遇到问题。
Interestingly, I also had to set ticks
as I did because without it I was getting a single tick value of 1 displayed on the x-axis and I couldn't otherwise get rid of it. 有趣的是,我还必须像我一样设置
ticks
,因为如果没有它,我将在x轴上显示单个刻度值1,否则我将无法摆脱它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.