Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cmackenz committed Feb 13, 2018
1 parent 0e34096 commit a52a88a
Show file tree
Hide file tree
Showing 51 changed files with 6,969 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
languages:
JavaScript: true
exclude_paths:
- "tests/*"
- "config/*"
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false

[*.{diff,md}]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions .ember-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
/**
Ember CLI sends analytics information by default. The data is completely
anonymous, but there are times when you might want to disable this behavior.

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false
}
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
extends: 'eslint:recommended',
env: {
browser: true
},
rules: {
},
globals: {
"jQuery": true,
"$": true
}
};
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp

# dependencies
/node_modules
/bower_components

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log*
yarn-error.log
testem.log

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try

.idea
16 changes: 16 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/bower_components
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.gitignore
.eslintrc.js
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js
47 changes: 47 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "6"

sudo: required
dist: trusty
addons:
chrome: stable

cache:
yarn: true

env:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

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

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- yarn global add phantomjs-prebuilt
- phantomjs --version

install:
- yarn install --no-lockfile --non-interactive

before_script:
- "sudo chown root /opt/google/chrome/chrome-sandbox"
- "sudo chmod 4755 /opt/google/chrome/chrome-sandbox"

script:
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
3 changes: 3 additions & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
}
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Ember CLI echarts

[![Ember Version](https://embadge.io/v1/badge.svg?start=2.3.0)](https://embadge.io/v1/badge.svg?start=2.3.0)
[![Build Status](https://travis-ci.org/funnelcloudinc/ember-cli-echarts.svg)](https://travis-ci.org/funnelcloudinc/ember-cli-echarts)
[![npm version](https://badge.fury.io/js/ember-cli-echarts.svg)](http://badge.fury.io/js/ember-cli-echarts)
[![Download Total](https://img.shields.io/npm/dt/ember-cli-echarts.svg)](http://badge.fury.io/js/ember-cli-echarts)
[![Ember Observer Score](https://emberobserver.com/badges/ember-cli-echarts.svg)](https://emberobserver.com/addons/ember-cli-echarts)
[![Code Climate](https://codeclimate.com/github/funnelcloudinc/ember-cli-echarts/badges/gpa.svg)](https://codeclimate.com/github/funnelcloudinc/ember-cli-echarts)

An EmberJS [echarts](http://echarts.baidu.com/) wrapper

### Shout-out to @offirgolan as a lot of this was stolen from: [ember-cli-nvd3](https://github.com/offirgolan/ember-cli-nvd3) :pizza: :pizza: :pizza:

## Installation ##
```shell
ember install ember-cli-echarts
```

## Looking for help? ##
If it is a bug [please open an issue on GitHub](http://github.com/funnelcloudinc/ember-cli-echarts/issues).

## echarts Documentation
Before using this addon, you might want to checkout the [echarts Docs](https://ecomfe.github.io/echarts-doc/public/en/api.html#echarts)

## Basic Usage ##
All you need to get started is to specify which type of chart you want and the data it should display

```handlebars
{{echarts-chart options=options}}
```

## Options

### Chart Options
All chart specific options can be specified via the `options` property.

```javascript
// Basic area chart
option = {
xAxis: {
type: 'category',
boundaryGap: false,
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
areaStyle: {}
}]
};
```

```handlebars
{{echarts-chart options=options}}
```

### Helper Actions
Currently there are two helper actions provided:

#### 1. beforeSetup
This is called before echarts has been initialized.

```javascript
beforeSetup(context, chart) {}
```

```handlebars
{{echarts-chart options=options beforeSetup=beforeSetup}}
```

#### 2. afterSetup
This is called after all chart options and data have been set, as well as after the chart has been created.

```javascript
afterSetup(context, chart) {}
```

# Want to help?

## Installation

* `git clone` this repository
* `npm install`
* `bower install`

## Running

* `ember server`
* Visit your app at http://localhost:4200.

## Running Tests

* `ember test`
* `ember test --server`

## Building

* `ember build`

For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
Empty file added addon/.gitkeep
Empty file.
80 changes: 80 additions & 0 deletions addon/components/echarts-chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import Component from '@ember/component';
import { get, set, computed, observer } from '@ember/object';
import { run } from '@ember/runloop';
import { on } from '@ember/object/evented';
import echarts from 'echarts';

export default Component.extend({
classNames: ['echarts-chart'],

options: {},
notMerge: false,
lazyUpdate: false,
theme: null,
initOptions: {
devicePixelRatio: 1,
renderer: 'canvas',
width: 'auto',
height: 'auto'
},

_chart: null,

beforeSetup() {
},
afterSetup() {
},

init() {
this._super(...arguments);
$(window).on('resize', this.handleResize.bind(this));
},

eventContext: computed(function() {
return get(this, 'targetObject') || this;
}),

reDraw: on('didInsertElement', observer('options', 'options.{*}', function() {
run.scheduleOnce('render', this, this.drawChart);
})),

drawChart() {
if (get(this, '_chart') && get(this, '_chart').isDisposed()) {
return;
}

let chart;
let selector = `#${get(this, 'elementId')}`;
let $el = $(selector);
let context = get(this, 'eventContext');

chart = echarts.init($el[0], get(this, 'theme'), get(this, 'initOptions'));

set(this, '_chart', chart);

run(() => get(this, 'beforeSetup').call(context, chart));

chart.setOption(get(this, 'options'), get(this, 'notMerge'), get(this, 'lazyUpdate'));

run(() => get(this, 'afterSetup').call(context, chart));

return chart;
},

handleResize() {
const chart = get(this, '_chart');
if (chart) {
chart.resize();
}
},

willDestroyElement() {
this._super(...arguments);
const chart = get(this, '_chart');
if (chart) {
chart.dispose();
}
$(window).off('resize');
}

});
Empty file added app/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions app/components/echarts-chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-cli-echarts/components/echarts-chart';
Loading

0 comments on commit a52a88a

Please sign in to comment.