Can the number widget be used multiple times on the same dashboard?
e.g. I want to show a current score for each team member, one widget per team member with an up/down arrow comparing the current score with the last score, if the score is up the widget background is Green if it is down the widget background is Red.
My .rb file passes data from an excel file.
Every widget shows the correct current score Every widget shows the correct up/down arrow ALL widgets show the same but opposite color of what I want despite the .coffee showing to the contrary.
It's as is if the loop to detect which color the background should be stops after the first `pass.
Bug or bad code? number4.coffee
class Dashing.Number4 extends Dashing.Widget
@accessor 'current', Dashing.AnimatedValue
@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
""
@accessor 'arrow', ->
if @get('last')
if parseInt(@get('current')) > parseInt(@get('last')) then 'fa fa-arrow-up' else 'fa fa-arrow-down'
constructor: ->
super
@onData(Dashing.lastEvents[@id]) if Dashing.lastEvents[@id]
onData: (data) ->
if parseInt(@get('current')) > parseInt(@get('last')) then $(@node).css('background-color', '#006600') else $(@node).css('background-color', '#660000')
number4.scss
//
// ----------------------------------------------------------------------------
// Mixins
// ----------------------------------------------------------------------------
@mixin transition($transition-property, $transition-time, $method) {
-webkit-transition: $transition-property $transition-time $method;
-moz-transition: $transition-property $transition-time $method;
-o-transition: $transition-property $transition-time $method;
transition: $transition-property $transition-time $method;
}
// ----------------------------------------------------------------------------
// Sass declarations
// ----------------------------------------------------------------------------
$value-color: #fff;
$title-color: rgba(255, 255, 255, 0.7);
$moreinfo-color: rgba(255, 255, 255, 0.7);
// ----------------------------------------------------------------------------
// Widget-number styles
// ----------------------------------------------------------------------------
.widget-number4 {
.title {
color: $title-color;
font-size: 40px;
}
.value {
color: $value-color;
}
.change-rate {
font-weight: 500;
font-size: 30px;
color: $value-color;
}
.more-info {
color: $moreinfo-color;
font-size: 23px;
bottom: 40px;
}
.updated-at {
color: white;
font-size: 23px;
}
}