使用人力车与一个小部件冲突问题 [英] Dashing problems using Rickshaw with one widget

查看:241
本文介绍了使用人力车与一个小部件冲突问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正尝试使用Rickshaw小部件在Dashing中的X轴上添加数据类型。

I'm currently trying to add data types to the x-axis of my graphs in Dashing using the Rickshaw widget.

基本上我想创建数据调用与Coffeescript小部件中的if语句相关的仪表板文件

Essentially I want to create data call in the dashboard file that relates to an if statement in the Coffeescript widget

来自coffeescript的代码(Rickshaw.coffee)

Code from 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)

这涉及到调用更改的Dashboard文件,如下所示:

This relates to a Dashboard file that calls the change like so:

  <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或其他类似的尝试。

Essentially the if statements do not seem to have any effect, I've tried to amend to enable if @get('var') == true or other similar attempts.

任何帮助将非常感谢!

Matt

推荐答案

管理破解:

# 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元素中做。

Basically, the 'data-x-axis' parameter needs to be passed as @get('xAxis'). Then you can feel free to do as you please in the switch element.

这篇关于使用人力车与一个小部件冲突问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