How can i write javascript functions inside configurations using python

Hi, @Team quick chart below is my code, I want to convert my point’s background color according to the y-axis scale.
Please help me with this

js_point_color_formatter = """
    function(context) {
        var yValue = context.dataset.data[context.dataIndex];
        if (yValue <= 10) {
            return 'green';
        } else if (yValue > 10 && yValue <= 20) {
            return 'red';
        } else {
            return 'blue';
        }
    }
"""
options = {
    "devicePixelRatio": 2,
    "format": "png",
    "backgroundColor": "#ffffff",
    'chart':{
    'type': 'line',
    'data': {
        'labels': ['January', 'February', 'March', 'April', 'May'],
        'datasets': [{
            'label': 'Sales',
            'data': [12, 19, 3, 5, 2],
            'pointBackgroundColor': json.loads(json.dumps(js_point_color_formatter)),
            'borderColor': 'rgba(255, 99, 132, 1)',
            'borderWidth': 1
        }]
    },
    'options': {
        'scales': {
            'y': {
                'beginAtZero': True
            }
        }
    }
}
}
def convert_config_to_graph():

   response = requests.post("https://quickchart.io/chart", json=chart_config)
    if response.status_code != 200:
        print('error',response.status_code)
    else:
        with open('chart.png', 'wb') as f:
            f.write(response.content)

Hi @pranuu91,

The easiest way is to use the quickchart-io python package.

One option is to define the configuration as a string, and substitute your function: code example

Another option is to use QuickChartFunction to define your function: code example

Hope this helps!