Skip to content

Commit

Permalink
chore: formatter tooltip value
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc committed May 15, 2023
1 parent 940458c commit b5b3331
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions site/docs/spec/component/tooltip.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ mark.tooltip({ channel: 'y' });
mark.tooltip((d) => (d.value > 100 ? d.name : d.age));

// 格式化
mark.tooltip({ channel: 'y', labelFormatter: (d) => d.toFixed(1) });
mark.tooltip({ channel: 'y', valueFormatter: (d) => d.toFixed(1) });

// d3-format 支持的字符
// https://github.com/d3/d3-format
mark.tooltip({ channel: 'y', labelFormatter: '~s' });
mark.tooltip({ channel: 'y', valueFormatter: '~s' });

// 完整信息
mark.tooltip({ name: 'name', color: 'red', value: 'color' });
Expand Down
7 changes: 6 additions & 1 deletion site/examples/general/dual/demo/pareto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ chart
title: 'Cumulative Percentage',
grid: null,
labelFormatter: (d) => `${(d * 100).toFixed(0)}%`,
})
.tooltip({
channel: 'y',
valueFormatter: (d) => `${(d * 100).toFixed(2)}%`,
});

chart
Expand All @@ -73,6 +77,7 @@ chart
.encode('y', 'accumulate')
.encode('shape', 'diamond')
.scale('y', { independent: true, domainMin: 0 })
.axis('y', null);
.axis('y', null)
.tooltip(null);

chart.render();

0 comments on commit b5b3331

Please sign in to comment.