最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Stop HighCharts increasing width of line on hover - Stack Overflow

programmeradmin1浏览0评论

I am using the latest version of HighCharts to build a chart with multiple trends. By default HighCharts increases the thickness / lineWidth of a line when the user's mouse hovers over it. Because I could have ~10 trends on the chart I would like to remove this feature, meaning that the thickness of the line does not change on hover.

jsFiddle of code so far

I believe I need to set this in the plotOptions{} section. I have tried adding the following without success:

plotOptions: {
    series: {
        mouseOver: {
            lineWidth: 2
        }
    },
    marker: {
        enabled: false,
        states: {
            hover: {
                lineWidth: 2
            }
        }
    }
},

I would, however, like to retain the marker that denotes where the mouse of positioned:

I am using the latest version of HighCharts to build a chart with multiple trends. By default HighCharts increases the thickness / lineWidth of a line when the user's mouse hovers over it. Because I could have ~10 trends on the chart I would like to remove this feature, meaning that the thickness of the line does not change on hover.

jsFiddle of code so far

I believe I need to set this in the plotOptions{} section. I have tried adding the following without success:

plotOptions: {
    series: {
        mouseOver: {
            lineWidth: 2
        }
    },
    marker: {
        enabled: false,
        states: {
            hover: {
                lineWidth: 2
            }
        }
    }
},

I would, however, like to retain the marker that denotes where the mouse of positioned:

Share Improve this question edited Mar 25, 2015 at 10:47 John 'Mark' Smith asked Mar 25, 2015 at 10:21 John 'Mark' SmithJohn 'Mark' Smith 2,61410 gold badges47 silver badges70 bronze badges 1
  • 1 You can set a lineWidth as 1, jsfiddle.net/4oypoeom/5. – Sebastian Bochan Commented Mar 25, 2015 at 11:29
Add a comment  | 

2 Answers 2

Reset to default 13

Make this below change (Set the states mouseover to disabled state)

plotOptions: {
            series: {
                    lineWidth: 2,
                 states: {
                    hover: {
                        enabled: false
                    }
                }
            },

DEMO


In that case make lineWidth: 1 for hover

plotOptions: {
            series: {
                    lineWidth: 2,
                 states: {
                    hover: {
                        lineWidth: 1
                    }
                }

DEMO 2

What you need here is the lineWidthPlus property.

plotOptions: {
  series: {
    states: {
      hover: {
        lineWidthPlus: 0
     }
    }
  }
}

This way, no matter what else you change, the chart will not change the lineWidth when hovered.

API Reference:

  • http://api.highcharts.com/highcharts#plotOptions.series.states.hover.lineWidthPlus

Your fiddle updated:

  • http://jsfiddle.net/jlbriggs/4oypoeom/8/
发布评论

评论列表(0)

  1. 暂无评论