繁体   English   中英

nvd3 LineChart工具提示不起作用

[英]nvd3 LineChart tooltip not works

在此演示中, http://nvd3.org/livecode/index.html#codemirrorNav只是将数据更改为

function() {

  return [
    {
      values: [{x:23,y:9,},{x:22,y:6,},{x:21,y:6,},{x:20,y:10,},{x:19,y:19,},{x:18,y:26,},{x:17,y:30,},{x:16,y:41,},{x:15,y:49,},{x:14,y:31,},{x:13,y:48,},{x:12,y:7,},{x:11,y:26,},{x:10,y:47,},{x:9,y:35,},{x:8,y:20,},{x:7,y:25,},{x:6,y:1,},{x:0,y:1,}],
      key: 'A',
      color: '#ff7f0e'
    },
    {
      values: [{x:22,y:6,},{x:20,y:3,},{x:19,y:1,},{x:18,y:7,},{x:17,y:8,},{x:16,y:15,},{x:15,y:22,},{x:14,y:9,},{x:13,y:10,},{x:12,y:16,},{x:11,y:27,},{x:10,y:34,},{x:9,y:57,},{x:8,y:162,},{x:7,y:102,},{x:6,y:3,},{x:3,y:1,},{x:0,y:1,}],
      key: 'B',
      color: '#2ca02c'
    }
  ];
}

那时候工具提示坏了。为什么?

这是因为如果将数据更改为类似的内容,则NVD3希望对数据进行排序

function() {

  return [
    {
      values: [{x:21,y:9,},{x:22,y:6,},{x:23,y:6,}],
      key: 'A',
      color: '#ff7f0e'
    },
    {
      values: [{x:21,y:6,},{x:22,y:3,},{x:23,y:1,}],
      key: 'B',
      color: '#2ca02c'
    }
  ];
}

有用。 您必须在服务器端或使用.sort()在javascript上对数据进行排序

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM