dc.js中X轴刻度的问题

时间:2019-05-08 06:36:59

标签: reactjs d3.js dc.js crossfilter

我正在使用d3 v5.9.2dc v3.0.12来绘制折线图,​​但x轴上的刻度似乎有问题。由于提供的数据是时间轴图,因此必须在x轴上标出日期,在y轴上标出值。

const line = lineChart(divRef);
const crossfilterDimension = dx.dimension(dimension);
const firstRecord = crossfilterDimension.bottom(1)[0];
const lastRecord = crossfilterDimension.top(1)[0];
line
  .dimension(crossfilterDimension)
  .x(
    scaleTime().domain([
      firstRecord[Object.keys(firstRecord)[0]],
      lastRecord[Object.keys(lastRecord)[0]]
    ])
  )
  .xUnits(timeYear)
  .xAxisLabel(xAxis.label)
  .yAxisLabel(yAxis.label)
  .renderDataPoints({ radius: 2, fillOpacity: 0.8, strokeOpacity: 0.0 })
  .group(
    count
      ? crossfilterDimension.group().reduceCount()
      : crossfilterDimension.group().reduceSum(group)
  );
line
  .yAxis()
  .ticks(yAxis.ticks)
  .tickFormat(yAxis.tickFormat);
return line;

Timeline graph

0 个答案:

没有答案