-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Adding New Chart Library | ||
**Global Chart Factory** have generic chart model and each chart library have it is own factory. Therefore when you adding new chart library you have to extended the Global Chart Factory. | ||
|
||
##Pre-request | ||
Need to add new JS charting library for the project or application. | ||
|
||
* `bower install <library name> --save` | ||
|
||
This command update your bower.json and index html | ||
|
||
##Steps | ||
1. Create a new factory inside the **chart-factory** with extending Global Chart Factory. | ||
|
||
```javascript | ||
angular.module('apacheZeppelinGsocApp').factory('MyNewChartFactory', function( | ||
ChartFactory) { | ||
|
||
//extending common chart model | ||
var MyNewChartFactory = new ChartFactory('NewChartLibraryName', newChart); | ||
|
||
//To-Do Implement or add new chart | ||
}); | ||
``` | ||
1.1. Supporting chart types need to define in ChartList array as below | ||
```javascript | ||
var ChartList = { | ||
'Bar': 'BarChart', | ||
'Line': 'LineChart' | ||
}; | ||
``` | ||
1.2. Develop the rest of method you need from you charting library | ||
|
||
2. Factories are expose from **ChartService**. Therefore you can add new services (only one method) that is using new factory. | ||
|
||
```javascript | ||
this.getNewChart = function(chartType) { | ||
var myChart = MyNewChartFactory; | ||
myChart.setChartType(chartType); | ||
return myChart; | ||
}; | ||
``` | ||
|
||
3. Update the configure file for new chart library. Update 'libraryName' as below. Add template for views | ||
|
||
```javascript | ||
'library': 'highChart', | ||
'service': 'getHighChart', | ||
'template': 'views/charts/highchart.html' | ||
``` | ||
|
||
Run | ||
* `npm install` first, If you hav not run it before. | ||
* `bower install` will download new library for application. | ||
|
||
### Build the application | ||
|
||
`./grunt build` | ||
|
||
Run `grunt build` for building | ||
|
||
### Preview Web application | ||
|
||
`./grunt serve` | ||
|
||
This will launch a WebApplication on port **9000** and update on code changes. | ||
|
||
### Testing | ||
|
||
`./grunt test` | ||
|