All Projects → jherdman → Ember Cli Chartist

jherdman / Ember Cli Chartist

Licence: mit
Ember Addon for Chartist.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ember Cli Chartist

Ember Accessibility
An EmberJS addon to help identify accessibility violations during development
Stars: ✭ 29 (-50%)
Mutual labels:  ember, ember-addon
Ember Api Feature Flags
API based, read-only feature flags for Ember
Stars: ✭ 11 (-81.03%)
Mutual labels:  ember, ember-addon
Ember Cp Validations
Ember computed property based validations
Stars: ✭ 442 (+662.07%)
Mutual labels:  ember, ember-addon
Ember Sticky Element
An ember component that mimics the functionality of `position: sticky`
Stars: ✭ 51 (-12.07%)
Mutual labels:  ember, ember-addon
Ember React Components
Render React components in Ember
Stars: ✭ 43 (-25.86%)
Mutual labels:  ember, ember-addon
Ember Decorators
Useful decorators for Ember applications.
Stars: ✭ 360 (+520.69%)
Mutual labels:  ember, ember-addon
Ember I18n Changeset Validations
ember-i18n support for ember-changeset-validations messages
Stars: ✭ 11 (-81.03%)
Mutual labels:  ember, ember-addon
Ember Websockets
Ember.js websockets and socket.io addon
Stars: ✭ 336 (+479.31%)
Mutual labels:  ember, ember-addon
Docfy
Build fully personalized documentation sites; write content and demos in Markdown.
Stars: ✭ 48 (-17.24%)
Mutual labels:  ember, ember-addon
Ember Simple Auth Auth0
Auth0 + lock.js, built on ember-simple-auth
Stars: ✭ 53 (-8.62%)
Mutual labels:  ember, ember-addon
Ember Cli Flash
Simple, highly configurable flash messages for ember-cli
Stars: ✭ 358 (+517.24%)
Mutual labels:  ember, ember-addon
Ember Side Menu
Side menu component for Ember.js applications
Stars: ✭ 58 (+0%)
Mutual labels:  ember, ember-addon
Ember Simple Auth Token
Ember Simple Auth extension that is compatible with token-based authentication like JWT.
Stars: ✭ 356 (+513.79%)
Mutual labels:  ember, ember-addon
Ember Intl
Localization library for any Ember Application or Addon
Stars: ✭ 412 (+610.34%)
Mutual labels:  ember, ember-addon
Ember Metrics
Send data to multiple analytics integrations without re-implementing new API
Stars: ✭ 356 (+513.79%)
Mutual labels:  ember, ember-addon
Ember Bootstrap
Ember-cli addon for using Bootstrap as native Ember components.
Stars: ✭ 475 (+718.97%)
Mutual labels:  ember, ember-addon
Ember Burger Menu
An off-canvas sidebar component with a collection of animations and styles using CSS transitions
Stars: ✭ 280 (+382.76%)
Mutual labels:  ember, ember-addon
Ember Light Table
Lightweight, contextual component based table for Ember 2.3+
Stars: ✭ 310 (+434.48%)
Mutual labels:  ember, ember-addon
Ember Paper
The Ember approach to Material Design.
Stars: ✭ 871 (+1401.72%)
Mutual labels:  ember, ember-addon
Ember Polymer
Use Polymer in your ambitious Ember application! 💎
Stars: ✭ 20 (-65.52%)
Mutual labels:  ember, ember-addon

Chartist.js for Ember-CLI Projects

Build Status Ember Observer Score

This is an ember-cli wrapper for Chartist. It allows you to render Chartist charts in your templates using components.

Compatibility

Setup

In an existing ember-cli project. Install with:

ember install ember-cli-chartist

In the template where you want the chart to appear:

<ChartistChart @type="line" @data={{model.chartData}} />
  • data is an optional attribute. Its value should be an object. Check the Chartist docs for expected data structure.
  • type is a required attribute. It can be any of the recognized chat types.

Where does the data come from?

The data can be specified in an Ember route or controller. In the example above it's coming from the model which is defined in the route.

/app/routes/application.js

import Route from '@ember/routing/route';

export default class ApplicationRoute extends Route {
  model() {
    return {
      chartData: {
        labels: ['Day1', 'Day2', 'Day3'],
        series: [
          [5, 4, 8],
          [10, 2, 7],
          [8, 3, 6]
        ]
      }
    }
  }
};

