Django, xhtml2pdf cannot add to canvas properties

I'm trying to create some pdf bar charts in my Django project using xhtml2pdf (which I find easier to use than ReportLab and better than Weasyprint). I can use the example given in the xhtml2pdf docs using my own data and labels and can change any of the existing canvas properties but cannot add any new properties. My understanding is that the canvas properties that xhtml2pdf uses are derived from ReportLab Graphics converted to a dictionary.

My HTML code is:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vertical bars</title>
</head>
<body>
<canvas type="graph" width="350" height="150">
      {
            "data": [{{ data1 }}, {{ data2 }}],   # <-- Can add data & labels here
            "labels": {{ labels }},
            "title": {"_text": "Number of Orders by Destination", "x": 290, "y": 155},
            "x_title": 290, "y_title": 155,
            "type": "verticalbar",
            "fillColor" : "#000000",  #  <-- (added) cannot change color
            "x": 150, "y": 50,
            "barLabelFormat": "%2.0f",
            "barLabels": {"nudge": 7},
            "valueAxis": {"valueStep": 40, "valueMin" : 0},  #  <-- (added) property ignored
            "categoryAxis": {
                  "strokeColor": "#000000",  #  <-- changed
                  "labels": {"angle": 0, "boxAnchor": "n", "dy": -6, "fontName": "Helvetica", "fontSize": 8, "textAnchor": "middle"}
            }
      }
</canvas>
</body>
</html>

How can I add properties to an xhtml2pdf html page? Specifically what I want to do is to change the graphic background to white one (None?)

Вернуться на верх