pChart 2.x 图表使用小数而不是整数绘制比例
我正在处理包含访问次数的统计数据,pChart 上的比例显示小数而不是整数。
默认设置是使用类似于下面的分数创建比例:
0 0.2 0.4 0.6 0.8 1.0 1.2 |=== |======== |============================ |=== |===================
这不起作用,因为您不能访问某个网站 1.2 次。
我试图使用 "Mode"=>SCALE_MODE_MANUAL
参数仅使用整数(0、1、2 等)进行缩放,但失败了。
如何设置或强制 pChart 在轴上使用整数进行绘图?
I'm working on stats containing a number of visits and the scale on pChart is showing decimals instead of whole integers.
The default setting is creating scales with fractions similar to below:
0 0.2 0.4 0.6 0.8 1.0 1.2 |=== |======== |============================ |=== |===================
That doesn't work as you can't visit a site 1.2 times.
I was trying to make scale only with whole numbers (0, 1, 2 etc.) with "Mode"=>SCALE_MODE_MANUAL
parameter but I failed.
How do I set or force pChart to plot using whole numbers on the axis?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能最好调整数据,而不是图表,因为即使比例显示为 1,您仍然会看到显示 1.2 的条形图。
如果您仍在尝试修复轴边界,则可以设置轴边界,然后使用最小 div 高度值,您可以更好地控制轴。
另一种稍微狡猾的方法是在调用drawScale函数之前创建一个包含整数的数据集,然后将其删除并添加实际数据。
You are possibly best to adjust your data, rather than your graph, as you will still see the bar chart showing 1.2, even if the scale says 1.
If you were still trying to fix the axis boundaries, you set the axis boundaries, and use the minimum div height value, you can have better control over your axis.
Another, slightly dodgy way, is to create a dataset with whole numbers to before you call the drawScale function, then remove it, and add your actual data.
为了实现这一目标,我做了几件事,首先我设置了一个带有最小值和最大值的固定比例。
然后,当我使用 drawScale() 方法时,我将 Factor 属性设置为 1:
I did a couple of things to achieve this, first I set a fixed scale with a min and max.
And then when I use the drawScale() method I set the Factor property to 1:
如果您设置“因素”=>; array(10000) 在drawScale 函数中,pChart 显示整数(1, 2)。我自己找到了解决方案。
if you set "Factors" => array(10000) in drawScale function the pChart is showing intergers(1, 2). I found the solution myself.