cal-heatmap icon indicating copy to clipboard operation
cal-heatmap copied to clipboard

displaying value/data from json

Open 0xRoM opened this issue 6 years ago • 3 comments

Hi,

I'm unable to display the value in subDomainTextFormat when data: is from a json file. If it's a local variable it works fine, but I need it to work with .json for ajax.

Heres an example: http://embed.plnkr.co/giWBM1R2B0yzIr6xfSvq/

Hope someone can help

0xRoM avatar Sep 19 '18 18:09 0xRoM

I found a way to do it:

	subDomainTextFormat: function(date ,value) {
		var date = parseInt((new Date(date).getTime() / 1000).toFixed(0))
		var finval = 0;

		$.ajax({
			url: 'test.json',
			async: false,
			dataType: 'json',
			success: function (response) {
				$.each(response, function(i, field){
					if(date == i){
						console.log("found: "+field);
		        		finval = field;
		        		return finval;
		        	}
	        	})
			}
		});

		if (finval == 0){finval = "";}
		return finval;
	},

It's certainly not optimised and will get slower the more data there is and creates a LOT of requests... but it works!

0xRoM avatar Sep 20 '18 16:09 0xRoM

Just realised the last update was a year ago. Is project maintained anymore and likely to be patched?

0xRoM avatar Sep 22 '18 09:09 0xRoM

Having the same issue...was hoping to display values from my "week" subdomain into the cell.

@0xRoM thanks for the tip but it's going to be too much json to unpack quickly.

drgrubman avatar Feb 22 '21 15:02 drgrubman

Fixed in v4

wa0x6e avatar Nov 18 '22 16:11 wa0x6e