5
votes

I am using column chart with drilldown. Here is my JSFIDDLE.

Now my problem is:

  • I want to remove hyperlink like formatting from the labels on x-axis and dataLabels

As you would be able to notice from my fiddle that I have already tried to apply formatting on the x-axis labels by using the code like:

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

and used 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: The formatting only works for that x-axis labels and dataLabels that does not have drilldown data. While it works on all the x-axis labels and dataLabels of drilldowned data !

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

Any help would be greatly appreciated !

6

6 Answers

4
votes

You need to overwrite drilldown function, to avoid add action to labels.

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);
5
votes

We can use drilldown option to control the drilldown.

 drilldown: {
//for axis label
        activeAxisLabelStyle: {
            textDecoration: 'none',
            fontStyle: 'italic'
        },
//for datalabel
        activeDataLabelStyle: {
            textDecoration: 'none',
            fontStyle: 'italic'
        }
}

[Reference:http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/drilldown/labels/][1]

3
votes

Or you can do it with css

.highcharts-drilldown-axis-label{
text-decoration: none !important;
}
1
votes
{...
series: [],
drilldown: {
    activeAxisLabelStyle: {
        cursor: 'default',
        color: '#3E576F',
        fontWeight: 'normal',
        textDecoration: 'none'
    },
    activeDataLabelStyle: {
        cursor: 'default',
        color: '#3E576F',
        fontWeight: 'normal',
        textDecoration: 'none'
    }
}
}
0
votes

In drilldown just put

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

In case you have a chart where only a selection of columns have drilldowns, Sebastian Bochan's answer needs to be modified so that all 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 also affect any other charts you may have.