romaninsh
romaninsh

Reputation: 10664

Zoomcharts with preloaded data

I am trying to use TimeChart with preloaded data, but I can't find a good example.

data = {'preloaded':{
    'unit':'s',
    'values':{'id':3,'name':'slice1','value':20}
}}

However I'm getting error: "Required field 'unit' not set in data"

Can you please recommend how specify the data properly?

Upvotes: 1

Views: 296

Answers (2)

Eizens
Eizens

Reputation: 46

This should work:

    var dataObj = {
        "dataLimitFrom":1279408157,
        "dataLimitTo":1384253671,
        "unit":"s",
        "values":[
          [1280062860,"8.221"],
          [1282209412,"4.2",],
          [1284577510,"5.9"],
          [1286988866,"1.52"],
        ]
    };
    var t = new TimeChart({
        container: document.getElementById("demo"),
        data:
        {
            units:["s"],
            timestampInSeconds: true,
            preloaded: dataObj
        }
    });

For TimeChart in data array first one is always timestamp [1280062860,"8.221"].
You can also change "unit" to any of ["s","m","h","d","M","y"]

More about timechart: https://zoomcharts.com/developers/en/time-chart/api-reference/settings.html

UPDATE: 'data' array containing timestamps and values is now called 'values'.

Upvotes: 3

user3313471
user3313471

Reputation: 1

The first value in [data] is the difference between 1/1/1970 and the selected date in seconds/hour/minute/...

Upvotes: -1

Related Questions