Enable the Drill Down feature in a Highcharts chart by interacting with a different chart through a manual click

Utilizing Highcharts for creating two charts within Angular (although that detail may not be relevant to the issue at hand) - a pie chart and a bar chart. I have both charts defined and my objective is to initiate a drill-down action in the bar chart upon clicking on the pie chart. The drill-down should happen using the same dataset. Below are the settings for these charts:

import Highcharts from 'highcharts/highstock';

export const MEDIA_CHART = {
chart: {
  height: 350,
  type: 'pie',
  width: 300
},
drilldown: {
 allowPointDrilldown: true
},
legend: {
 borderWidth: 0,
 enabled: true,
 symbolRadius: 0,
 title: {
  text: ''
},
useHTML: true,
/*eslint-disable*/
labelFormatter: function () {
  return '<div style="max-width:150px;"><span style="width:100%;display:block;text-align:center;">' + this.name + '</span><span>' + Highcharts.numberFormat(this.y, 2, ',', '.') + '€</span></div>';
}
/*eslint-enable*/
},
plotOptions: {
 pie: {
  center: ['48%', '42%'],
  showInLegend: true
 },
series: {
  allowPointSelect: true,
  cursor: 'pointer',
  /*eslint-disable*/
  events: {
    click: function (event) {
      console.log(TACTIC_CHART.chart.drilldownLevels.length);
    }
  },
  /*eslint-enable*/
  dataLabels: {
    enabled: true,
    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
  }
}
},
 series: [{
 size: '95%',
 innerSize: '60%'

}],
tooltip: {
borderWidth: 0,
backgroundColor: '#37474F',
headerFormat: '',
pointFormat: '{point.name}: {point.y:,.2f}€',
style: {
  color: '#fff',
  padding: 0,
  fontWeight: 700
},
useHTML: true
}
};

export const TACTIC_CHART = {
chart: {
 type: 'bar',
 height: '100%'
},
colors: ['#969696', '#F1292E', '#A0CB0E'],
drilldown: {
  allowPointDrilldown: true
},
xAxis: {
title: {
  text: null
},
 type: 'category'
},
yAxis: {
 min: 0,
 title: {
  text: 'Budget €',
  align: 'high'
},
labels: {
  overflow: 'justify'
}
},
tooltip: {
  enabled: true,
  borderWidth: 0,
  backgroundColor: '#37474F',
  headerFormat: '',
  pointFormat: '{series.name}: {point.y:,.2f}€',
  style: {
  color: '#fff',
  padding: 0,
  fontWeight: 700
},
  useHTML: true,
  valueSuffix: ' €'
},
title: {
align: 'left'
},
plotOptions: {
bar: {
  dataLabels: {
    enabled: true,
    /*eslint-disable*/
    formatter:  function () {
      return Highcharts.numberFormat(this.y, 2, ',', '.') + '€';
    }
    /*eslint-enable*/
  }
 }
},
legend: {
  enabled: true,
  layout: 'horizontal',
  align: 'center',
  verticalAlign: 'top',
  floating: true,
  borderWidth: 1,
  backgroundColor: '#FFFFFF',
  shadow: true
}
};

Within this section, I capture the click event on the pie chart:

events: {
    click: function (event) {
      console.log(TACTIC_CHART.chart.drilldownLevels.length);
    }
  },

I've attempted to retrieve this information but encounter an error cannot get length of undefined. Despite trying various solutions found, none have been successful. The main issue lies in the need to maintain the data for the bar chart without redrawing it, but rather activating the drill-down feature if feasible. Appreciate any assistance provided! Thanks.

Answer №1

If you want to trigger the internal function Point.doDrilldown() on a specific point of another chart during the drilldown event, and then use Chart.drillup() on the drillup event. Make sure to set up a flag variable to avoid an infinite loop. Check out the example below that I've prepared for you. If you have any questions, don't hesitate to ask.

For more information, refer to the API Reference:
http://api.highcharts.com/highcharts/chart.events.drilldown
http://api.highcharts.com/highcharts/chart.events.drillup

Here's an example demonstration:
http://jsfiddle.net/048kne3c/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the power of AngularJS with JSON datasets

While working on angularJS, I encountered a problem with calculating operations on JSON data. I need assistance in solving this issue. enter code hereCode snippet. In the "script.js" file, there is JSON data named "marksArray". My task is to calculate the ...

After the "div" tag comes the magic of AJAX, PHP, and JAVASCRIPT, replacing

My Ajax implementation is successfully displaying the selected content on a div, but unfortunately, everything that comes after the div is getting replaced by this output. I am unsure of why this is happening and how to resolve it. If you have any insigh ...

