Keen.io Dataviz to draw graph but keep getting error “Uncaught Requested parser does not exist”

北城以北 提交于 2019-12-10 20:34:25

问题


Tried to do some custom data alteration before charting a line graph

Keen.io Dataviz to draw graph but keep getting error "Uncaught Requested parser does not exist"

Does Keen.Dataviz only take data from Keen.query??

Data:

{
    "result": [
        {
            "value": 317,
            "timeframe": {
                "start": "2017-04-01T00:00:00.000Z",
                "end": "2017-05-01T00:00:00.000Z"
            }
        },
        {
            "value": 1015,
            "timeframe": {
                "start": "2017-05-01T00:00:00.000Z",
                "end": "2017-06-01T00:00:00.000Z"
            }
        }
    ],
    "totalusers": 5357
}


vm.mau = JSON.stringify(data.result, null, 2);
console.log(vm.mau);
var chart = new Keen.Dataviz()
    .el(document.getElementById('my-div'))
    .chartType("line")
    .colors(["#6ab975"])
    .title("AVG. TIME ON SITE / USER")
    .width(400)
    .prepare();

chart
    .data({result: vm.mau})
    .render();

回答1:


You can definitely send Keen.Dataviz() data from other sources or manually pass it in.

Here are some examples of this: https://keen.io/docs/visualize/visualize-your-own-data/

If you click on the JavaScript tabs of the JSFiddles, you can see how we are passing in the data.

I went ahead and created a JSFiddle with your example: https://jsfiddle.net/trt2yddw/1/

// Fetch data from another API or your own data source:
var data = {
    "result": [
        {
            "value": 317,
            "timeframe": {
                "start": "2017-04-01T00:00:00.000Z",
                "end": "2017-05-01T00:00:00.000Z"
            }
        },
        {
            "value": 1015,
            "timeframe": {
                "start": "2017-05-01T00:00:00.000Z",
                "end": "2017-06-01T00:00:00.000Z"
            }
        }
    ],
    "totalusers": 5357
}

var chart = new Keen.Dataviz()
    .el(document.getElementById('chart'))
    .chartType("line")
    .colors(["#6ab975"])
    .title("AVG. TIME ON SITE / USER")
    .width(400)
    .prepare();

chart
  .data(data)
  .render();


来源:https://stackoverflow.com/questions/44594115/keen-io-dataviz-to-draw-graph-but-keep-getting-error-uncaught-requested-parser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!