DC.js scatterPlot ordinal axis tick position

拜拜、爱过 提交于 2019-12-22 08:25:09

问题


How can I position the value points directly above the ticks (or the ticks directly under the points), using DC.js. I could not manage that, DC.js (or D3.js) positions the value points shifted to the left of the ticks, although the X-value is exactly the tick value.

Important: I need this feature for ordinal X axis (it works fine for linear X axis)!

var data = [
  {"x":"a","y":1},
  {"x":"b","y":2},
  {"x":"c","y":3}
];
...
dc.scatterPlot("#mychart")
  .dimension(dimension) 
  .group(group) 
  .x(d3.scale.ordinal().domain(data.map(function(v) {return v.x})))
  .xUnits(dc.units.ordinal) 
  .valueAccessor(function(d) {return d.value;});

Complete code see jsfiddle: http://jsfiddle.net/bourbert/59Lmt98w/1/


回答1:


In dc.js Bubble Chart modify bubbleLocator:

var bubbleLocator = function (d) {
return 'translate(' + (bubbleX(d)+20) + ',' + (bubbleY(d)) + ')';
};


来源:https://stackoverflow.com/questions/37027768/dc-js-scatterplot-ordinal-axis-tick-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!