# ember-cli-cedar **Repository Path**: mirrors_Esri/ember-cli-cedar ## Basic Information - **Project Name**: ember-cli-cedar - **Description**: Ember addon for Esri's Cedar charting library - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-08-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ember-cli-cedar Ember addon for the [@esri/cedar](https://github.com/Esri/cedar) charting library. [View it live](http://esri.github.io/ember-cli-cedar/#/charts/bar) ## Usage ### Component This addon exposes the `{{cedar-chart}}` component that you can use to declaratively add a Cedar chart to your ember application. ```hbs {{!-- you can pass the definition as an object --}} {{cedar-chart definition=model onError=(action 'showError') }} {{!-- or you can pass the individual parts of a definition --}} {{cedar-chart type=model.type datasets=model.datasets series=model.series overrides=model.overrides legend=model.legend style=model.style onError=(action 'showError') }} ``` NOTE: if you've configured emeber-cli-cedar to [lazy-load cedar dependencies](#lazy-load-amcharts), then the `{{cedar-chart}}` component will handle that for you. ### Service This addon exposes the `cedar-loader` service that you can use to control when cedar's dependencies are lazy-loaded (if you've [configured ember-cli-cedar to do so](#lazy-load-amcharts)). This can be useful if you want to implement your own chart component instead of using [`{{cedar-chart}}`](#component). The service exposes a single function `loadDependencies()` which returns a `Promise` that will resolve with the `cedar` global once the dependencies have been loaded. ```js this.get('cedarLoader').loadDependencies().then(cedar => { // now you can safely use cedar this.chart = new cedar.Chart(this.elementId, definition); }); ``` ### Importing from cedar Alternatively you can `import` from the cedar library directly: ```js import { Chart } from '@esri/cedar'; this.chart = new Chart(this.elementId, definition); ``` NOTE: If you will be [lazy-loading cedar's dependencies](#lazy-load-amcharts), you should probably use the [service](#service) instead. ### v0.x Below are the instructions for using v0.x. This addon exposes a component you can use to declaratively add a Cedar chart to your ember application: ```hbs {{cedar-chart type="bar" datasets=model.datasets series=model.series specification=model.specification timeout=5000 options=model.options override=model.override onUpdateStart=(action 'onChartUpdateStart') onUpdateEnd=(action 'onChartUpdateEnd') onError=(action 'onChartError') transform=(action chartTransform') }} ``` See the [Cedar documentation](https://esri.github.io/cedar/) for details on how to construct a [chart definition](https://esri.github.io/cedar/api/interfaces/idefinition.html) and other chart parameters. ## Installation To consume this addon in any ember application, run: ``` ember install ember-cli-cedar ``` Please see the [Dependencies](#dependencies) and [Configuration](#configuration) sections below for further installation steps. ## Dependencies This addon will add [@esri/cedar] as a dependency to your application. @esri/cedar depends on [amCharts](https://www.amcharts.com/javascript-charts/), which will be installed locally as an npm dependency. However, you have a few options as to how your application will load amCharts' scripts, styles, themes, and/or plugins. You can either: - configure ember-cli-cedar to [lazy-load amCharts](#lazy-load-amcharts), either - [from a CDN](#lazy-load-amcharts-from-a-cdn) - [from the public folder](#lazy-load-from-the-public-folder) - configure ember-cli-cedar to [import amCharts into the vendor js/css files](#import-amCharts-in-vendor-files) - manually [insert amCharts ` ``` ## Configuration ### Serve locally installed amCharts If you want to serve the amCharts package that is installed locally (in node_modules), you will need to start by adding the following options in ember-cli-build.js: ```js // ember-cli-build.js { cedar: { amCharts: { // publicPath - amCharts will be included at this path in the public folder // use this if you are goint to either: // - import amcharts into vendor files // - or lazy-load amcharts from the public folder publicPath: 'amcharts' } } // amCharts uses hardcoded paths to assets (like images and plugin files) // so you will need to make sure those don't get fingerprinted fingerprint: { // NOTE: this needs to be the same as publicPath above exclude: ['amcharts'] } } ``` ### Deploying assets to a CDN If you're serving the locally installed amCharts files, we assume that your assets are hosted under your application's `rootURL` and the `publicPath` is relative to that location. However, if for certain environments you deploy your assets to a remote CDN (i.e. using an addon like [ember-cli-deploy-cloudfront](https://github.com/kpfefferle/ember-cli-deploy-cloudfront)), you will also need to specify the `assetBaseUrl` in config/enviroment.js. ```js // config/enviroment.js if (environment === 'production') { // tell amCharts to look for scripts, styles, themes, and assets at the CDN ENV.cedar.amCharts.assetBaseUrl = 'https://fa9efa977faw99.cloudfront.net/my-app/assets' } ``` NOTE: `window.AmCharts_path` will be set to `ENV.cedar.amCharts.assetBaseUrl` concatenated with the `publicPath`. ## Development ### Running the Dummy App After cloning the repository you can test this addon in the dummy app with: * `ember server` * Visit your app at http://localhost:4200. NOTE: Windows users may need to specify an alternate livereload port like: `ember server -lrp 9000` ### Running in Another App In the root of this repo run: `npm link` In the consuming app, run: ``` npm link ember-cli-cedar ember generate ember-cli-cedar ember server ``` ### Running Tests * `npm test` (Runs `ember try:testall` to test your addon against multiple Ember versions) * `ember test` * `ember test --server` ### Building * `ember build` For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/). ### Contributing Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/Esri/contributing/blob/master/CONTRIBUTING.md). ## License Copyright © 2016-2018 Esri Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at > http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. A copy of the license is available in the repository's [LICENSE](./LICENSE) file. [@esri/cedar]:https://github.com/Esri/cedar