G2-JS / feedback

Antv 的反馈库
GNU General Public License v2.0
124 stars 9 forks source link

tooltip的配置中, 设置 map的value 为 数据源中的另一个数值字段无效 #122

Open zachshelter opened 7 years ago

zachshelter commented 7 years ago
const chart = new G2.Chart({
  id: chartId,
  height: 320,
  forceFit: true,
  plotCfg: {
    margin: [20, 120, 40, 50]
  }
});

var frame = new G2.Frame(dataSource);
chart.source(frame, {
  date: { type: 'time', nice: false, alias: ' ' },
  originCount: { type: 'linear' }
});
chart.tooltip({
  crosshairs: true,
  map: {
    value: 'originCount'
  }
});
chart.legend({ title: null });
chart.area().position('date*totalCount').color('alarmCategory').shape('smooth');

chart.render();

tooltip始终显示的是 totalCount的值,而无法显示originCount的值是为什么呢?

simaQ commented 7 years ago

因为 originCount 没有参与到图形语法中,你可以这样;

chart.tooltip({
  crosshairs: true
});
chart.legend({ title: null });
chart.area().position('date*totalCount').color('alarmCategory').shape('smooth').tooltip('originCount');

https://antv.alipay.com/g2/api/geom.html#tooltip