简体   繁体   English

破折号:数字小部件背景颜色

[英]Dashing: Number widget background color

Can the number widget be used multiple times on the same dashboard? 能否在同一仪表板上多次使用数字小部件?

eg 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. 我的.rb文件传递来自excel文件的数据。

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. 每个小部件显示正确的当前分数每个小部件显示正确的向上/向下箭头尽管.coffee显示相反,所有小部件都显示与我想要的颜色相同但相反的颜色。

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 4号咖啡

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 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;
}

}

You can use a widget multiple times on a single dashboard but it sounds like you have that part working already. 您可以在单个仪表板上多次使用小部件,但这听起来好像已经使该部件正常工作了。

You need to fade out the widget, set the background-color, and then the fade in again. 您需要淡出小部件,设置背景颜色,然后再次淡入。 Otherwise you will not see the background color change as the rendering has already occurred. 否则,您将不会看到背景颜色的变化,因为渲染已经发生。

 onData: (data) -> if @get('last') if parseInt(@get('current')) > parseInt(@get('last')) then $(@node).fadeOut().css('background-color', "#006600").fadeIn() else $(@node).fadeOut().css('background-color', "#660000").fadeIn() 

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM