Last active
June 27, 2017 13:50
-
-
Save krivaten/75f1bdaf5591f061edb21c9a70dc23eb to your computer and use it in GitHub Desktop.
Coin Chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { | |
get, | |
computed | |
} = Ember; | |
export default Ember.Component.extend({ | |
class: ['tile-icon'], | |
percentComplete: 100, | |
expectedPercent: 40, | |
type: '2', | |
percentColor: computed('percentComplete', function() { | |
const percentComplete = get(this, 'percentComplete'); | |
let color; | |
if (percentComplete > 50) { | |
color = '#99CC00'; | |
} else if (percentComplete > 25) { | |
color = '#FFCC00'; | |
} else { | |
color = '#CC3300'; | |
} | |
return color; | |
}), | |
radius: computed('type', function() { | |
const type = get(this, 'type'); | |
let radius; | |
switch (type) { | |
case 'donut': | |
radius = 45; | |
break; | |
case 'pie': | |
radius = 25; | |
break; | |
} | |
return radius; | |
}), | |
stroke: computed('type', function() { | |
const type = get(this, 'type'); | |
let stroke; | |
switch (type) { | |
case 'donut': | |
stroke = 10; | |
break; | |
case 'pie': | |
stroke = 50; | |
break; | |
} | |
return stroke; | |
}), | |
percentCompleteStroke: computed('percentComplete', function() { | |
let percent = get(this, 'percentComplete') || 0; | |
let radius = get(this, 'radius'); | |
let length = (2 * Math.PI) * radius; | |
if (percent > 100) percent = 100; | |
let result = (percent / 100) * length; | |
return result + ' ' + length; | |
}), | |
expectedPercentRotation: computed('expectedPercent', function() { | |
let expectedPercent = get(this, 'expectedPercent'); | |
if (expectedPercent > 100) expectedPercent = 0; | |
return 360 * (expectedPercent * 0.01); | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'g' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
percentComplete: 60, | |
expectedPercent: 65 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.coin-chart-segment { | |
transition: stroke-dasharray 0.75s ease; | |
} | |
.coin-chart-indicator { | |
transition: transform 0.75s ease; | |
} | |
.tile-icon { | |
position: relative; | |
} | |
.tile-icon-content-text { | |
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif; | |
color: white; | |
font-weight: 800; | |
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); | |
} | |
.svg-big, | |
.svg-small { | |
margin: 0; | |
padding: 0; | |
} | |
.svg-big { | |
font-size: 40px; | |
} | |
.svg-small { | |
font-size: 14px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment