Can not display date/time when plot
Closed this issue · 5 comments
Thanks for the great tool!
I tried to plot charts using F4 shortcut, but it can't read date/time.
res2: ([] x: til 10; y: sin(til 10)) \ this works
res3: ([] ts: 2020.01.07 + til 10; y: sin(til 10)) \ this doesn't
Could you please suggest? Thanks.
Thanks for the comment and for raising the issue!
To debug the issue, could you tell me the following?
- what kdb version are you using?
- what's the result of
.j.j res3
? (it should look like this"[{\"ts\":\"2020-01-07\",\"y\":0}...
) - what do you see in the plot? do you see any error in developer console? (if you are using mac, go to View/Developer/Javascript Console)
- can you try this in the console and tell me what you see? (put in the date you see in no. 2)
>new Date("2020-01-07")
Tue Jan 07 2020 09:00:00 GMT+0900 (Japan Standard Time)
@komsit37 Thanks.
I'm working on win7 and default browser is IE 11. Regarding to your question:
- kdb version: 3.5
- output of .j.j res3 is as expected.
- To compare with your attached plot for res3, on my side I do not have x-axis as well as the blue line, just blank. There is no error in developer console, also the script block shows
<script type="text/javascript"> window.onload = function () { var chart = new CanvasJS.Chart("chartContainer", chartObj); chart.render(); } var chartObj = {"zoomEnabled":true,"axisX":{"labelAngle":-30},"axisY":{"includeZero":false},"toolTip":{"content":"{x}<br/><span style='\"'color: {color};'\"'>{name}</span>: <strong>{y}</strong><br/>{z}"},"data":[{"type":"line","markerType":"none","name":"y","axisYType":"primary","dataPoints":[{"x":"2020-01-07","y":0},{"x":"2020-01-08","y":0.841471},{"x":"2020-01-09","y":0.9092974},{"x":"2020-01-10","y":0.14112},{"x":"2020-01-11","y":-0.7568025},{"x":"2020-01-12","y":-0.9589243},{"x":"2020-01-13","y":-0.2794155},{"x":"2020-01-14","y":0.6569866},{"x":"2020-01-15","y":0.9893582},{"x":"2020-01-16","y":0.4121185}],"showInLegend":true}]}; chartObj.data = formatCanvasJsData(chartObj.data); </script>
- The output is
>new Date("2020-01-07") [date] Mon Jan 06 2020 19:00:00 GMT-0500 (Eastern Standard Time)[date] Mon Jan 06 2020 19:00:00 GMT-0500 (Eastern Standard Time)
also attribute proto shows[date] Invalid Date?
Sorry I'm not able to show you screenshot, please let me know anything that might help, thanks.
can you try this in your browser console? i'm guessing you have have invalid date or a string in your x
>formatCanvasJsData(chartObj.data)[0].dataPoints[0]
{x: Tue Jan 07 2020 09:00:00 GMT+0900 (Japan Standard Time), y: 0}
do you have chrome or other browsers? can you try to open the same url on those?
Thanks! I should have tried to use chrome. It works well in Chrome. Could you please suggest how to make my chrome default browser when plot? I tried modified/installed package, not work yet.
Ok thanks. Can you help me test the fix in this branch?
https://github.com/komsit37/sublime-q/tree/fix-browser-compat
- improve js date parsing for other browser. hopefully this will work on IE. If this works, can you try with date time and timestamp column as well?
- if you want to use other browser, you can add this key to your Package Settings/sublime-q/Settings - User
"browser": {
"browser_type": "chrome"
}