0

below I send example of candlestick charts.js date structure - (JSON type):

 <script>
    const data1 = luxon.DateTime.fromRFC2822('15 Dec 2021 00:00 GMT');
    const date2 = luxon.DateTime.fromRFC2822('16 Dec 2021 00:00 GMT');
    const data = {
      datasets: [{
        data: [
        {
          x: data1.valueOf(),
          o: 1,
          h: 0.75,
          l: 0.75,
          c: 1.25
        },
        {
          x: date2.valueOf(),
          o: 1.20,
          h: 1.5,
          l: 0.75,
          c: 0.9
        }
        ],
      }]
    };

    // config 
    const config = {
      type: 'candlestick',
      data,
      options: {}

    };

    // render init block
    const myChart = new Chart(
      document.getElementById('myChart'),
      config
    );
    </script>

It seems similar to serializers? So I wonder if it is possible to send it in context to make this json like data

enter image description here

And seems...

const data = {{data}}

enter image description here doesn't work... :)

Marcixen
  • 31
  • 4
  • Does this answer your question? [Creating a JSON response using Django and Python](https://stackoverflow.com/questions/2428092/creating-a-json-response-using-django-and-python) – JonSG Feb 04 '22 at 17:39
  • Not really, I'm looking for serialized data from db, In my example I use rest framework – Marcixen Feb 04 '22 at 17:50
  • 1
    You seem to be returning a string version of your python dictionary. You probably want to use `json.dumps()` or `django.http.JsonResponse()` on your dictionary when returning it. – JonSG Feb 04 '22 at 17:55

0 Answers0