Retrieve the scrolling height in Vue.js 2 window

I need to apply the sticky class to the navbar when a user scrolls down, and remove it when they scroll back up. To achieve this, I am attempting to calculate the scrolled height. Currently, my code looks like: mounted(){ this.setUpRoutes(); wind ...

Executing JavaScript functions within static files in Django

I can't figure out why I'm unable to invoke a javascript function when clicking my Bootstrap button in a Django project. In my directory, I have set up the static folder as "main/static/main/js/script.js". While I can successfully load the stati ...

Using HTML and CSS to capture user input data and store it in an array

I've created a form that allows users to add and remove multiple fields, ranging from one to three. My goal is to retrieve the form data and store it in an array. index.html <!DOCTYPE html> <html lang="en"> <head> ...

A guide on utilizing express.js to retrieve and display the output of a mySql query

I am facing an issue with getting the results of my simple SELECT command into the index.js file. I want to store all the records in an array, but when I try to do so, I always end up with undefined values. Interestingly, if I print the results in the data ...

retrieve data from an asynchronous request

Utilizing the AWS Service IotData within an AWS Lambda function requires the use of the AWS SDK. When constructing the IotData service, it is necessary to provide an IoT endpoint configuration parameter. To achieve this, another service is utilized to obta ...

Generating Javascript code with PHP and handling quotes successfully

After encountering an issue with apostrophes causing errors in my PHP-generated HTML, I found a solution that involved using the addslashes() function. Here is the code snippet: <?php $lines = array(); $lines[] = "I am happy"; $lines[] = "I'm hap ...

ASP.NET repeater causing jQuery scrollTop to malfunction after first use

I am facing a peculiar issue where I need to scroll through repeater items in a RadWindow using arrow keys in an ASP.NET application. Below is the code snippet: function isScrolledIntoView(elem) { var docViewTop; var docViewBottom ...

Guide to testing express Router routes with unit tests

I recently started learning Node and Express and I'm in the process of writing unit tests for my routes/controllers. To keep things organized, I've split my routes and controllers into separate files. How should I approach testing my routes? con ...

Managing elements within another element in Angular

I am currently exploring the use of Component Based Architecture (CBA) within Angular. Here is the situation I am dealing with: I have implemented three components each with unique selectors. Now, in a 4th component, I am attempting to import these compon ...

Ensuring distinct characteristics within an array using JSON Schema and AJV

Here is a sample data snippet: "labels": [ {"name" : "sampleId", "value" : "12345"}, {"name" : "SAMPLEID", "value" : "12345"} ] I ...

Having trouble storing data in a database with PHP in an AngularJS application

<!DOCTYPE html> <html ng-controller="controller" ng-app="app"> username:<input type="text" placeholder="*username" ng-model="user"><br><BR> password:<input type="password" placeholder="*password" ng-model="pass" &g ...

What's causing my variables to be returned as null in the alerts?

Why am I receiving null values when alerting my variables? I'm attempting to pass a string stored in a variable from an external JavaScript file back to the main page using alerts. Initially, I suspected that the JavaScript was not fetching data cor ...

Unable to access the store from the Redux library within a React application

I decided to test out the Redux example from the official React-Redux website, which can be found HERE, using the following JavaScript code: // index.js import React from 'react' import ReactDOM from 'react-dom' import TodoApp from &ap ...

Unable to locate the module name loaded using require() function

Within my React file, I am importing a Javascript file like this (I am using Typescript): let FloDialog = require('../public/js/flo-dialog.min'); Afterwards, I declare a property for the dialog class: dialog: FloDialog = null; It is important ...

Activate the popup for sharing or bookmarking by clicking on a regular link

I am currently utilizing a Share/Bookmark script: <div class="singles-right"> <a href="#" class="bookmark"></a> <script type="text/javascript" src="http://static.addinto.com/ai/ai2_bkmk.js"></script> <a href="#" clas ...

The fading effects are not functioning as expected in the following code

Hey there, I'm not the most tech-savvy person, but I managed to come up with this code for page redirection. Unfortunately, I couldn't quite get the fade out and fade in effects to work properly when executing it. If anyone out there can help me ...

Div keydown event not being triggered in Vue

I've been struggling to get my event to fire despite following the instructions in the title. @keydown="keyPressed($event)" Although currently it looks like this, I have also attempted setting the tabIndex and adding it on mount as shown be ...

Substitute all web links contained within the DIV

Is there a way to change the URLs within a specific DIV? Here's an example of what I want to do: <div id="SearchList"> <a href="www.google.com/up">up</a> <a href="www.google.com/down">down</a> <a href="www.google.com/ ...