Highcharts Column chart with flattening, removing hyperlinks, like formatting with labels on the x axis

I use column chartwith drilldown. Here is my JSFIDDLE .

Now my problem is:

  • I want to remove a hyperlink, such as formatting, from labels on the x axis and dataLabels

As you might have noticed from my violin, I already tried to apply formatting on the labels of the x axis using code like:

xAxis: {
         type: 'category',
         labels:{
               style:{
                    color: 'red',
                    textDecoration:"none"
               }
         } 
      },

and used the following code to format dataLabels:

plotOptions: {
                    series: {
                        borderWidth: 0,
                        dataLabels: {
                            enabled: true,
                            format: '{point.y:.1f}%',
                            style:{
                               color: 'blue',
                               textDecoration:"none"
                            }
                        }
                    }
                }

But the problem is that formatting only works for these x-axis labels and dataLabels that do not have drilldown data . Although it works on all x-axis labels and dataLabels of expanded data!

: http://api.highcharts.com/highcharts#xAxis.labels.style http://api.highcharts.com/highcharts#series.data.dataLabels

!

+4
4

, .

http://jsfiddle.net/phpdeveloperrahul/FW64T/

 (function (H) {
    H.wrap(H.Point.prototype, 'init', function (proceed, series, options, x) {
        var point = proceed.call(this, series, options, x),
            chart = series.chart,
            tick = series.xAxis && series.xAxis.ticks[x],
            tickLabel = tick && tick.label;

        if (point.drilldown) {

            // Add the click event to the point label
            H.addEvent(point, 'click', function () {
                point.doDrilldown();
            });

            // Make axis labels clickable
            if (tickLabel) {
                if (!tickLabel._basicStyle) {
                    tickLabel._basicStyle = tickLabel.element.getAttribute('style');
                }
                tickLabel.addClass('highcharts-drilldown-axis-label')          .css({
                    'text-decoration': 'none',
                    'font-weight': 'normal',
                    'cursor': 'auto'
                    })
                    .on('click', function () {
                    if (point.doDrilldown) {
                        return false;
                    }
                });

            }
        } else if (tickLabel && tickLabel._basicStyle) {
        }

        return point;
    });
})(Highcharts);
+4

css

.highcharts-drilldown-axis-label{
text-decoration: none !important;
}
+3

activeAxisLabelStyle: {
    cursor: 'pointer',
    color: '#0d233a',
    fontWeight: 'bold',
    textDecoration: 'none'          
}
0
source

If you have a chart where only the column selection has a sweep, Sebastian Boch's answer should be changed so that all the columns have the same label:

(function (H) {
            //DATALABELS
            H.wrap(H.Series.prototype, 'drawDataLabels', function (proceed) {
                var css = this.chart.options.drilldown.activeDataLabelStyle;
                proceed.call(this);

                css.textDecoration = 'none';
                css.fontWeight = 'normal';
                css.cursor = 'default';
                css.color = 'blue';

                H.each(this.points, function (point) {

                    if (point.dataLabel) { // <-- remove 'point.drilldown &&' 
                        point.dataLabel
                            .css(css)
                            .on('click', function () {
                                return false;
                            });
                    }
                });
            });
        })(Highcharts);

Also note that these settings are global, so they also affect any other charts you may have.

0
source

Source: https://habr.com/ru/post/1546306/


All Articles