使用一个小部件使用人力车的奔跑问题
Dashing problems using Rickshaw with one widget
我目前正在尝试使用 Rickshaw 小部件将数据类型添加到我在 Dashing 中的图表的 x 轴。
基本上我想在与 Coffeescript 小部件中的 if 语句相关的仪表板文件中创建数据调用
来自 coffeescript 的代码 (Rickshaw.coffee)
# Define elements for Rickshaw time
time = new Rickshaw.Fixtures.Time
months = time.unit('month')
weeks = time.unit('week')
if @get("weekly-view")
x_axis = new Rickshaw.Graph.Axis.Time(graph: graph, timeUnit: weeks)
y_axis = new Rickshaw.Graph.Axis.Y(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
else if @get("monthly-view")
x_axis = new Rickshaw.Graph.Axis.Time(graph: graph, timeUnit: months)
y_axis = new Rickshaw.Graph.Axis.Y(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
else
x_axis = new Rickshaw.Graph.Axis.X(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
y_axis = new Rickshaw.Graph.Axis.Y(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
这与调用更改的仪表板文件相关:
<li data-row="1" data-col="1" data-sizex="6" data-sizey="6">
<div data-id="etvvrb" data-view="Rickshawgraph" data-weekly-view="true"></div>
</li>
基本上 if 语句似乎没有任何效果,我尝试修改以启用 if @get('var') == true 或其他类似尝试。
如有任何帮助,我们将不胜感激!
马特
成功破解:
# Define elements for Rickshaw time
time = new Rickshaw.Fixtures.Time
months = time.unit('month')
weeks = time.unit('week')
y_axis = new Rickshaw.Graph.Axis.Y(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
switch @get('xAxis')
when "weekly"
x_axis = new Rickshaw.Graph.Axis.Time(graph: graph, timeUnit: weeks)
when "monthly"
x_axis = new Rickshaw.Graph.Axis.Time(graph: graph, timeUnit: months)
else
x_axis = new Rickshaw.Graph.Axis.X(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
并且:
<li data-row="1" data-col="1" data-sizex="6" data-sizey="6">
<div data-id="etvvrb" data-view="Rickshawgraph" data-title="Weekly ETV reach" data-moreinfo="Week commencing" style="background-color:#336699" data-color-scheme="rainbow" data-renderer="line" data-x-axis="weekly"></div>
</li>
基本上,'data-x-axis'参数需要作为@get('xAxis')传递。然后你就可以在switch元素中尽情发挥了。
我目前正在尝试使用 Rickshaw 小部件将数据类型添加到我在 Dashing 中的图表的 x 轴。
基本上我想在与 Coffeescript 小部件中的 if 语句相关的仪表板文件中创建数据调用
来自 coffeescript 的代码 (Rickshaw.coffee)
# Define elements for Rickshaw time
time = new Rickshaw.Fixtures.Time
months = time.unit('month')
weeks = time.unit('week')
if @get("weekly-view")
x_axis = new Rickshaw.Graph.Axis.Time(graph: graph, timeUnit: weeks)
y_axis = new Rickshaw.Graph.Axis.Y(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
else if @get("monthly-view")
x_axis = new Rickshaw.Graph.Axis.Time(graph: graph, timeUnit: months)
y_axis = new Rickshaw.Graph.Axis.Y(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
else
x_axis = new Rickshaw.Graph.Axis.X(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
y_axis = new Rickshaw.Graph.Axis.Y(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
这与调用更改的仪表板文件相关:
<li data-row="1" data-col="1" data-sizex="6" data-sizey="6">
<div data-id="etvvrb" data-view="Rickshawgraph" data-weekly-view="true"></div>
</li>
基本上 if 语句似乎没有任何效果,我尝试修改以启用 if @get('var') == true 或其他类似尝试。
如有任何帮助,我们将不胜感激!
马特
成功破解:
# Define elements for Rickshaw time
time = new Rickshaw.Fixtures.Time
months = time.unit('month')
weeks = time.unit('week')
y_axis = new Rickshaw.Graph.Axis.Y(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
switch @get('xAxis')
when "weekly"
x_axis = new Rickshaw.Graph.Axis.Time(graph: graph, timeUnit: weeks)
when "monthly"
x_axis = new Rickshaw.Graph.Axis.Time(graph: graph, timeUnit: months)
else
x_axis = new Rickshaw.Graph.Axis.X(graph: graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
并且:
<li data-row="1" data-col="1" data-sizex="6" data-sizey="6">
<div data-id="etvvrb" data-view="Rickshawgraph" data-title="Weekly ETV reach" data-moreinfo="Week commencing" style="background-color:#336699" data-color-scheme="rainbow" data-renderer="line" data-x-axis="weekly"></div>
</li>
基本上,'data-x-axis'参数需要作为@get('xAxis')传递。然后你就可以在switch元素中尽情发挥了。