Skip to content

Commit

Permalink
upgrades ember to 2.10 (#58)
Browse files Browse the repository at this point in the history
* upgrades ember to 2.10
  • Loading branch information
Zach Zibrat authored Feb 22, 2017
1 parent 66df443 commit 3c7feae
Show file tree
Hide file tree
Showing 27 changed files with 7,260 additions and 206 deletions.
33 changes: 13 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
---
language: node_js
node_js:
- "4"
- "stable"

dist: trusty
sudo: required
sudo: false

cache:
directories:
- node_modules

addons:
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
- $HOME/.npm
- $HOME/.cache # includes bowers cache

env:
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=ember-lts-2.4
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-release

- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary

matrix:
fast_finish: true
allow_failures:
- env:
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-lts-2.4
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm config set spin false
- npm install -g bower
- bower --version
- npm install phantomjs-prebuilt
- node_modules/phantomjs-prebuilt/bin/phantomjs --version

install:
- npm install
Expand All @@ -45,4 +38,4 @@ install:
script:
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
- ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016
Copyright (c) 2017

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This addon includes an `{{ember-sparkles}}`, which renders a responsive SVG cont
input-key='ts'
output-key='value'
x-scale-type='band'
scale-type='band'
y-scale-type='linear'
x-domain=(map (r/get 'ts') data)
y-domain=(append 0 outputMax)
Expand Down Expand Up @@ -73,13 +73,7 @@ This addon includes an `{{ember-sparkles}}`, which renders a responsive SVG cont

* `x-scale-type {String}` **optional**

Type of D3 scale function to use for horizontal axis.

_default:_ `linear`

* `y-scale-type {String}` **optional**

Type of D3 scale function to use for vertical axis.
Type of D3 scale function to use for horizontal axis (`linear`, `band`, or `time`).

_default:_ `linear`

Expand Down
2 changes: 1 addition & 1 deletion addon/helpers/e-s/arc-translate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';

export function emberSparklesArcTranslate([ centroid ], { height, width }) {
export function emberSparklesArcTranslate([ { centroid } ], { height, width }) {
return function(d) {
let [x, y] = centroid(d)
return `translate(${x + width}, ${y + height})`;
Expand Down
7 changes: 7 additions & 0 deletions addon/helpers/e-s/bandwidth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Ember from 'ember';

export function eSBandwidth([ { bandwidth } ]) {
return bandwidth;
}

export default Ember.Helper.helper(eSBandwidth);
11 changes: 11 additions & 0 deletions addon/helpers/e-s/pojo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// for ember v2.10+, the hash helper returns an EmptyObject, by design: https://github.com/emberjs/ember.js/issues/14489
// this ensures a POJO in the template, which many helpers expect

import Ember from 'ember';
const { keys } = Object;

export function eSPojo(params, hash) {
return keys(hash).reduce((pojo, k) => ({ [k]: hash[k], ...pojo }), {});
}

export default Ember.Helper.helper(eSPojo);
12 changes: 12 additions & 0 deletions addon/page-objects/grouped-bar-chart.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
let hex = (x) => (`0${parseInt(x, 10).toString(16)}`).slice(-2);
let rgb2hex = (rgb) => {
if (/^#[0-9A-F]{6}$/i.test(rgb)) return rgb;
let matches = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
return `#${hex(matches[1])}${hex(matches[2])}${hex(matches[3])}`;
}

export default class GroupedBarChart {
constructor(env) {
this.env = env;
Expand All @@ -17,4 +24,9 @@ export default class GroupedBarChart {
}
}

// phantomJS + chrome return hex and rgb values, respectively. we convert all fills to hex
fills() {
return this.rect('css', 'fill').map(m => m.map(rgb2hex));
}

}
8 changes: 5 additions & 3 deletions addon/templates/components/e-s/bar-chart.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{let updateRect (pipe
{{#let (pipe
(if with-transition (d3-transition transition) (d3-noop))
(d3-attr 'width' xScale.bandwidth)
(d3-attr 'width' (e-s/bandwidth xScale))
(d3-attr 'height' (pipe outputKey yScale (e-s/bar-height height)))
(d3-attr 'x' (pipe inputKey xScale))
(d3-attr 'y' (pipe outputKey yScale))
(d3-style 'opacity' 1)
)}}
) as |updateRect|}}

{{d3-graph (pipe
(d3-select-all 'rect')
Expand All @@ -32,3 +32,5 @@
))
classNames='ember-sparkles--bar-chart'
}}

{{/let}}
56 changes: 30 additions & 26 deletions addon/templates/components/e-s/grouped-bar-chart.hbs
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
{{let enterRect (pipe
(d3-append 'rect')
(d3-attr 'width' 0)
(d3-attr 'height' 0)
(d3-attr 'x' (pipe groupKey groupScale))
(d3-attr 'y' height)
(d3-style 'fill' 'red')
(d3-style 'opacity' 0)
)}}
{{#let
(pipe
(d3-append 'rect')
(d3-attr 'width' 0)
(d3-attr 'height' 0)
(d3-attr 'x' (pipe groupKey groupScale))
(d3-attr 'y' height)
(d3-style 'fill' 'red')
(d3-style 'opacity' 0)
)

{{let updateRect (pipe
(if with-transition (d3-transition transition) (d3-noop))
(d3-attr 'width' groupScale.bandwidth)
(d3-attr 'height' (pipe valueKey yScale (e-s/bar-height height)))
(d3-attr 'x' (pipe groupKey groupScale))
(d3-attr 'y' (pipe valueKey yScale))
(d3-style 'fill' (pipe groupKey colorScale))
(d3-style 'opacity' 1)
)}}
(pipe
(if with-transition (d3-transition transition) (d3-noop))
(d3-attr 'width' (e-s/bandwidth groupScale))
(d3-attr 'height' (pipe valueKey yScale (e-s/bar-height height)))
(d3-attr 'x' (pipe groupKey groupScale))
(d3-attr 'y' (pipe valueKey yScale))
(d3-style 'fill' (pipe groupKey colorScale))
(d3-style 'opacity' 1)
)

{{let exitRect (pipe
(if with-transition (d3-transition transition) (d3-noop))
(d3-attr 'y' height)
(d3-attr 'height' 0)
(d3-style 'fill' 'green')
(d3-style 'opacity' 0)
(d3-remove)
)}}
(pipe
(if with-transition (d3-transition transition) (d3-noop))
(d3-attr 'y' height)
(d3-attr 'height' 0)
(d3-style 'fill' 'green')
(d3-style 'opacity' 0)
(d3-remove)
)
as |enterRect updateRect exitRect|}}

{{d3-graph (pipe
(d3-select-all '.rect-group')
Expand Down Expand Up @@ -69,3 +71,5 @@
))
classNames='ember-sparkles--grouped-bar-chart'
}}

{{/let}}
46 changes: 26 additions & 20 deletions addon/templates/components/e-s/legend.hbs
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
{{#d3-graph classNames="ember-sparkles--legend" as |d3|}}

{{let transform (d3-attr 'transform'
(i 'translate(${coords})' coords=(concat dx ',' dy))
)}}
{{let shapePositionerOpt (compute
(action shapePositioner
(or direction 'vertical')
(or shape-spacing 20)
(hash x=dx y=dy)
)
)}}
{{let addShape (get (hash
rect=(pipe
(d3-append 'rect')
(d3-attr 'width' (or shape-size 14))
(d3-attr 'height' (or shape-size 14))
)
circle=(pipe
(d3-append 'circle')
(d3-attr 'r' (or shape-size 8))
{{#let
(d3-attr 'transform'
(i 'translate(${coords})' coords=(concat dx ',' dy))
)

(compute
(action shapePositioner
(or direction 'vertical')
(or shape-spacing 20)
(e-s/pojo x=dx y=dy)
)
)
) shape)}}

(get (e-s/pojo
rect=(pipe
(d3-append 'rect')
(d3-attr 'width' (or shape-size 14))
(d3-attr 'height' (or shape-size 14))
)
circle=(pipe
(d3-append 'circle')
(d3-attr 'r' (or shape-size 8))
)
) shape)
as |transform shapePositionerOpt addShape|}}

{{d3.graph (pipe
(d3-append 'g')
Expand Down Expand Up @@ -86,4 +90,6 @@
)
))}}

{{/let}}

{{/d3-graph}}
Loading

0 comments on commit 3c7feae

Please sign in to comment.