5

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 Answers 6

5

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]

Sign up to request clarification or add additional context in comments.

Comments

4

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 Comments

Thanks Sebastian Bochan ! How can I do the same thing with dataLabels also ? If you can give me the updated code, then I will accept your answer
Thhhhhhaaaannnnnkkkkksssss.... a lot my dear friend ! Can you please provide the links for further reference on prototyping ?
I wrap function from drilldown.src.js
@SebastianBochan any idea why I get Uncaught TypeError: point.doDrilldown is not a function ? I get that in your example too.
This code is broken. If you open a drill down by clicking a column and then clicking on drillUp button, it will rebuild all links except the last one. Also console is returning an error.
3

Or you can do it with css

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

Comments

2
{...
series: [],
drilldown: {
    activeAxisLabelStyle: {
        cursor: 'default',
        color: '#3E576F',
        fontWeight: 'normal',
        textDecoration: 'none'
    },
    activeDataLabelStyle: {
        cursor: 'default',
        color: '#3E576F',
        fontWeight: 'normal',
        textDecoration: 'none'
    }
}
}

1 Comment

While this code may answer the question, providing information on how and why it solves the problem improves its long-term value.
0

In drilldown just put

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

1 Comment

Note: It just change the looks, not the behavior. Means, though it makes label look normal, if the user accidently clicks on it, hyperlink behavior happens.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.