Zing Charts transform epoch dates to human readable

195 views Asked by At

I'm trying to use the transform:date from zingcharts scale objects http://www.zingchart.com/docs/json-attributes-syntax/scale-objects/transform/ to display an epoch date in the x-scale.

Some of the epoch dates I'm using are: 1402444800,1402531200,1402617600.

Using their Epoch Converter link the results I should be seeing are: 11 Jun 2014, 12 Jun 2014,13 Jun 2014.

Instead I get: 17 Jan 1970,17 Jan 1970,17 Jan 1970. Working code is http://jsfiddle.net/Rodmunera/j1ddL5k6/5/

  "scale-x": {
    "transform": {
      "item": {
        "visible": false
      },
      "guide": {
        "visible": false
      },
      "all": " %d %M %Y",
      "type": "date"
    },
    "decimals": 0,
    "format": "%v",
    "mirrored": 0,
    "text": "Shows",
    "values": [
      1402444800,
      1402531200,
      1402617600
    ]
  },

I'm pretty sure I'm implementing this feature properly, can anybody tell me what I'm doing wrong? or if feature

1

There are 1 answers

2
Stalfos On BEST ANSWER

rodmunera,

You just have to add three more 0's to each of your Unix times, as ZingChart uses milliseconds, not seconds.

I've updated your demo here.

"values": [
      1402444800000,
      1402531200000,
      1402617600000
    ]

I'm a member of the ZingChart team, so if you have any more questions, feel free to ask :)