Creating custom widgets for ruby gem dashing.io - Or combining widgets elements -


i'm working dashing ruby gem , combine elements of graph , number widgets. elements of graph , include up/down percentage arrow number widget.

i've never done work ruby , understand there few files within widget might need changed.

i've setup few nice widgets , i'm using job pull data redis db populate. i've added following graph.html page:

<p class="change-rate">   <i data-bind-class="arrow"></i><span data-bind="difference"></span> </p> 

this has no effect, , i'm sure i'm missing in 1 of many files makes work.

your on right track, , i've put similar in order complete trying need send data 2 new data binds, done jobs file , graph.coffee file.

i'm not sure how you're getting graph data redis jobs erb file want setup couple new variables, example have used nownumber , lastnumber. these number valuation performed on.

jobs/jobname.erb

send_event('graph', points: points, current: nownumber, last: lastnumber ) 

if print out this:

{:points=>[{:x=>6, :y=>64}, {:x=>5, :y=>62}, {:x=>4, :y=>56}], :current=>57, :last=>64} 

tweak graph/graph.coffee file:

# following 6 lines aren't needed solution, if wanted take advantage of 'warning', 'danger', , 'ok' status classes (changes background color , flashes), feed send_event 'status: [one of 3 status names]    if data.status     # clear existing "status-*" classes       $(@get('node')).attr 'class', (i,c) ->         c.replace /\bstatus-\s+/g, ''       # add new class       $(@get('node')).addclass "status-#{data.status}"    @accessor 'difference', ->     if @get('last')       last = parseint(@get('last'))       current = parseint(@get('current'))       if last != 0         diff = math.abs(math.round((current - last) / last * 100))         "#{diff}%"     else       ""   # picks direction of arrow based on whether current value higher or lower last   @accessor 'arrow', ->     if @get('last')       if parseint(@get('current')) > parseint(@get('last')) 'icon-arrow-up' else 'icon-arrow-down' 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -