Highcharts - How do I move an icon inside each pie slice when the pie slice moves on hover?

Simmy Dhanda

I have a pie chart which has a icon(html tags defining class-and positioned). When you hover over each pie slices the slice moves out correctly BUT the icon is fixed in the position. Is there a way to move the icon AS WELL?

This is showing the initial series code:

series: [{
  type: 'pie',
  color: '#FFFFFF',
  data: [{
    name: '<h3>Scheduling</h3>',
    y: 60,
    icon: '<i class="fa fa-book" style="cursor:pointer;font-size:80px;margin:-20px;"></i>'
  }]
}]

morganfree

You need to move the data label on hover point - the x, y of the move can be grabbed from point.slicedTranslation

example: https://jsfiddle.net/036j2uLs/

On mouse over, you need to animate the point in the same direction as the slice.

         mouseOver: function(event) {
        var point = this;

        if (!point.selected) {
          timeout = setTimeout(function() {
            const label = point.dataLabel;
            point.firePointEvent('click');

            point.series.points.forEach(point => {
              const label = point.dataLabel;
              if (label.sliced) {
                label.animate({
                  x: label.originX,
                  y: label.originY
                });
                label.sliced = false;
              }
            });

            if (!label.sliced) {
              const {
                translateX: tx,
                translateY: ty
              } = point.slicedTranslation;

              label.animate({
                x: label.originX + tx,
                y: label.originY + ty
              });
              label.sliced = true;
            }

            chart.tooltip.shared = false;
            chart.tooltip.refresh(point);
          }, 0);
        }
      }
    }

Record origin data labels position on load/redraw:

function setLabelOrigins() {
  this.series[0].points.forEach(point => {
    const label = point.dataLabel;
    label.originX = label.x;
    label.originY = label.y;
  });
}

var chart = new Highcharts.Chart({
  chart: {
    renderTo: 'modules',
    plotBackgroundColor: null,
    plotBorderWidth: null,
    plotShadow: false,
    type: 'pie',
    backgroundColor: "transparent",
    events: {
      load: setLabelOrigins,
      redraw: setLabelOrigins
    }
  },

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Highcharts - How do I position tooltip behind icon on each pie slice on hover?

From Dev

Can I assign a different radius for each pie slice using Highcharts?

From Dev

How to hide a highcharts pie slice programatically

From Dev

highcharts - how to controle slice pie from bottom

From Dev

how to position label inside a pie chart slice

From Dev

Disabling a slice for a Highcharts pie chart when creating the chart

From Dev

How Can I Hide a Pie Chart's Slice in HighCharts Without Removing It From the Legend?

From Dev

How to change color of pie slice when mouse hover event take place

From Dev

Highcharts {Pie} - Remove slice pieces out onclick

From Dev

disable hover on special slice of pie chart

From Dev

D3.js Pie chart .. can pie slice move when selected?

From Dev

amCharts pie - how to trigger function when mouse over a slice?

From Dev

When I select a slice in the Pie Graph I want to show some kind of Visual representation of the Slice selection

From Dev

Filling a pie slice of a rectangle

From Dev

Angular-Charts - Pie Chart,show labels inside each slice of data

From Dev

Angular-Charts - Pie Chart,show labels inside each slice of data

From Dev

Highcharts: Change color of Pie Chart section without slice animation

From Dev

Highcharts pie chart - offset a single slice on legend click

From Dev

Highcharts: Change color of Pie Chart section without slice animation

From Dev

How do I make each row in a HTML table a pie chart in Highcharts?

From Dev

How do I make each row in a HTML table a pie chart in Highcharts?

From Dev

View #VAL label on Pie Chart and NOT inside the Series when slice selected = true

From Dev

Specifying different offset for each slice of a Shield UI JavaScript pie chart

From Dev

Highcharts: How do I set dynamic data to the drilldown pie chart?

From Dev

How do I select a region in pie chart (Highcharts)

From Dev

How to display pie chart data values of each slice in chart.js

From Dev

Setting the pie slice colors in MPAndroidChart

From Dev

Set Colors of Different Points when Clicking on Pie Slice Legend

From Dev

How to offset biggest slice automaticly in google pie chart?

Related Related

  1. 1

    Highcharts - How do I position tooltip behind icon on each pie slice on hover?

  2. 2

    Can I assign a different radius for each pie slice using Highcharts?

  3. 3

    How to hide a highcharts pie slice programatically

  4. 4

    highcharts - how to controle slice pie from bottom

  5. 5

    how to position label inside a pie chart slice

  6. 6

    Disabling a slice for a Highcharts pie chart when creating the chart

  7. 7

    How Can I Hide a Pie Chart's Slice in HighCharts Without Removing It From the Legend?

  8. 8

    How to change color of pie slice when mouse hover event take place

  9. 9

    Highcharts {Pie} - Remove slice pieces out onclick

  10. 10

    disable hover on special slice of pie chart

  11. 11

    D3.js Pie chart .. can pie slice move when selected?

  12. 12

    amCharts pie - how to trigger function when mouse over a slice?

  13. 13

    When I select a slice in the Pie Graph I want to show some kind of Visual representation of the Slice selection

  14. 14

    Filling a pie slice of a rectangle

  15. 15

    Angular-Charts - Pie Chart,show labels inside each slice of data

  16. 16

    Angular-Charts - Pie Chart,show labels inside each slice of data

  17. 17

    Highcharts: Change color of Pie Chart section without slice animation

  18. 18

    Highcharts pie chart - offset a single slice on legend click

  19. 19

    Highcharts: Change color of Pie Chart section without slice animation

  20. 20

    How do I make each row in a HTML table a pie chart in Highcharts?

  21. 21

    How do I make each row in a HTML table a pie chart in Highcharts?

  22. 22

    View #VAL label on Pie Chart and NOT inside the Series when slice selected = true

  23. 23

    Specifying different offset for each slice of a Shield UI JavaScript pie chart

  24. 24

    Highcharts: How do I set dynamic data to the drilldown pie chart?

  25. 25

    How do I select a region in pie chart (Highcharts)

  26. 26

    How to display pie chart data values of each slice in chart.js

  27. 27

    Setting the pie slice colors in MPAndroidChart

  28. 28

    Set Colors of Different Points when Clicking on Pie Slice Legend

  29. 29

    How to offset biggest slice automaticly in google pie chart?

HotTag

Archive