javascriptkeen-io

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


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();

Solution

  • 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();