1
使用条形图:自定义dc.js日期x轴
actionsChart /* dc.barChart('#volume-month-chart', 'chartGroup') */
.width(actionsWidth)
.height(240)
.margins({top: 10, right: 50, bottom: 30, left: 40})
.dimension(dateDimension)
//...
.elasticX(true)
.elasticY(true)
.gap(1)
.alwaysUseRounding(true)
.x(d3.time.scale().domain([ minDate, maxDate ]))
.round(d3.time.day.round)
.xUnits(d3.time.days)
.renderHorizontalGridLines(true)
//.xAxisLabel('Dan')
//.xAxisPadding(2)
.xAxisLabel("Datum")
//.yAxisLabel("Akcije") // OK, but already in title
.xAxisPadding(1)
//nok in dc: //.tickFormat(d3.time.format("%Y-%m-%d"))
//.label(function(d){ return JSON.stringify(d); })
;
如何把标签。每5天或7天,并自定义格式(天数月,没有星期几)?
谢谢。
是的,分隔滴答设置帮助。目前,出于某种原因,有时候文本与下个月的第一天重叠(自动显示)。我正在测试文字方向是否有助于使用CSS,如http://www.d3noob.org/2013/01/how-to-rotate-text-labels-for-x-axis-of.html中的评论所述。 – igr
是啊,我不认为d3在放置蜱时会根据文本大小。 (这将是困难和昂贵的。)旋转文本可以提供帮助,或者如果情况变得更糟,您可以准确计算出您想要的刻度日期并使用['.tickValues()'](https://github.com/d3 /d3-3.x-api-reference/blob/master/SVG-Axes.md#tickValues)。 – Gordon
有没有办法在本月1日禁用显示? – igr