Browsing through the highcharts visualization graph

My current project involves developing a hybrid app using the phonegap framework, and I have decided to incorporate graphs using the highcharts library.

However, I am facing an issue where I am unable to scroll after interacting with the chart within the app. I would like the chart to be passive, not capturing any events, and allow for smooth scrolling even over the chart area.

To achieve this, I have included the following code snippet:


chart1 = new Highcharts.Chart({
  chart: {
    renderTo: 'containerBar',
    animation: false,
    type: 'bar',
    events: {
      click: function(event){
        return false;
      }
    }
  },
  scrollbar: {
    enabled: true
  },
  title: {
    text: 'Fruit Consumption'
  },
  plotOptions: {
    bar: {
      events: {
        click: function(event){
          return false;
        },
        mouseOver: function(event){
          return false;           
        },
        legendItemClick: function () {
          return false;
        }
      },
      states: {
        hover: function(){
          alert("Allow");
        }
      }
    }
  },
  events: {
    click: function(e) {
      alert("Click");
    }  
  },
  xAxis: {
    categories: ['Apples', 'Bananas', 'Oranges']
  },
  yAxis: {
    title: {
      text: 'Fruit eaten'
    }
  },
  tooltip: {
    enabled: false
  },
  series: [{
    name: 'Jane',
    data: [1, 3, 4]
  }, {
    name: 'John',
    data: [5, 7, 3]
  }]
});

Answer №1

For those interested in the evolution of scrolling issues with Highcharts visualizations, a solution was implemented in Version 3.0.1 (2013-04-09). A similar update was also applied to Highstock with Version 1.3.1 (2013-04-09).

A new option, tooltip.followTouchMove, was introduced. When set to true, the tooltip can be dragged using a single finger on the chart, reminiscent of functionality in Highcharts 2. If set to false, dragging a single finger will not interact with the chart and instead scroll the entire page. This behavior occurs only when zooming is disabled.

Additional improvements were included in Highcharts Version 4.1.0 (2015-02-16):

The default setting for tooltip.followTouchMove was changed to true, allowing page scrolling simultaneously.

To view the full Highcharts change log, visit http://www.highcharts.com/documentation/changelog.

Answer №2

The issue arises from Highcharts intercepting all touch events and rendering them inactive. To resolve this, I devised a solution by simply placing a div on top of the chart section on mobile devices to block these events from reaching Highcharts elements (allowing them to trigger default actions such as page scrolling). Below is the JavaScript code I used (assuming JQuery or similar library is also utilized):

$('.highcharts-container').each(function() {
  var dragHandle;
  dragHandle = $('<div class="chart-drag-handle">');
  $(this).append(dragHandle);
  dragHandle.on('touchstart', function(e) {
    e.stopPropagation();
  });
  dragHandle.on('touchmove', function(e) {
    e.stopPropagation();
  });
  dragHandle.on('touchend', function(e) {
    e.stopPropagation();
  });
  dragHandle.on('touchcancel', function(e) {
    e.stopPropagation();
  });
});

To ensure proper overlay of the chart area with the added elements, styling adjustments were necessary. Here's how I formatted it:

.highcharts-container .chart-drag-handle {
  position: absolute;
  height: 100%;
  width: 100%;
  top: 0;
  z-index: 100;
}

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

Display information in a box when hovering using CSS and JQuery

I'm looking for an Info-Box (with the code <div class="inner">...</div>) that can determine if there is enough space available on the right, left, up, or down to display and adjust accordingly. While I've managed to check the space o ...

Determine if a property of an object is an empty string in React Native

