Skip to content

Commit 7554dfa

Browse files
authored
Merge pull request #392 from valor-software/feat-rc6
feat(package): upgrade to rc6 and use ng2-webpack-conf
2 parents 2e61aa0 + 0c195a3 commit 7554dfa

31 files changed

+363
-336
lines changed

.gitignore

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,25 @@ npm-debug.log
88

99
# WebStorm
1010
.idea
11+
.vscode
1112

1213
# ignore build and dist for now
13-
/build
1414
/bundles
1515
/demo-build
1616
/dist
1717
/coverage
1818
/ts
19+
/doc
1920

20-
ng2-charts.d.ts
21-
ng2-charts.js
22-
ng2-charts.js.map
21+
# ignore inline compiling
2322
/demo/**/*.js
2423
/demo/**/*.js.map
2524
/demo/**/*.d.ts
25+
!/demo/custom-typings.d.ts
2626
/components/**/*.js
2727
/components/**/*.js.map
2828
/components/**/*.d.ts
29-
29+
ng2-charts.js
30+
ng2-charts.d.ts
31+
ng2-charts.js.map
3032
/logs

.ng2-config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
var pkg = require('./package.json');
3+
4+
module.exports = {
5+
// metadata
6+
title: pkg.description,
7+
baseUrl: '/',
8+
// root folder name
9+
src: 'demo',
10+
dist: 'demo-build',
11+
htmlIndexes: ['index.html'],
12+
// karma bundle src
13+
spec: './spec-bundle.js',
14+
// webpack entry
15+
entry: {
16+
polyfills: './demo/polyfills.ts',
17+
vendor: './demo/vendor.ts',
18+
main: './demo/index.ts'
19+
},
20+
commonChunks: {
21+
name: ['polyfills', 'vendor'].reverse()
22+
},
23+
// webpack alias
24+
alias: {},
25+
copy: [
26+
{from: 'demo/favicon.ico', to: 'favicon.ico'},
27+
{from: 'demo/assets', to: 'assets'}
28+
]
29+
};

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ language: node_js
22
node_js:
33
- "6"
44

5+
before_install: npm i -g npm@latest
6+
57
script:
68
- npm run flow.install:typings
79
- npm test
810

911
after_success:
10-
- ./node_modules/.bin/codecov
12+
- ./node_modules/.bin/codecov -f coverage/coverage-final.json
1113