Chart types

There are three types of charts; line, bar, and pie. The default is line. You can change the chart type using the type attribute.

/app/templates/application.hbs

<ChartistChart @type="bar" @data={{model.chartData}} />

Responsive scaling

Chartist charts scale up and down in size. They do so at specified ratios. You can change the ratio using the ratio attribute.

/app/templates/application.hbs

<ChartistChart @ratio="ct-golden-section" @data={{model.chartData}} />

See Chartist docs for the full list of ratios and info on how to create your own.

Chart configuration

Chartist charts have a whole bunch of cool configuration options. You can pass those to the chartist-chart components with the options attribute. You'll need to create the options object in a similar way as you do for the data attribute object.

/app/templates/application.hbs

<ChartistChart @options={{chartOptions}} @data={{model.chartData}} />

/app/controllers/application.js

import Controller from '@ember/controller';

export default ApplicationController extends Controller {
  chartOptions = {
    showArea: true,
    lineSmooth: false,

    axisX: {
      showGrid: false
    }
  };
};

See the Chartist docs for all available config options. There's bunch of good-uns!

Responsive config

You can also configure your charts based on media queries. The same configuration options are available, but you provide them via the responsiveOptions attribute. They can be used in tandem with standard options.

<ChartistChart @responsiveOptions={{chartResOptions}} @data={{model.chartData}} />

/app/controllers/application.js

import Controller from '@ember/controller';

export default ApplicationController extends Controller {
  chartResOptions = [
    ['screen and (min-width: 640px)', {
      showArea: true,
      lineSmooth: false,

      axisX: {
        showLabel: false
      }
    }]
  ];
};

Other configuration

There are other ways to configure chartist-chart components that are specific to the addon.

updateOnData: By default, when the data associated with a chartist-chart is changed, the chart will be updated to reflect the data. That can be turned off by setting updateOnData to false. Note: If you use this option, you will have to manually draw and redraw the chart using Chartist methods.

<ChartistChart @updateOnData={{false}} />

Custom CSS

If you want to use custom CSS you can tell the addon to not include the compiled version.

In your app's ember-cli-build.js:

let app = new EmberApp({
  'ember-cli-chartist': {
    'useCustomCSS': true
  }
});

If you use custom CSS, you'll likely want to import the Chartist Scss into your app's scss, you will need to install ember-cli-sass. You can then import the Chartist scss with:

In app.scss

@import "chartist/chartist.scss";

you can also import the Chartist settings scss:

@import "chartist/chartist-settings.scss";

For more on custom styles see the Chartist docs

Extending chartist-chart

Care has been taken to provide as many knobs and parameters as you'd need to NOT extend the <ChartistChart component. Pass in data you need. The component does yield its template above the chart.

Should you find yourself needing to extend the base class please open an issue.

Using Plugins

  1. Add the plugin of your choice to your dependencies, e.g. yarn add -D chartist-plugin-fill-donut
  2. In ember-cli-build.js import your plugin, e.g. app.import('node_modules/chartist-plugin-fill-donut/dist/chartist-plugin-fill-donut.js');
  3. In your chartOptions object add the plugin, e.g.
chartOptions = {
  plugins: [
    Chartist.plugins.fillDonut({
      // config of plugin
    })
  ],
};

Live examples

There is an example app included in this repo in /tests/dummy/. It contains examples of most of the functionality described above. To view those examples you'll need to clone this repo and start the Ember cli server.

git clone https://github.com/jherdman/ember-cli-chartist.git
cd ember-cli-chartist
ember serve

The example app will be running at http://localhost:4200

How do I Test My Chart?

Asserting on characteristics of your chart is kind of hard as it's an SVG rendering. Tools like Percy may be of help with ensuring your chart looks the way it should. We do have an issue open and are interested in pull requests to help with this matter.

Consider, however, that your chart may be difficult to read for people that are visually impaired. Consider implementing an accessible data table — these are vastly easier to make assertions on. Note that we do not provide tooling for this as it's out of scope for this library, and is probably too close to your business domain to meaningfully abstract.

Development

If you'd like to contribute to this project, that would be swell. Here are some details on doing that.

Installation

  • git clone this repository
  • yarn install

Running

Linting

  • yarn lint:js
  • yarn lint:js -- --fix
  • yarn lint:hbs

Running Tests

  • ember test
  • ember test --server
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].