Skip to content

May 11, 2011

15

Making Highcharts support right-click context menu

by Joe Kuan

Currently, Highcharts (v2.1.4) doesn’t support (right click) context menu but this is in the feature request. Unfortunately, I don’t have the luxury to wait for the democratic process. So I did it the hard way and spent half a day to understand the Highcharts code and made the necessary changes to support right click context menu.

First, download and apply the patch diff to your Highcharts source code. Then to make the Highcharts context menu feature, you need to define the context menu event handler in the config, same as how you define click handler. Here is an example for a column chart:

....
plotOptions: {
   column: {
      allowPointSelect: true,
      events: {
         // Default action for (left) clicking the data
         click: function(point) {

         },
         // (Right-click) Create a menu for the data point
         contextmenu: function(point) {
            ....
         },
      }
   }
}
....

Here is a screenshot of my ExtJS (3.2) application integrated with HighChart and using context menu.

Tested on IE8, Safari 5 and Firefox. Let me know if you find any problem.

Advertisements
15 Comments Post a comment
  1. May 11 2011

    Awesome!! What version fo highcharts are you using this with?

    Reply
    • Joe Kuan
      May 12 2011

      2.1.4 (the latest one), also I have tried the changes with 2.1.0 and it works fine.

      Reply
  2. Dec 2 2011

    Hi, seems you understand both highchart and extjs. Do you also know if highcharts can be integrated with Jasper reports? http://http://jasperforge.org/

    Reply
    • Dec 2 2011

      link is jasperforge.org/

      Reply
      • Joe Kuan
        Dec 3 2011

        Sorry, I have no experience of Jasper. However, Highcharts have pretty flexible interfaces, it may be possible to integrate.

  3. Any plan to migrate the patch to current version (2.3.3)?
    It would be very handy to isolate the changes in order to be able to use future HighSoft’s updates as well as yours

    Reply
    • Hi there,
      Did you see my previous message? Just in case you did not:
      Any plan to migrate the patch to current version (2.3.3)?
      It would be very handy to isolate the changes in order to be able to use future HighSoft’s updates as well as yours

      Reply
      • I forgot to ask:
        how to use it without loosing future releases?

      • Joe Kuan
        Oct 31 2012

        Sorry for the late reply. No for two reasons:

        1) Involves changing source code and actually not straightforward. Also I have to keep up with the Highcharts regular release. This feature should really be supported by Highcharts instead of contribution.

        2) Insanely busy. Too many family issues lately + writing Highcharts book + demanding work + other projects to maintain

      • Hello Joe,
        Thanks for your response and I agree with you in “This feature should really be supported by Highcharts”

  4. Hi Joe: your contribution was just converted to a plugin in the Highcharts user voice site as a workaround to keep the context menu code separated from the official release. I see it was wrapped into the Highcharts.wrap method to keep current functionality plus plugin functionality. Thanks again,

    Reply
    • Joe Kuan
      Nov 5 2012

      Thanks again. Nice work

      Reply

Trackbacks & Pingbacks

  1. links for 2011-06-10 « Caiwangqin’s delicious bog
  2. Highcharts right-click support: An example of community contributions « Javier Andres Caceres Alvis – C# para Windows Phone 7
  3. Highcharts right-click support: An example of community contributions « MVPs de LATAM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

%d bloggers like this: