Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

D3 - data format required for cal-heatmap calendar heatmap?

I'm trying to plot calendar-heatmap from this link.

I searched all over the documenation but i couldn't find any sample file for the data-format.

Here's a link for documentation but there's no sample file for it.

In the documentation I find this data being imported datas-years.json. But I don't have any clue on how the format is. Someone please help me on this.

like image 660
Unknown User Avatar asked Dec 28 '13 07:12

Unknown User


Video Answer


1 Answers

Cal-Heatmap expects data in a JSON object in the following format:

{
    "timestamp1": value1,
    "timestamp2": value2,
    "timestamp3": value3,
    ...
}

Value can be any number (integer or float).

All timestamp are in seconds. Seconds are 'UTC seconds' (sometimes also called 'epoch seconds' or 'unix seconds') as the number of seconds since at 01-01-1970 00:00:00 for the GMT date/time provided. Here is UTC second calculator.

Today we are around 1.388.000.000 UTC seconds. The sample on the site shows data from year 2000, that is why its UTC seconds are around 946.000.000 as you saw in the JSON file sample.

Good thing is that you can find easily on the internet how to obtain UTC seconds from other time formats, and than you will be able to create a data file that Cal-Heatmap expects. :)

like image 132
VividD Avatar answered Sep 30 '22 13:09

VividD