Google Charts - 如何拥有轴标签和值?

发布于 2024-10-25 08:52:25 字数 843 浏览 11 评论 0原文

我目前正在使用 Google Charts 在 XY 折线图上显示 2 行数据。我已经快完成了,但我需要在 X 轴和 Y 轴上都贴上标签。
沿着垂直 Y 轴,我想用“分钟”替换 0 到 100,沿着水平 X 轴,我想用“小时”替换 0 到 100。

我已经折腾了很多年了,只是无法弄清楚这个小事情。这是我目前的代码。有人可以救我的大脑免于融化吗?这是我的代码,以便您可以查看图表,谢谢。

<img src="http://chart.apis.google.com/chart
?chxr=0,0,24|1,0,60
&chxt=x,y,x,y
&chs=800x350
&cht=lxy
&chco=3072F3,FF0000
&chds=0,24,0,60,0,24,0,60
&chd=t:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23|20,30,40,20,30,40,20,30,40,20,30,40,20,30,40,20,30,40,20,30,40,20,30,40|
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23|5,10,22,35,5,10,22,35,5,10,22,35,5,10,22,35,5,10,22,35,5,10,22,35
&chdl=Active|Sedentary
&chls=2,4,1|1
&chma=5,5,5,25
&chtt=Physical+Activity+Chart" 
width="800" height="350" alt="Physical Activity Chart" />

I am currently working on displaying 2 lines of data on a XY linechart using Google Charts. I have it nearly finished but I need to put labels on both the X and Y axis.
Along the vertical Y axis I want to replace the 0 to 100 with 'Minutes' and along the horizontal X axis I want to replace the 0 to 100 with 'Hours'.

I have been messing around with the for ages and can't figure it out just this tiny thing. Here is my current code at the moment. Can someone please save my brain from melting? Here is my code so you can view the chart, thanks.

<img src="http://chart.apis.google.com/chart
?chxr=0,0,24|1,0,60
&chxt=x,y,x,y
&chs=800x350
&cht=lxy
&chco=3072F3,FF0000
&chds=0,24,0,60,0,24,0,60
&chd=t:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23|20,30,40,20,30,40,20,30,40,20,30,40,20,30,40,20,30,40,20,30,40,20,30,40|
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23|5,10,22,35,5,10,22,35,5,10,22,35,5,10,22,35,5,10,22,35,5,10,22,35
&chdl=Active|Sedentary
&chls=2,4,1|1
&chma=5,5,5,25
&chtt=Physical+Activity+Chart" 
width="800" height="350" alt="Physical Activity Chart" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

裸钻 2024-11-01 08:52:25

好吧,我几乎立刻就明白了,痛苦!
不管怎样,我必须添加这段代码,然后它就起作用了,为每个轴标签分配值-

&chxl=0:|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|
1:|0|5|10|15|20|25|30|35|40|45|50|55|60|
2:|Hours|
3:|Minutes
&chxp=2,50|3,50

Ok I figured it out almost straight away then, pain!
Anyways, i had to add in this code and it worked then, assigning values to each axis label-

&chxl=0:|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|
1:|0|5|10|15|20|25|30|35|40|45|50|55|60|
2:|Hours|
3:|Minutes
&chxp=2,50|3,50
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文