Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery highcharts如何将关闭按钮添加到上下文菜单右角_Jquery_Highcharts - Fatal编程技术网

Jquery highcharts如何将关闭按钮添加到上下文菜单右角

Jquery highcharts如何将关闭按钮添加到上下文菜单右角,jquery,highcharts,Jquery,Highcharts,我正在制作海图。在上图中,我必须在右角添加关闭按钮来关闭菜单项。我尝试添加close button类,但不起作用 下面是一些变化 navigation: { menuStyle: { border: '0px', background: '#727272', padding: '5px 56px 0px 1px', width: '100%' }, menuItemHoverStyle

我正在制作海图。在上图中,我必须在右角添加关闭按钮来关闭菜单项。我尝试添加close button类,但不起作用

下面是一些变化

navigation: {
        menuStyle: {
        border: '0px',
        background: '#727272',
        padding: '5px 56px 0px 1px',
        width: '100%'
        },
        menuItemHoverStyle: {
        background: null
        },
        menuItemStyle: {
        fontWeight: 'normal',
        background: null,
        fontSize: '13px',
        color: '#FFFFFF'
        },
}
下面是我的自定义菜单按钮

settingButton: {
                 symbol: 'url(' + baseUrl + '/admin/customMenu.png)',
                 symbolStrokeWidth: 0,
                 _titleKey: 'settingkey',
                 symbolFill: '#fffff',
                 symbolX: 20,
                 symbolY: 20,
                 y: -8,
                 symbolStroke: '#330033',
                 **menuItems: buttons,**
                 theme: {
                           states: {
                                hover: {
                                    fill: '#ffffff',
                                    stroke: '#ffffff'
                                  }
                             },
                  style: {
                            cursor:'cursor',
                            fontFamily:'Oswald'
                           }
                     }
                },
而menuitem是

buttons.push({
                    text: "Topper one",
                    onclick: topperOne
                }, {
                    text: "Topper ",
                    onclick: TopperTwo
                });
我尝试将类和Id属性添加到按钮,但这是添加到设置按钮而不是菜单项

主题:{ 类:“myButton highcharts button highcharts button normal”, id:“myDiamondButton”
}

您可以为导出菜单添加自定义菜单项定义。看

在文本属性中,可以定义html元素,单击可以设置所需的行为

function hideHighlight(id) {
  window.event.stopPropagation()
  const chart = Highcharts.charts.find(chart => chart.options.chart.id === id)

  if (chart) {
    const printItem = chart.exportDivElements[0]

    if (printItem) {
      printItem.onmouseout()
    }
  }
}

Highcharts.chart('container', {
  chart: {
    id: 'c1'
  },
  series: [],
  exporting: {
    menuItemDefinitions: {
      printChart: {
        onclick: function(e) {
          if (e.target.tagName === 'SPAN') {
            return false
          }

          this.print()
        },
        text: 'Print chart<span style="float: right" onmouseover="hideHighlight(\'c1\')">X</span>'
      }
    }
  }
});
函数隐藏高亮度(id){
window.event.stopPropagation()
const chart=Highcharts.charts.find(chart=>chart.options.chart.id==id)
如果(图表){
const printItem=chart.exportDivElements[0]
如果(打印项){
printItem.onmouseout()
}
}
}
Highcharts.chart('容器'{
图表:{
id:'c1'
},
系列:[],
出口:{
菜单项定义:{
打印图表:{
onclick:函数(e){
如果(e.target.tagName=='SPAN'){
返回错误
}
这个.print()
},
文本:“打印图表X”
}
}
}
});

实例:

请分享你的html。