Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8186091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:04:31+00:00 2026-06-07T02:04:31+00:00

In highcharts I’m trying to add a drag-effect to point’s datalabel. I’ve found a

  • 0

In highcharts I’m trying to add a drag-effect to point’s datalabel. I’ve found a couple of ways to target a given label. In this fiddle you can see some of my attempts. (I’ve combined to different attempts in one fiddle here to show off what I’ve tried)

http://jsfiddle.net/EjwaX/3/

Now both using chart.series[0].data[0].dataLabel and using the points click event makes me able to change the attributes of a dataLabel. However I’m not able to attach a jquery ui .draggable() to the label. Is is somehow possible to make an element inside a chart draggable?

Please let me know if any more information is needed

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:04:33+00:00Added an answer on June 7, 2026 at 2:04 am

    You can actually attach draggable widgets to the data labels just fine. However, since the data labels are SVG elements, they completely ignore changes made to their position, left and top CSS properties.

    Instead, the <g> elements that wrap the labels expose a transform attribute:

    <g zIndex="1" transform="translate(9, 152)">
        <!-- data label content -->
    </g>
    

    We can still use the draggable widget (which is quite handy because it abstracts the lower-level drag events) and update the transform attribute of the data label wrappers in a drag event handler. Since drag coordinates are relative, we’ll have to parse the original transform attribute and use the resulting coordinates as the origin.

    Now, all the label wrappers are themselves children of groups decorated with the highcharts-data-labels class. This provides us with a good starting point, so we can write something like:

    $(".highcharts-data-labels").children().filter(function() {
        var $this = $(this);
        // Parse original translation.
        var coords = $this.attr("transform")
                          .match(/translate\((-?\d+),\s*(-?\d+)\)/);
        if (coords) {
            // Associate origin with element.
            return $this.data("origin", {
                x: +coords[1],
                y: +coords[2]
            });
        } else {
            // Parsing failed, reject element.
            return false;
        }
    }).draggable({
        drag: function(event, ui) {
            var $this = $(this);
            // Fetch back origin.
            var origin = $this.data("origin");
            // Update current transform.
            $this.attr("transform", "translate("
                + (origin.x + ui.position.left) + ", "
                + (origin.y + ui.position.top) + ")");
        }
    });
    

    You will find an updated fiddle here.

    A few remarks about the code above:

    • filter() is used instead of each() because it allows us to filter out elements whose transform attributes could not be parsed (you never know), instead of outright failing or feeding garbage to the computations in the drag handler,

    • attr() is used instead of prop() to emphasize the fact we’re modifying attributes in an SVG fragment. prop() would probably work in the exact same way, so it’s only a matter of style and personal preference.

    Finally, a caveat: I can only test this on Firefox for now, but it seems to be very difficult to trigger mousedown events on some of the labels, especially in “crowded” areas with portions of the curve and the data tip competing for space. Tweaking the zIndex attributes of the data label wrappers did not achieve much. Multiple clicks sometimes help. If this is consistent on all browsers, additional solutions will probably have to be devised (transparent overlays maybe, or simply relaying mousedown events from the data points themselves to the data labels).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create Highcharts chart from mysql, I have code like this: xAxis:
I am using lazy_highcharts gem and trying to configure live charts. Following this guide
We are using highcharts and are trying to customize a chart to look similar
I have a big problem using highcharts, because I have been trying for hours
I am attempting to use the highcharts javascript library to load charts using this
I'm trying to use Highcharts to create a graph similar to what's shown below.
I want to add and image button on highcharts. So far, I have successfully
I am trying to display a graph with HighCharts en i got stacked with
In Highcharts I want to change the default starting point from 0 to 1
I'd like to change the axis label (like Change HighCharts axis title ) but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.