apexcharts / apexcharts.js

📊 Interactive JavaScript Charts built on SVG
https://apexcharts.com
MIT License
14.05k stars 1.28k forks source link

3.37.0 Broke annotations on category x-axis #3654

Open sacalata opened 1 year ago

sacalata commented 1 year ago

Description

Annotations on an category x-axis are no longer rendered on charts in the latest 3.37.0 release.

This can be observed in the documentation

Steps to Reproduce

  1. Create a chart with the following code on version 3.37.0 :

    var options = {
          series: [{
          name: 'Servings',
          data: [44, 55, 41, 67, 22, 43, 21, 33, 45, 31, 87, 65, 35]
        }],
          annotations: {
          points: [{
            x: 'Bananas',
            seriesIndex: 0,
            label: {
              borderColor: '#775DD0',
              offsetY: 0,
              style: {
                color: '#fff',
                background: '#775DD0',
              },
              text: 'Bananas are good',
            }
          }]
        },
        chart: {
          height: 350,
          type: 'bar',
        },
        plotOptions: {
          bar: {
            borderRadius: 10,
            columnWidth: '50%',
          }
        },
        dataLabels: {
          enabled: false
        },
        stroke: {
          width: 2
        },
    
        grid: {
          row: {
            colors: ['#fff', '#f2f2f2']
          }
        },
        xaxis: {
          labels: {
            rotate: -45
          },
          categories: ['Apples', 'Oranges', 'Strawberries', 'Pineapples', 'Mangoes', 'Bananas',
            'Blackberries', 'Pears', 'Watermelons', 'Cherries', 'Pomegranates', 'Tangerines', 'Papayas'
          ],
          tickPlacement: 'on'
        },
        yaxis: {
          title: {
            text: 'Servings',
          },
        },
        fill: {
          type: 'gradient',
          gradient: {
            shade: 'light',
            type: "horizontal",
            shadeIntensity: 0.25,
            gradientToColors: undefined,
            inverseColors: true,
            opacityFrom: 0.85,
            opacityTo: 0.85,
            stops: [50, 0, 100]
          },
        }
        };
    
        var chart = new ApexCharts(document.querySelector("#chart"), options);
        chart.render();

Expected Behavior

Annotations are rendered on the chart

Actual Behavior

Annotations are NOT rendered on the chart

Screenshots

PREVIOUS VERSION:

image

3.37.0:

image

Reproduction Link

https://apexcharts.com/javascript-chart-demos/column-charts/column-with-rotated-xaxis-labels/

canblt commented 1 year ago

any updates for that issue ?

mygpse commented 1 year ago

Move the code snippet (this works on 3.37.0) if (w.config.annotations.position === 'back') { w.globals.dom.Paper.add(w.globals.dom.elAnnotations); me.annotations.drawAxesAnnotations(); } from line 32183 to line 32137.

position: 'back' no work image

position: 'back' will work image

pav-stastny commented 3 months ago

Move the code snippet (this works on 3.37.0) if (w.config.annotations.position === 'back') { w.globals.dom.Paper.add(w.globals.dom.elAnnotations); me.annotations.drawAxesAnnotations(); } from line 32183 to line 32137.

This is not a proper fix. What if we are using normal npm module? Then what? IMO this is uninentional breaking change.