-
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
3 changed files
with
122 additions
and
42 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 |
---|---|---|
@@ -1,13 +1,68 @@ | ||
## Flow ChartJS | ||
__flowChartJs__ is an example of chart plugin, using [ChartJS](https://github.com/nnnick/Chart.js) via [Angular Chart](http://jtblin.github.io/angular-chart.js/) | ||
|
||
### Options | ||
- `chartType`: string representing one of chart types supported by ChartJS (line, bar, radar, pie, polar-area, doughnut) | ||
- `chartOptions`: options to be passed to ChartJS | ||
- `valueProperty`: path to property of the data point object to be used as chart value. Should be in `path.to.prop` form | ||
- `valueDefault`: default value to be inserted if the data point object doesn't contain property in the given path. | ||
Defaults to `null`, resulting in graph point not being drawn | ||
- `labelProperty`: path to property of the data point object to be used as chart label. Should be in `path.to.prop` form. | ||
# Flow ChartJS | ||
__flowChartJs__ is an example of chart plugin for [Angular Flow Chart](https://github.com/Sljux/angular-flow-chart), | ||
using [ChartJS](https://github.com/nnnick/Chart.js) via [Angular Chart](http://jtblin.github.io/angular-chart.js/) | ||
|
||
Install via Bower | ||
```sh | ||
bower install angular-flow-chartjs --save | ||
``` | ||
|
||
Add script tag to your `index.html` | ||
```html | ||
<script src="bower_components/angular-flow-chartjs.js"></script> | ||
``` | ||
|
||
Include the `ngFlowChartJs` module as a dependency to your module: | ||
```js | ||
angular.module('app', ['ngFlowChartJs', 'ngFlowChart']) | ||
``` | ||
|
||
## Options | ||
- `chartType`: `string` representing one of chart types supported by ChartJS (line, bar, radar, pie, polar-area, doughnut) | ||
- `chartOptions`: options `object` to be passed to ChartJS | ||
- `valueProperties`: `string` or an `array of strings` each representing a path to property of the data point object to be used as graph value. | ||
If array is passed, a graph will be drawn for each path. Should be in `path.to.prop` form | ||
- `valueDefaults`: `number` or an `array of numbers` to be used as a default if the data point object doesn't contain property in the given path. | ||
Defaults to `null`, resulting in graph points not being drawn. If a single value is passed, it will be used as default for all graphs | ||
- `labelProperty`: `string` representing a path to property of the data point object to be used as chart label. Should be in `path.to.prop` form. | ||
If nothing is passed, the labels are auto incremented integers starting at 0 | ||
- `labelDefault`: used if `labelProperty` is passed. Default label value if the data point object doesn't contain property in the given label path | ||
- `series`, `click`, `hover`, `legend` and `colours` are directly passed to [Angular Chart](http://jtblin.github.io/angular-chart.js/) directive | ||
- `labelDefault`: used if `labelProperty` is passed. `Number` representing default label value if the data point object | ||
doesn't contain property in the given label path | ||
- `series`, `click`, `hover`, `legend` and `colours` are directly passed to [Angular Chart](http://jtblin.github.io/angular-chart.js/) directive | ||
|
||
## Example usage | ||
```html | ||
<!-- main.html --> | ||
|
||
<flow-chart flow-id="flowId" limit="20"> | ||
<flow-chart-js | ||
value-properties="chart.valueProp" | ||
value-defaults="chart.valueDefaults" | ||
chart-type="line" | ||
chart-options="chart.options" | ||
series="chart.series" | ||
legend="chart.legend"> | ||
</flow-chart-js> | ||
</flow-chart> | ||
``` | ||
|
||
```js | ||
/* main.js */ | ||
|
||
angular.module('ngFlowThingsApp') | ||
.controller('MainCtrl', function ($scope) { | ||
$scope.flowId = '< your Flow ID >'; | ||
|
||
$scope.chart = { | ||
options: { | ||
animation: false | ||
}, | ||
series: ['Inside Temperature', 'Outside Temperature'], | ||
valueProp: ['inside.temperature', 'outside.temperature'], | ||
/* or valueProp: 'inside.humidity' */ | ||
valueDefaults: 0, | ||
/* or valueDefaults: [3, -7] */ | ||
legend: true | ||
} | ||
}); | ||
``` |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.