I am facing a situation where I have an object that may or may not have an image URL. { id: 1, term: "Research", imageURL: "", definition: "is a way of thinking and understanding various aspects of a procedure ...

Using knockout to retrieve the attribute value with an onClick event

Snippet of HTML View with attribute value 'Qref'. This is the sample HTML Code for binding Currently, I have manually inputted the Qref Attribute value <!--ko if:$parent.Type == 2 --> <input type="checkbox" data-bind="attr:{id: $data ...

Updating the id token in VueJs using Axios interceptor when it expires

I need to implement an axios interceptor that will add the idToken as an authorization header to every axios call, and also refresh the idToken if it has expired before making any call. My current code for this task is as follows: axios.interceptors.requ ...

In Angular, what is the best way to change the format of the timestamp '2019-02-22T12:11:00Z' to 'DD/MM/YYYY HH:MM:SS'?

I am currently working on integrating the Clockify API. I have been able to retrieve all time entries from the API, which include the start and end times of tasks in the format 2019-02-22T12:11:00Z. My goal is to convert the above date format into DD/MM/Y ...

Utilizing jQuery to extract the `h1` element from a dynamically loaded external page within the

I am facing a challenge in selecting an h1 element from a remote page that I have loaded into $(data). Despite several attempts, I am struggling to write the correct code. When I use this code: console.log($(data)); The output is as follows: [text, meta ...

"Utilize jQuery to target textboxes that are positioned below others, rather than adjacent to them

My goal is to focus on textboxes that are arranged vertically, one below the other. However, when I write a query for pressing "Enter" to act as a tab key, the focus does not shift to the next adjacent textbox. Instead, I want the focus to move to the text ...

Unable to get click function to work with multiple div elements

Using four div elements, I have implemented a feature where clicking on the first div causes all other div elements to change opacity. This is working correctly. However, I would like the opacity of the first div to remain unchanged when moving to another ...

Transmitting JSON data object

Sending a JSON Object to JSP Page After following the provided link, I discovered that one of the answers suggests creating a JSON object using the following constructor: JSONObject jsonObj=new JSONObject(String_to_Be_Parsed); Upon downloading the JSON ...

Creating a hierarchical tree visualization with React JS using JSON data

As a newcomer to React JS, I've been working on a project for the past three days and need some help. My task is to create a category list structured like this: Category1 ->Sub-Category1 ->Sub-Category2 Category2 Category3 . . . CategoryN I h ...

Is there a way to efficiently return an array of object and nested object keys with their full paths through recursion

My grasp of JS is still in its early stages, so understanding how the stack and recursion function can be challenging for me at this point. The task at hand involves displaying an array of object keys, including the parent object name if the object is nest ...

execute field function prior to sorting

Currently, I am building a graphql server in express and using a resolver to modify my fields based on user input from the query. The issue arises from the transformer function returning a function. My goal is to sort the results by a field determined by ...

Tips for efficiently reading a large volume of documents (1M+) from a collection in Cloud Firestore?

Encountering an error of 9 FAILED_PRECONDITION: The requested snapshot version is too old. const ref = db.collection('Collection'); const snapshot = await ref.get(); snapshot.forEach((doc,index) => { ...utilize data }) Want to retrieve all ...

What is causing the malfunction of these three links?

Discover the yellow section below the images labeled "Read more about /college/" on . The first 3 links (Columbia, Princeton, and Brown) are not functioning properly, while the others are. An error in JavaScript is being raised stating Uncaught Error: Syn ...

What causes the output of Math.pow(a, b) to be NaN when the value of a is negative and b is not a whole number?

After observing different JavaScript behaviors, I noticed the following: > Math.pow(4, 2) 16 > Math.pow(4, 2.1) 18.37917367995256 > Math.pow(4, 0.5) 2 > Math.pow(-4, 2) 16 > Math.pow(-4, 2.1) NaN > Math.pow(-4, 0.5) NaN Why does using a ...

The issue of Access-Control-Allow-Origin not functioning properly when using Ajax for a POST request

I am encountering an issue with the header "Access-control-allow-origin" when making a request using the following code: <script type='text/javascript'> function save() { $.ajax( { type: 'POST', ur ...

"Encountering an error stating "breakpoint set but not yet bound" while debugging a node.js application

After following the instructions in this link to configure Visual Studio code for debugging nodejs and chrome(vuejs) applications, I encountered an error message saying "Failed to exec debug script" when attempting to debug "Meteor All" in Visual Studio co ...

Guide on separating a variable by commas using jQuery

After making an Ajax call to a Java servlet, I am retrieving data and storing it in the 'data' variable upon success. Here is the code snippet: var s1=""; var ticks =""; $('#view').click(function(evt ...

My Node.js environment is unable to recognize the Express object, causing issues with setting paths for my CSS and JavaScript files

Check out the following link for more information: http://expressjs.com/en/starter/static-files.html I'm currently utilizing sockets.io: const PORT = 3000; var objServer = require('express')(); var http = require('http').Server(o ...

Iterating through a jQuery function to increment value

I have encountered an issue while trying to calculate the total value from an array of form fields. The problem lies in how the final value is being calculated on Keyup; it seems that only the last inputted value is being added instead of considering all t ...