1214
addons:
1315
# sauce labs tunel connector (read more https://docs.travis-ci.com/user/sauce-connect/ )

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Follow me at [twitter](https://twitter.com/valorkin) to be notified about new re
3131
**Important**: Embedding `Chart.js` in application is mandatory!
3232

3333
```html
34-
<script src="node_modules/chart.js/dist/Chart.bundle.min.js"></script>
34+
<script src="node_modules/chart.js/src/chart.js"></script>
3535
```
3636
### Usage & Demo
3737
Demo and API details of ***ng2-charts*** can be found here:
@@ -46,7 +46,7 @@ System.js bundles can be found in `bundles` directory of npm package or at [npm
4646

4747
### Import
4848
```typescript
49-
import {ChartsModule} from 'ng2-charts/ng2-charts';
49+
import { ChartsModule } from 'ng2-charts/ng2-charts';
5050

5151
// In your App's module:
5252
imports: [
@@ -80,7 +80,6 @@ There are one directive for all chart types: `base-chart`, and there are 6 types
8080
There are a set several default colors. Colors can be replaced using the `colors` attribute. If there is more data than colors, colors are generated randomly.
8181

8282

83-
8483
## Troubleshooting
8584

8685
Please follow this guidelines when reporting bugs and feature requests:

components/charts/charts.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Component } from '@angular/core';
2+
import { ComponentFixture, TestBed } from '@angular/core/testing';
3+
4+
import { ChartsModule } from '../../ng2-charts';
5+
6+
const html = ``;
7+
8+
describe('Component: ng2-charts', () => {
9+
let fixture:ComponentFixture<any>;
10+
let context:TestChartsComponent;
11+
12+
beforeEach(() => {
13+
TestBed.configureTestingModule({
14+
declarations: [TestChartsComponent],
15+
imports: [ChartsModule]
16+
});
17+
TestBed.overrideComponent(TestChartsComponent, {set: {template: html}});
18+
fixture = TestBed.createComponent(TestChartsComponent);
19+
context = fixture.componentInstance;
20+
fixture.detectChanges();
21+
});
22+
23+
it('fixture should not be null', () => {
24+
expect(fixture).not.toBeNull();
25+
});
26+
});
27+
28+
@Component({
29+
selector: 'charts-test',
30+
template: ''
31+
})
32+
33+
class TestChartsComponent {
34+
}

components/charts/charts.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class BaseChartComponent implements OnDestroy, OnChanges, OnInit {
107107

108108
let options:any = Object.assign({}, this.options);
109109
if (this.legend === false) {
110-
options.legend = { display: false };
110+
options.legend = {display: false};
111111
}
112112
// hock for onHover and onClick events
113113
options.hover = options.hover || {};
@@ -288,14 +288,13 @@ function getColors(chartType:string, index:number, count:number):Color {
288288
}
289289

290290
@NgModule({
291-
declarations: [
292-
BaseChartComponent
293-
],
294-
exports: [
295-
BaseChartComponent
296-
],
297-
imports: [
298-
299-
]
291+
declarations: [
292+
BaseChartComponent
293+
],
294+
exports: [
295+
BaseChartComponent
296+
],
297+
imports: []
300298
})
301-
export class ChartsModule {}
299+
export class ChartsModule {
300+
}

components/charts/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ There are one directive for all chart types: `base-chart`, and there are 6 types
1515
- `labels` (`?Array<any>`) - x axis labels. It's necessary for charts: `line`, `bar` and `radar`. And just labels (on hover) for charts: `polarArea`, `pie` and `doughnut`
1616
- `chartType` (`?string`) - indicates the type of charts, it can be: `line`, `bar`, `radar`, `pie`, `polarArea`, `doughnut`
1717
- `options` (`?any`) - chart options (as from [Chart.js documentation](http://www.chartjs.org/docs/))
18-
- `colours` (`?Array<any>`) - data colours, will use default and|or random colours if not specified (see below)
18+
- `colors` (`?Array<any>`) - data colors, will use default and|or random colors if not specified (see below)
1919
- `legend`: (`?boolean=false`) - if true show legend below the chart, otherwise not be shown
2020

2121
### Events
@@ -24,6 +24,6 @@ There are one directive for all chart types: `base-chart`, and there are 6 types
2424
- `chartHover`: fires when mousemove (hover) on a chart has occurred, returns information regarding active points and labels
2525

2626

27-
### Colours
27+
### Colors
2828

29-
There are a set several default colours. Colours can be replaced using the `colours` attribute. If there is more data than colours, colours are generated randomly.
29+
There are a set several default colors. Colors can be replaced using the `colors` attribute. If there is more data than colors, colors are generated randomly.

demo/components/charts-section.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {Component} from '@angular/core';
1+
import { Component } from '@angular/core';
22

33
let name = 'Charts';
44
let src = 'https://github.com/valor-software/ng2-charts/blob/master/components/charts/charts.ts';
55
// webpack html imports
6-
let doc = ''; // require('../../components/charts/readme.md');
6+
let doc = require('../../components/charts/readme.md');
77

88
let chartDesc:Array<any> = [
99
{
@@ -60,7 +60,7 @@ let chartDesc:Array<any> = [
6060
];
6161

6262
let chartContent:string = ``;
63-
chartDesc.forEach((desc:any) => {
63+
chartDesc.forEach((desc:any, index:number) => {
6464

6565
chartContent += `
6666
<section id="${desc.id}" style="padding-top: 50px;">
@@ -94,6 +94,7 @@ chartDesc.forEach((desc:any) => {
9494
</tab>
9595
<tab heading="TypeScript">
9696
<div class="card card-block panel panel-default panel-body">
97+
<pre class="language-typescript"><code class="language-typescript" [innerHTML]="chartDesc[${index}].ts"></code></pre>
9798
</div>
9899
</tab>
99100
</tabset>
@@ -106,27 +107,31 @@ chartDesc.forEach((desc:any) => {
106107
@Component({
107108
selector: 'charts-section',
108109
template: `
109-
<br>
110-
<div class="row">
111-
<h2>API</h2>
112-
<div class="card card-block panel panel-default panel-body">${doc}</div>
113-
</div>
114-
115-
<section id="${name.toLowerCase()}">
116-
<div class="row"><h1>${name}<small>(<a href="${src}">src</a>)</small></h1></div>
117-
118-
<hr>
119-
110+
<br>
120111
<div class="row">
121-
<h2>Example</h2>
122-
${chartContent}
112+
<h2>API</h2>
113+
<div class="card card-block panel panel-default panel-body" [innerHTML]="doc"></div>
123114
</div>
124-
125-
<br>
126-
127-
</section>
115+
116+
<section id="${name.toLowerCase()}">
117+
<div class="row"><h1>${name}<small>(<a href="${src}">src</a>)</small></h1></div>
118+
119+
<hr>
120+
121+
<div class="row">
122+
<h2>Example</h2>
123+
124+
${chartContent}
125+
126+
</div>
127+
128+
<br>
129+
130+
</section>
128131
`
129-
130132
})
133+
131134
export class ChartsSectionComponent {
135+
public doc:string = doc;
136+
public chartDesc:any[] = chartDesc;
132137
}

demo/components/charts/bar-chart-demo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component} from '@angular/core';
1+
import { Component } from '@angular/core';
22

33
// webpack html imports
44
let template = require('./bar-chart-demo.html');
@@ -17,8 +17,8 @@ export class BarChartDemoComponent {
1717
public barChartLegend:boolean = true;
1818

1919
public barChartData:any[] = [
20-
{data: [65, 59, 80, 81, 56, 55, 40], label:'Series A'},
21-
{data: [28, 48, 40, 19, 86, 27, 90], label:'Series B'}
20+
{data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A'},
21+
{data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B'}
2222
];
2323

2424
// events

demo/components/charts/base-chart-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component} from '@angular/core';
1+
import { Component } from '@angular/core';
22

33
// webpack html imports
44
let template = require('./base-chart-demo.html');

0 commit comments

Comments
 (0)