Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于在图标上滑动十字显示问题 #3241

Closed
1 task
ruoru opened this issue Jan 26, 2021 · 4 comments
Closed
1 task

关于在图标上滑动十字显示问题 #3241

ruoru opened this issue Jan 26, 2021 · 4 comments
Labels

Comments

@ruoru
Copy link

ruoru commented Jan 26, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  1. 在走势图上横向滑动的时候十字 tooltip不显示十字
  2. 如何隐藏tooltip与走势线的空心交点
  3. 如何修改样式,tooltip与走势线的空心交点
Environment Info
g2 4.1.7
System -
Browser -

如果代码打不开,可以看一下下面的,root更一下就可以了

import F2 from '@antv/f2';
import _ from 'lodash';

fetch('https://gw.alipayobjects.com/os/antfincdn/OVMtvjbnut/series-line.json')
  .then(res => res.json())
  .then(data => {
    const chart = new F2.Chart({
      id: 'root',
      pixelRatio: window.devicePixelRatio
    });
    chart.source(data);
    chart.scale('date', {
      type: 'timeCat',
      tickCount: 3
    });
    chart.scale('value', {
      tickCount: 5
    });
    chart.axis('date', {
      label: function label(text, index, total) {
        // 只显示每一年的第一天
        const textCfg = {};
        if (index === 0) {
          textCfg.textAlign = 'left';
        } else if (index === total - 1) {
          textCfg.textAlign = 'right';
        }
        return textCfg;
      }
    });
    chart.tooltip({
      custom: true, // 自定义 tooltip 内容框
      showXTip: true,
      showYTip: true,
      snap: true,
      crosshairsType: 'xy',
      crosshairsStyle: {
        lineDash: [2]
      },
      onChange: function onChange(obj) {
        const legend = chart.get('legendController').legends.top[0];
        const tooltipItems = obj.items;
        const legendItems = legend.items;
        const map = {};
        legendItems.forEach(function(item) {
          map[item.name] = _.clone(item);
        });
        tooltipItems.forEach(function(item) {
          const name = item.name;
          const value = item.value;
          if (map[name]) {
            map[name].value = value;
          }
        });
        legend.setItems(_.values(map));
      },
      onHide: function onHide() {
        const legend = chart.get('legendController').legends.top[0];
        legend.setItems(chart.getLegendItems().country);
      }
    });
    chart.line().position('date*value').color('type');
    chart.area().position('date*value').color('type');

    chart.render();
  });
@hustcc
Copy link
Member

hustcc commented Jan 29, 2021

这个是 f2 的问题,可以到 f2 提交 issue~ G2 F2 API 比较类似,但是在细节实现上还是有一些区别的。 @ruoru

@hustcc hustcc added the Invalid label Jan 29, 2021
@ruoru
Copy link
Author

ruoru commented Jan 31, 2021

sorry @hustcc

@ruoru ruoru closed this as completed Jan 31, 2021
@ruoru ruoru reopened this Jan 31, 2021
@ruoru
Copy link
Author

ruoru commented Jan 31, 2021

@hustcc 关于另一个问题,点击new issue的时候请把仓库名自动做一个选中,不然很容易忽略,提错。

@hustcc
Copy link
Member

hustcc commented Jan 31, 2021

@hustcc 关于另一个问题,点击new issue的时候请把仓库名自动做一个选中,不然很容易忽略,提错。

什么意思?不是从哪里点就是哪里嘛,你从哪里点 new issue 的

@hustcc hustcc closed this as completed May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants