dongyuanliao6204 2014-12-13 23:53
浏览 91

am json from field to field

Part of the script says from field to field which is to do with this. Here's my JSON pulling info from my database, value 1 is amount, value 2 is time

[{
  "date": "2014-12-09",
  "value1": 367,
  "value2": 03:06:00
}, {
  "date": "2014-12-09",
  "value1": 367,
  "value2": 03:06:00
}]

That's my data, this is part of the script that wants me to map it? :S

        dataSet.fieldMappings = [{
            fromField: "valu1",
            toField: "value2"
        }, {
            fromField: "volume",
            toField: "volume"
        }];

I only have 3 fields don't I? Sorry for a vague question, I just don't understand.

  • 写回答

1条回答 默认 最新

  • dqy13020940 2015-01-23 15:29
    关注

    The fieldMapping maps the JSON-fields with the valueField specified in the graph-properties.

    I guess what you want to do is something like this:

    [{
      "date": "2014-12-09 03:06:00",
      "value": 367
    }, {
      "date": "2014-12-09 03:07:00",
      "value": 673
    }]
    

    Note that i put the time into the date-field and changed the second date and value to be different from the first. (I think two similar datapoints won't work)

    For this dataset your mapping should look like this:

    dataSet.fieldMappings = [{
        fromField: "value", // this is the JSON-field
        toField: "valueMapped" // the graph will search for this field - see below
    }];
    

    To find the data, the graph needs to know the mapped field:

    "graphs": [{
        "valueField": "valueMapped"
    }];
    

    Now one last step for the correct use of the "date"-field:

    "dataDateFormat": "YYYY-MM-DD JJ:NN:SS",
    "categoryField": "date"
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)