1

I am trying to draw multiple polygons in highcharts and it can be achieved by inserting null separating the polygons in highcharts.

$('#container').highcharts({
    series: [{
        name: 'Polygons',
        type: 'polygon',
        data: [
            [2, 100],
            [3, 100],
            [3, 200],
            [2, 200],
            null, // allows multiple polygons         
            [6, 100],
            [8, 100],
            [8, 200],
            [6, 200]
        ]
    }, {
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]

});

What is the equivalent way to achieve in python using justpy? Currently I have to create two polygons seperately:

import justpy as jp

chart_dict = {
    'series': [{'name': 'Polygons',
                'type': 'polygon',
                'data': [[2, 100],
                         [3, 100],
                         [3, 200],
                         [2, 200]]},
               {'name': 'Polygons',
                'type': 'polygon',
                'data': [[6, 100],
                         [8, 100],
                         [8, 200],
                         [6, 200]]
                }, {
                   'data': [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
               }]}

def load():
    wp = jp.WebPage()
    chart = jp.HighStock(a=wp, options=chart_dict)
    return wp

jp.justpy(load)

I have tried combining them and use None to separate but it didn't work.

william wong
  • 21
  • 1
  • 4
  • Hi @william wong, I am not a python expert, but you probably need to use `json.dumps` method to convert `None` to `null`. Docs: https://docs.python.org/3/library/json.html – ppotaczek Jan 28 '22 at 13:36

0 Answers0