Shopify Dashing:CoffeeScript没有将X轴显示为月

Shopify Dashing: CoffeeScript not showing X axis as months

本文关键字:显示 Dashing CoffeeScript Shopify      更新时间:2023-09-26

类似于:无法在Coffeescapet 上的Rickshaw Graph上显示月份名称

尽管这个问题与上面的类似,但我已经尝试了这个问题的给定答案,并且我仍然无法将沿"X"轴的数值更改为月份名称

与RickshawGraph.coffee相关的代码:

xAxisOptions = new Rickshaw.Fixtures.Time()
time = xAxisOptions.unit('month')
x_axis = new Rickshaw.Graph.Axis.Time(graph: graph, timeUnit: time, timeFixture: xAxisOptions)
y_axis = new Rickshaw.Graph.Axis.Y(graph: graph, tickFormat: Rickshaw.Fixtures.Number.format)

我希望能够显示月份名称而不是数字。。。有人能提出解决方案吗?

好吧,以下是我如何至少获得要显示的日期,尽管因此出现了另一个问题:

新代码

format =  (d) ->
enddate = new Date()
startdate = new Date()
startdate.setMonth(startdate.getMonth() - 12)
d = d3.time.months(startdate,enddate)
x_axis = new Rickshaw.Graph.Axis.X(graph: graph, pixelsPerTick: 1000, tickFormat: format)

以下是另一个问题的链接(与此相关,但不同):https://stackoverflow.com/questions/26141212/coffeescript-dashing-rickshaw-graph-range-of-dates-parse