zoukankan      html  css  js  c++  java
  • highcharts或highStock在react中使用highchartscustomevents插件(右击出现一个菜单项!)

    1、引入

    import HighStock from 'highcharts-release/highstock.js'
    import HighchartsCustomEvents from 'highcharts-custom-events'
    
    HighchartsCustomEvents(HighStock) // 很重要,要不然图表上用不了
    

      

    引用basiccontext(菜单的样式)

    import basicContext from 'basiccontext'
    import 'basiccontext/dist/basicContext.min.css'
    import 'basiccontext/dist/themes/bright.min.css'
    import 'basiccontext/dist/addons/popin.min.css'
    

      

    2、具体实现

    plotOptions: {
            line: {
              lineWidth: 1,
              dataGrouping: {
                enabled: false
              }
            },
            series: {
              animation: true,
              point: {
                events: {
                  contextmenu: (e) => { // 右击显示菜单
                    if (!this.props.showContextMenu) {
                      const contextMenu = [
                        {
                          title: '波形频谱图',
                          icon: 'fa fa-line-chart',
                          fn: () => {
                            that.showChart(e, 'spectrum')
                          }
                        },
                        {
                          title: '原始轴心轨迹图',
                          icon: 'fa fa-eercast',
                          fn: () => {
                            that.showChart(e, 'polarAxis')
                          }
                        },
                        {
                          title: '合成轴心轨迹图',
                          icon: 'fa fa-bullseye',
                          fn: () => {
                            that.showChart(e, 'polar')
                          }
                        },
                        {
                          title: '伯德图',
                          icon: 'fa fa-area-chart',
                          fn: () => {
                            that.showChart(e, 'bode')
                          }
                        }
                      ]
    
                      basicContext.show(contextMenu, e)
                    }
                  }
                }
              }
            }
          },

     3、结果:

    highcharts-custom-events中的事件类型:

    • click
    • double click (including mobile devices)
    • right click (context menu)
    • mouse over
    • mouse out
    • mouse down
    • mouse move
  • 相关阅读:
    C/C++中浮点数输出格式问题
    C/C++中的输出对齐设置
    C++11 中的initialize_list
    c++中的构造函数初始化列表
    C++11中的array
    STL 中的链表排序
    poj1068 Parencodings
    poj 3295 Tautology
    How To Join XLA_AE_HEADERS and RCV_TRANSACTIONS(子分类账到事务处理追溯)
    销售订单的四个主要环节和每个环节用到的常用表
  • 原文地址:https://www.cnblogs.com/susu8/p/9150764.html
Copyright © 2011-2022 走看看