0

The issue is highchart is not able to render dates which is stored in monogdb. My date format is 2019-03-15T12:58:02. And below is the code what I am rendering in my javascript/highchart

Below is the date which is being stored in my mongodb

{'setnumlow': 6.0, 'setnum': 11.8, 'setnumdate': u'2019-03-15T12:58:02', 'setnumhigh': 18.0}

And My javascript code is shown below:

var ranges = [
        {% for i in mobu %}
        [{{ i.setnumdate }},{{ i.setnumlow }},{{ i.setnumhigh }}],  
        {% endfor %} 
        ],

My knowledge on javascript/highchart is less, so I am not sure how should I render it. Is there a way to convert the date to javascript format (on which highchart understands)

My flask code

for i in set2:
                mobu.append({
                "setnumdate":(i['date']),
                "setnum":(i['setnum']),
                "setnumhigh":(i['setnumhigh']),
                "setnumlow":(i['setnumlow'])
                })

Below is the output which I am getting from "Inspect Element"

enter image description here

So without touching the mongodb database, how can i convert the date to understandable javascript/highchart format

fear_matrix
  • 4,912
  • 10
  • 44
  • 65
  • you really should prepare a JSON in your flask route and send that JSON to be rendered by highcharts instead of looping in your html – Steven G Mar 15 '19 at 11:43
  • For `datetime` axes, the X value is the timestamp in milliseconds since 1970. So you should convert your dates first and then pass them to `ranges` array as a timestamp. – Wojciech Chmiel Mar 15 '19 at 11:55

0 Answers0