问题描述
但是我不知道如何实际实现Series对象来缩放和绑定数据,这是我的代码:
function render(svg) {
// const xValue = d => d['Population (2020)'];
// const yValue = d => d['Country (or dependency)'];
// const xExtent = d3.extent(world_population,xValue);
// const xScale = d3
// .scaleLinear()
// .domain(xExtent)
// .range([0,width]);
// const yScale = d3
// .scaleBand()
// .domain(world_population.map(yValue))
// .range([0,height]);
const xValue = d => d.data;
const yValue = d => d.index;
const xExtent = d3.extent(plot_data.values);
const xScale = d3
.scaleLinear()
.domain(xExtent)
.range([0,width]);
const yScale = d3
.scaleBand()
.domain(plot_data.index)
.range([0,height]);
const selection = d3.select(svg);
selection
.selectAll('rect')
.data(plot_data)
.enter()
.append('rect')
.attr('fill','slateblue')
.attr('y',d => yScale(d.index))
.attr('width',d => xScale(d.data))
.attr('height',yScale.bandwidth());
}
任何帮助或指针将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)