Highcharts有条件地将鼠标悬停在标记上

时间:2019-01-11 03:07:57

标签: angularjs highcharts highcharts-ng angular2-highcharts

高级图表的新手-我有一个图表,表明我在系列上禁用了标记

plotOptions: {
    series: {
        marker: {
            enabled: false
        }
    }
},

这对于绘制线条非常有用,但是,当我将鼠标悬停在图表上时,标记就在那里。这个很好,但是,如果xAxis上的y值为0(空),我不希望该标记出现,但是当y值时我要做在xAxis上大于1。

我之前可以通过将y值设置为null来禁用该系列的鼠标悬停,但是该系列中出现的空值-绘制为堆积的面积线图会导致样条线绘制不正确(没有花键,在连续使用connectNulls: true选项时边缘呈锯齿状。

I want this marker to be missing because there is no data on this day

I want the markers to be here when there is data

那么我和/或可以我如何基于xAxis上的y条件有条件地禁用悬停标记?

我一直在寻找包装Highcharts原型的方法,我已经在控制一些十字准线行为drawCrosshair()https://www.highcharts.com/docs/extending-highcharts/extending-highcharts,但是我似乎找不到任何可以控制标记绘制的东西。那个水平

2 个答案:

答案 0 :(得分:2)

一种动态的解决方案是拦截 Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'dcp-ecm-machine/centos-7'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: ecm_default_1547189617140_45398 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 1521 (guest) => 1521 (host) (adapter 1) default: 5601 (guest) => 5601 (host) (adapter 1) default: 9960 (guest) => 9960 (host) (adapter 1) default: 8760 (guest) => 8760 (host) (adapter 1) default: 8060 (guest) => 8060 (host) (adapter 1) default: 10080 (guest) => 10080 (host) (adapter 1) default: 10025 (guest) => 10025 (host) (adapter 1) default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection reset. Retrying... default: Warning: Connection aborted. Retrying... default: Warning: Remote connection disconnect. Retrying... ==> default: Machine booted and ready! [default] No Virtualbox Guest Additions installation found. Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Loading mirror speeds from cached hostfile * base: mirrors.dotsrc.org * extras: mirrors.dotsrc.org * updates: mirrors.dotsrc.org Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package binutils.x86_64 0:2.23.52.0.1-55.el7 will be updated ---> Package binutils.x86_64 0:2.27-34.base.el7 will be an update ---> Package gcc.x86_64 0:4.8.5-4.el7 will be updated ---> Package gcc.x86_64 0:4.8.5-36.el7 will be an update --> Processing Dependency: libgomp = 4.8.5-36.el7 for package: gcc-4.8.5-36.el7.x86_64 --> Processing Dependency: cpp = 4.8.5-36.el7 for package: gcc-4.8.5-36.el7.x86_64 --> Processing Dependency: libgcc >= 4.8.5-36.el7 for package: gcc-4.8.5-36.el7.x86_64 ---> Package kernel-devel.x86_64 0:3.10.0-957.1.3.el7 will be installed ---> Package make.x86_64 1:3.82-21.el7 will be updated ---> Package make.x86_64 1:3.82-23.el7 will be an update ---> Package perl.x86_64 4:5.16.3-286.el7 will be updated ---> Package perl.x86_64 4:5.16.3-293.el7 will be an update --> Processing Dependency: perl-libs = 4:5.16.3-293.el7 for package: 4:perl-5.16.3-293.el7.x86_64 --> Running transaction check ---> Package cpp.x86_64 0:4.8.5-4.el7 will be updated ---> Package cpp.x86_64 0:4.8.5-36.el7 will be an update ---> Package libgcc.x86_64 0:4.8.5-4.el7 will be updated ---> Package libgcc.x86_64 0:4.8.5-36.el7 will be an update ---> Package libgomp.x86_64 0:4.8.5-4.el7 will be updated ---> Package libgomp.x86_64 0:4.8.5-36.el7 will be an update ---> Package perl-libs.x86_64 4:5.16.3-286.el7 will be updated ---> Package perl-libs.x86_64 4:5.16.3-293.el7 will be an update --> Finished Dependency Resolution --> Running transaction check ---> Package kernel-devel.x86_64 0:3.10.0-327.36.1.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: kernel-devel x86_64 3.10.0-957.1.3.el7 updates 17 M Updating: binutils x86_64 2.27-34.base.el7 base 5.9 M gcc x86_64 4.8.5-36.el7 base 16 M make x86_64 1:3.82-23.el7 base 420 k perl x86_64 4:5.16.3-293.el7 base 8.0 M Removing: kernel-devel x86_64 3.10.0-327.36.1.el7 @updates 33 M Updating for dependencies: cpp x86_64 4.8.5-36.el7 base 5.9 M libgcc x86_64 4.8.5-36.el7 base 102 k libgomp x86_64 4.8.5-36.el7 base 157 k perl-libs x86_64 4:5.16.3-293.el7 base 688 k Transaction Summary ================================================================================ Install 1 Package Upgrade 4 Packages (+4 Dependent packages) Remove 1 Package Total download size: 54 M Downloading packages: No Presto metadata available for base -------------------------------------------------------------------------------- Total 7.3 MB/s | 54 MB 00:07 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : 4:perl-libs-5.16.3-293.el7.x86_64 1/18 Updating : 4:perl-5.16.3-293.el7.x86_64 2/18 Updating : libgcc-4.8.5-36.el7.x86_64 3/18 Updating : binutils-2.27-34.base.el7.x86_64 4/18 Updating : libgomp-4.8.5-36.el7.x86_64 5/18 Updating : cpp-4.8.5-36.el7.x86_64 6/18 Updating : gcc-4.8.5-36.el7.x86_64 7/18 Installing : kernel-devel-3.10.0-957.1.3.el7.x86_64 8/18 Updating : 1:make-3.82-23.el7.x86_64 9/18 Cleanup : kernel-devel-3.10.0-327.36.1.el7.x86_64 10/18 Cleanup : gcc-4.8.5-4.el7.x86_64 11/18 Cleanup : 4:perl-libs-5.16.3-286.el7.x86_64 12/18 Cleanup : 4:perl-5.16.3-286.el7.x86_64 13/18 Cleanup : binutils-2.23.52.0.1-55.el7.x86_64 14/18 Cleanup : cpp-4.8.5-4.el7.x86_64 15/18 Cleanup : libgcc-4.8.5-4.el7.x86_64 16/18 Cleanup : libgomp-4.8.5-4.el7.x86_64 17/18 Cleanup : 1:make-3.82-21.el7.x86_64 18/18 Verifying : kernel-devel-3.10.0-957.1.3.el7.x86_64 1/18 Verifying : cpp-4.8.5-36.el7.x86_64 2/18 Verifying : libgomp-4.8.5-36.el7.x86_64 3/18 Verifying : 4:perl-5.16.3-293.el7.x86_64 4/18 Verifying : gcc-4.8.5-36.el7.x86_64 5/18 Verifying : binutils-2.27-34.base.el7.x86_64 6/18 Verifying : libgcc-4.8.5-36.el7.x86_64 7/18 Verifying : 1:make-3.82-23.el7.x86_64 8/18 Verifying : 4:perl-libs-5.16.3-293.el7.x86_64 9/18 Verifying : cpp-4.8.5-4.el7.x86_64 10/18 Verifying : gcc-4.8.5-4.el7.x86_64 11/18 Verifying : kernel-devel-3.10.0-327.36.1.el7.x86_64 12/18 Verifying : libgomp-4.8.5-4.el7.x86_64 13/18 Verifying : libgcc-4.8.5-4.el7.x86_64 14/18 Verifying : 1:make-3.82-21.el7.x86_64 15/18 Verifying : binutils-2.23.52.0.1-55.el7.x86_64 16/18 Verifying : 4:perl-libs-5.16.3-286.el7.x86_64 17/18 Verifying : 4:perl-5.16.3-286.el7.x86_64 18/18 Removed: kernel-devel.x86_64 0:3.10.0-327.36.1.el7 Installed: kernel-devel.x86_64 0:3.10.0-957.1.3.el7 Updated: binutils.x86_64 0:2.27-34.base.el7 gcc.x86_64 0:4.8.5-36.el7 make.x86_64 1:3.82-23.el7 perl.x86_64 4:5.16.3-293.el7 Dependency Updated: cpp.x86_64 0:4.8.5-36.el7 libgcc.x86_64 0:4.8.5-36.el7 libgomp.x86_64 0:4.8.5-36.el7 perl-libs.x86_64 4:5.16.3-293.el7 Complete! Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso Mounting Virtualbox Guest Additions ISO to: /mnt mount: /dev/loop0 is write-protected, mounting read-only Installing Virtualbox Guest Additions 5.2.22 - guest version is unknown Verifying archive integrity... All good. Uncompressing VirtualBox 5.2.22 Guest Additions for Linux........ VirtualBox Guest Additions installer Removing installed version 5.0.26 of VirtualBox Guest Additions... Removing existing VirtualBox non-DKMS kernel modules[ OK ] Copying additional installer modules ... Installing additional modules ... VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while. VirtualBox Guest Additions: Starting. 的{​​{1}}功能。

例如,如果setState值为Point,则将其包装并阻止处理:

y

查看其中的this JSFiddle demonstration

答案 1 :(得分:1)

一个非常静态的方法是简单地用0的Y值寻址每个点。然后,您可以为每一个禁用悬停标记。这样的一点看起来像这样(JSFiddle demo):

{
  y:0, 
  marker:{
    states:{
      hover:{
        enabled:false
      }
    }
  }
}

并用于一系列:

series: [{
  marker: {
    enabled: false
  },
  data: [3, {y:0, marker:{states:{hover:{enabled:false}}}}, 3, 5, 1, 2, 12]
}]

如您所见,它并不漂亮,但可能会帮助需要临时解决方案的人。