Reputation: 1938
I am making a chart using AmCharts. This is my stocklegend
section.
"stockLegend": {
"valueTextRegular": "[[time]]:[[value]]"
}
(Here, time is Date obj converted from timestamp that was present in json dataset loaded in javascript object used as data provider for chart. "dataProvider": consChartData.Data
where Data is an array holding value & time for a data point.)
Using [[time]]:[[value]]
, what I am getting is this:
The way I want it is like: Dec 23 2017, 5:21:00 IST: 17,686.54. Is there any way to format the [[time]] here in the way I want?
This question was not solved by How to format a JavaScript date because, if I use that here, it would be like "valueTextRegular":dateFormat("[[time]]") + "[[value]]",
. I have to make a new Date object from passed time and then it shows:
"NaN undefined NaN 17,686.54"
in output.
Upvotes: 1
Views: 435
Reputation: 6162
You will need to use StockLegend's valueFunction to format the date:
"valueFunction": function (panel, value) {
var category = panel.category;
if (category && category instanceof Date) {
// Dec 23 2017, 5:21:00 IST: 17,686.54
return [AmCharts.formatDate(category, "MMM D YYYY, H:N:SS"), " IST: ", panel.dataContext.value].join("");
}
return value;
}
Please check the links below:
Upvotes: 2