typpo / quickchart-java

Java client for quickchart.io chart API
10 stars 1 forks source link

Option section not working in chart, affecting generated image #6

Closed alidehkhodaei closed 1 year ago

alidehkhodaei commented 1 year ago

When using the outlabeled Pie chart, the option section does not seem to be working properly. I set options. but they do not affect the generated chart image.

{
  "type": "outlabeledPie",
  "data": {
    "labels": ["ONE", "TWO", "THREE", "FOUR", "FIVE"],
    "datasets": [{
        "backgroundColor": ["#FF3784", "#36A2EB", "#4BC0C0", "#F77825", "#9966FF"],
        "data": [1, 2, 3, 4, 5]
    }]
  },
  "options": {
    "plugins": {
      "legend": false,
      "outlabels": {
        "text": "%l %p",
        "color": "white",
        "stretch": 35,
        "font": {
          "resizable": true,
          "minSize": 12,
          "maxSize": 18
        }
      }
    }
  }
}

This is affecting my ability to customize the chart output. Please advise on any known fixes or workarounds for this issue. Let me know if any other information would be helpful in debugging this problem.

typpo commented 1 year ago

Hi @alidehkhodaei,

The Chart.js outlabels plugin is unfortunately sensitive to the size and DPI of the canvas. If the labels are not showing up, that's because it can't quite fit the labels in your chart's dimensions, not because options isn't working at all.

In many cases, if you set devicePixelRatio to 2.0 and/or if you increase the size of the image in your request, it will likely be able to fit the outlabels. You might have to play around with the size and resolution a bit.

alidehkhodaei commented 1 year ago

Thank you, I used a different chart type and i will test it again later. I am closing this issue.