komsit37 / sublime-q

Sublime Text Plugin for q/kdb
MIT License
24 stars 9 forks source link

Can not display date/time when plot #22

Closed heeryerate closed 2 years ago

heeryerate commented 4 years ago

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.

komsit37 commented 4 years ago

Thanks for the comment and for raising the issue!

This works fine on my mac. image

To debug the issue, could you tell me the following?

  1. what kdb version are you using?
  2. what's the result of .j.j res3? (it should look like this "[{\"ts\":\"2020-01-07\",\"y\":0}...)
  3. 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)
  4. 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)
heeryerate commented 4 years ago

@komsit37 Thanks.

I'm working on win7 and default browser is IE 11. Regarding to your question:

  1. kdb version: 3.5
  2. output of .j.j res3 is as expected.
  3. 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>
  4. 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.

komsit37 commented 4 years ago

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?

heeryerate commented 4 years ago

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.

komsit37 commented 4 years ago

Ok thanks. Can you help me test the fix in this branch? https://github.com/komsit37/sublime-q/tree/fix-browser-compat

  1. 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?
  2. if you want to use other browser, you can add this key to your Package Settings/sublime-q/Settings - User
    "browser": {
    "browser_type": "chrome"
    }

    see https://github.com/komsit37/sublime-q/blob/fix-browser-compat/settings/sublime-q.sublime-settings#L12