日期范围谷歌图表工具 [英] Date Range Google Chart Tools

查看:99
本文介绍了日期范围谷歌图表工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Google图表在线图上显示数据。数据显示正常,但是我想设置一个日期范围来显示。



数据以JSON文本格式从数据库发送:


$ b $

  {
cols:[
{label:Week,type:date },
{label:Speed,type:number},
{type:string,p:{role:tooltip} },
{type:string,p:{role:tooltip}},
{type:string,p:{role :tooltip}},
{type:string,p:{role:tooltip}},

],
rows:[
{c:[{v:Date('。$ date。')},{v:null},{v:null},{ v:null},{v:null},{v:null}]},
{c:[{v:Date('。$ date。') },{v:null},{v:null},{v:null},{v:null},{v:null}]}
] $数据显示周或月( null $ b

/ $例如本周:

  2012,02,06 
2012年02月02日, 07
2012,02,09

数据并未设置为每周的每日数据,因此在这个例子中只显示了上面的日期。我希望展示的是本周开始(2012,02,06)到本周末(2012,02,12),类似于第三个示例 here

我设法让整体通过检查日期是否存在于数据库中,并且如果不附加额外的行将会显示空数据,则表明该行不是连续的,并且日期不是这样。



任何人都可以提供关于如何去做这件事的任何建议?



谢谢!

解决方案

缺少日期(即让数据库返回2个值而不是7个)?

连续轴应该处理缺失的日期,您只需设置轴范围从一周开始到结束。



更新

用于交互式折线图轴范围可以像这样设置(如

<$ p $ / questions / 6359935 / setting-a-hard-minimum-axis-value-in-google-charts-api> this thread
) p> hAxis:{...
viewWindowMode:'explicit',
viewWindow:{min:new Date(2007,1,1),
max:new日期(2010,1,1 )}
...}

请参阅 http://jsfiddle.net/REgJu/


I'm trying to display data on a line graph using Google Charts. The data displays fine, however I would like to set a date range to be displayed.

The data is sent from the database in a JSON literal format:

{
    "cols": [
                {"label": "Week", "type": "date"},
                {"label": "Speed", "type": "number"},               
                {"type":"string","p":{"role":"tooltip"}},   
                {"type":"string","p":{"role":"tooltip"}},   
                {"type":"string","p":{"role":"tooltip"}},   
                {"type":"string","p":{"role":"tooltip"}},   

            ],
    "rows": [
               {"c":[{"v": "Date('.$date.')"},{"v": null},{"v": null},{"v": null},{"v": null},{"v": null}]},
               {"c":[{"v": "Date('.$date.')"},{"v": null},{"v": null},{"v": null},{"v": null},{"v": null}]}
            ] 
}

Data is either displayed by week or month (null for easy reading) for example this week:

2012, 02, 06
2012, 02, 07
2012, 02, 09 

Data isn't set for everyday of the week, therefore in this example only the dates above are shown. What I would like to be shown is the start of the week (2012, 02, 06) to the end of the week (2012, 02, 12) similar to the third example here.

I managed to get the whole week showing by checking if the date exists in the database and if not append an extra row will null data, this however meant the line was not continuous and the dates where not in order.

Could anyone offer any advice on how to I could go about doing this?

Thanks!

解决方案

Did you try leaving the missing dates be missing dates (i.e. let the database return 2 values instead of 7)?

The continuous axis should handle missing dates, you just need to set the axis range from start to end of the week.

UPDATE

for interactive line chart the axis ranges can be set like this (as inspired by this thread):

hAxis: {...
        viewWindowMode: 'explicit',
        viewWindow: {min: new Date(2007,1,1),
                     max: new Date(2010,1,1)}
        ...}

see http://jsfiddle.net/REgJu/

这篇关于日期范围谷歌图表工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