使用谷歌图表包装器的垂直条形图的范围
我一直在尝试弄清楚如何在我的 django 中使用 google Chart-wrapper应用程序,但我似乎找不到任何有关如何使用它的文档。在玩了一段时间后,我让它完成了我想要的大部分事情,但我似乎不知道如何让范围变得非常正确。
例如,这个网址:
有几个高于 100 的值(在 url 的 chd 部分),但是当它被渲染时,它会切断任何高于 100 的值。
这是我用来创建该 url 的代码:
hist = {}
d = Defect.objects.all()
for defect in d:
c = Failure.objects.filter(defect = defect).count()
if c > 0:
hist[defect.defcode] = c
m = VerticalBarStack(hist.values())
m.title("Failure Types")
m.size(1000,300)
m.marker('N*', 'black', 0, -1, 11)
m.axes('x')
m.axes.label(0, '|'.join(hist.keys()))
谷歌图表包装器允许我编写类似于 m.range(1000) 的内容或类似的内容来指定要在图表上显示的范围,这似乎是合乎逻辑的,但是不起作用,我找不到任何真正的文档或详细、足够复杂的示例来弄清楚。
I've been trying to figure out how to use google chart-wrapper with my django application but I can't seem to find hardly any documentation on how to use it. After playing around with it for awhile I got it to do most everything I want it to, but I can't seem to figure out how to get the range quite right.
For example, this url:
has several values above 100 (in the chd section of the url), but when it gets rendered it cuts anything above 100 off.
This is the code I used to create that url:
hist = {}
d = Defect.objects.all()
for defect in d:
c = Failure.objects.filter(defect = defect).count()
if c > 0:
hist[defect.defcode] = c
m = VerticalBarStack(hist.values())
m.title("Failure Types")
m.size(1000,300)
m.marker('N*', 'black', 0, -1, 11)
m.axes('x')
m.axes.label(0, '|'.join(hist.keys()))
It seems logical that google chart-wrapper would allow me to write something along the lines of m.range(1000) or something similar to specify the range to show on the chart, but that doesn't work and I can't find any real documentation or detailed, complex enough examples to figure it out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该为扩展编码添加缩放。
我已经添加了所需的参数,如下:
chds=0,2000
您的最终网址是:
http://chart.googleapis.com/chart?chxt=x&chd=t:2.0,1.0,192.0,1032.0,22.0,60 .0,75.0,94.0,3.0,2.0,1.0,11.0,383.0,3.0,164.0,50.0,12.0,5.0,564.0,7671.0,115.0,331.0&chm=N %2A,000000,0,-1,11&chs=500x500&cht=bvs&chds=0,2000&chtt=故障+类型&chxl =0:|B16|B13|B10|C11|A10|A13|D04|D03|D02|B01|C09|B05|B04|B07|C01|C03|C04|C07|A02|A01|A06|A05
You should add scaling for extended encoding.
I have added the required parameters, as below:
chds=0,2000
your final URL is:
http://chart.googleapis.com/chart?chxt=x&chd=t:2.0,1.0,192.0,1032.0,22.0,60.0,75.0,94.0,3.0,2.0,1.0,11.0,383.0,3.0,164.0,50.0,12.0,5.0,564.0,7671.0,115.0,331.0&chm=N%2A,000000,0,-1,11&chs=500x500&cht=bvs&chds=0,2000&chtt=Failure+Types&chxl=0:|B16|B13|B10|C11|A10|A13|D04|D03|D02|B01|C09|B05|B04|B07|C01|C03|C04|C07|A02|A01|A06|A05