简体   繁体   English

从嵌套的JSON检索数据到Morris.js xkey

[英]Retrieve data from nested JSON to Morris.js xkey

So I'm trying to make a bar chart, with morris.js, using CakePHP 3. I have the following nested JSON,(wich contains date details): 因此,我尝试使用CakePHP 3使用morris.js制作条形图。我具有以下嵌套的JSON(其中包含日期详细信息):

MarketingSales:
 0: Object
 country_id: 5
 date: Object
   NumeroDia: 4
   date: "2015-01-01 T 00:00:00+0000"
   day: 1
   id: 366
   month: 1
   week: 1
   year: 2015
 date_id: 366
 id: 4106
 medium_id: 8
 sales: 54189.18863
 views: 3496

This JSON comes from two joined tables ("MarketingSales" and "Dates"), using the "contains" option from CakePHP. 此JSON来自两个连接的表(“ MarketingSales”和“日期”),使用CakePHP的“包含”选项。

I'm now trying to label the x axis with the number of the month, but I'm getting "undefined" labels. 我现在正在尝试用月份数来标记x轴,但是我却得到了“未定义”的标签。

so far, I have tried: 到目前为止,我已经尝试过:

xkey:['date']
xkey:['date.month']
xkey:['date']['month']
xkey:date.month

Reading through morris.js documentation I found about setting parseTime to false, but it doesn't work either. 通过阅读morris.js文档,我发现有关将parseTime设置为false,但是它也不起作用。

Any ideas of what I'm doing wrong? 关于我在做什么错的任何想法?

Thanks! 谢谢!

edit: fixed typing error 编辑:修正打字错误

Seems like a type error. 好像是类型错误。 Should not be one of these? 不应该是其中之一吗?

xkey:['date']
xkey:['date.month']
xkey:['date']['month']
xkey:date.month

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM