JQPlot - 将点标签移动到图形的起点
我一直在研究 jqplot 水平条形图。
我想要这个输出(我希望点标签以百分比表示,并且应该放置在图表的起点)
这是我的代码.....
$.jqplot.config.enablePlugins = true;
voteResults = [[Chinabank,0],['Citibank',100], ['UOB',0]['POSB',0],['OCBC',0]];
// voteResults = [[Chinabank,50],['Citibank',50], ['UOB',0]['POSB',0],['OCBC',0]];
plot = $.jqplot('chart1', [voteResults], {
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
shadowAngle: 135,
rendererOptions: {
barDirection: 'horizontal',
barWidth:15,
barMargin: 25
}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
tickOptions:{
showGridline:true,
markSize:0
}
},
xaxis:{
ticks:[0,100],
tickOptions:{formatString:'%d\%'}
}
}
});
现在,点标签显示在条形图末尾之后,如果点值接近 100%,则不会显示任何内容。并且点数显示为整数。
有没有办法可以将点移动到条形图起点附近?
上面的代码显示了这些示例输出...我希望你能帮助我解决我的问题:(
谢谢:)
I have been working on a jqplot horizontal bar graph.
I WANTED TO HAVE THIS OUTPUT (I wanted the Point Labels to be in percentage and should be placed at the starting point of the graph)
Here is my code.....
$.jqplot.config.enablePlugins = true;
voteResults = [[Chinabank,0],['Citibank',100], ['UOB',0]['POSB',0],['OCBC',0]];
// voteResults = [[Chinabank,50],['Citibank',50], ['UOB',0]['POSB',0],['OCBC',0]];
plot = $.jqplot('chart1', [voteResults], {
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
shadowAngle: 135,
rendererOptions: {
barDirection: 'horizontal',
barWidth:15,
barMargin: 25
}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
tickOptions:{
showGridline:true,
markSize:0
}
},
xaxis:{
ticks:[0,100],
tickOptions:{formatString:'%d\%'}
}
}
});
Right now the point labels are displayed after the end of the bar graph and if the point value is somewhere near 100% it won't display anything. And the Points are displayed as a whole number.
Is there a way that I could move the points near the starting point of the bar graph?
The code above displays these sample outputs… I hop you can help me fix my problem :(
Thank you :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不知何故,我在@Matt的帮助下设法解决了我的问题,并且我还添加了几行代码来满足我想要的要求。我没有将点标签放置在条形图的起点上,而是将其放置在中心,以使其更具可读性和美观性。
这是我的代码:(如果您觉得自己有更好的解决方案,我愿意接受建议)谢谢
Somehow I managed to solve my problem with the help of @Matt and also I add a few lines of code to meet the requirements I wantend. Instead of placing the point labels on the starting point of the bar graph, I placed it at the center to make it more readable and presentable.
Here is my code: (I'm open for suggestions if you feel you have a better solution) thanks
要允许在条形图接近 100% 时显示标签,请使用 PointLabels
edgeTolerance
选项。当我评论您的问题时,我不确定您是否确实发布了用于生成这些图表的代码。 这里是该代码的直接转储(已修复拼写错误), 这里是我能找到的最接近你的照片的地方,那就是对原始代码进行了大量更改。
介意发布一个 jsfiddle 来展示您如何生成这些示例吗?
To allow the labels to show when the bar is near 100%, use the PointLabels
edgeTolerance
option.As I commented on your question, I'm not sure that you actually posted the code you used to generate those charts. Here is a direct dump of that code (with typos fixed), and here is the closest I could get to your pictures, and that's with a lot of changes to your original code.
Mind posting a jsfiddle that shows how you generated those examples?