Search code examples
angularapexcharts

Apex Charts - Unable to hide data labels and set colours values


I've created a pie chart following the base documentation for Apex Charts, and I seem to be unable to hide the data labels on my pie chart (and set the colors as well).

Code sandbox - https://codesandbox.io/s/apx-pie-simple-forked-qlgxz

Colors documentation - https://apexcharts.com/docs/options/colors/

Data Labels documentation - https://apexcharts.com/docs/options/datalabels/

Any help would be appreciated.


Solution

  • Upon further investigation, it appears that the issue I had was due to responsive breakpoints within the chart, which I had to set these colours at each break point respectively. I haven't yet found an improved solution.

          responsive: [
        {
          breakpoint: 768,
          options: {
            chart: {
              height: 130,
            },
            dataLabels: {
              enabled: false,
            },
            legend: {
              position: "left",
              labels: {
                colors: "#FFFFFF",
                useSeriesColors: false,
              },
            },
          },
        },
        {
          breakpoint: 5000,
          options: {
            colors: ["Red, Green", "Blue"],
            dataLabels: {
              enabled: false,
            },
            legend: {
              labels: {
                colors: "#FFFFFF",
                useSeriesColors: false,
              },
            },
          },
        },
      ],