Skip to content

Commit

Permalink
Angular 17 schematics
Browse files Browse the repository at this point in the history
  • Loading branch information
santam85 committed Nov 14, 2023
1 parent 75a4cfc commit af93508
Show file tree
Hide file tree
Showing 7 changed files with 6,326 additions and 5,647 deletions.
21 changes: 6 additions & 15 deletions apps/ng2-charts-demo/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "ng2-charts-demo:build:production"
"buildTarget": "ng2-charts-demo:build:production"
},
"development": {
"browserTarget": "ng2-charts-demo:build:development"
"buildTarget": "ng2-charts-demo:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ng2-charts-demo:build"
"buildTarget": "ng2-charts-demo:build"
}
},
"lint": {
Expand All @@ -81,14 +81,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/ng2-charts-demo/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
"jestConfig": "apps/ng2-charts-demo/jest.config.ts"
}
},
"serve-static": {
Expand All @@ -105,10 +98,8 @@
},
"configurations": {
"update-snapshots": {
"options": {
"skipInstall": true,
"updateSnapshots": "all"
}
"skipInstall": true,
"updateSnapshots": true
}
}
}
Expand Down
44 changes: 22 additions & 22 deletions apps/ng2-charts-demo/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h2>API</h2>
In order to use ***ng2-charts*** you need to import `NgChartsModule`:

```typescript
import {{ '{' }} NgChartsModule } from 'ng2-charts';
import {{ '{' }} NgChartsModule &#125; from 'ng2-charts';

// In your App's module:
imports: [
Expand All @@ -79,23 +79,23 @@ <h2>API</h2>
When you import `NgChartsModule` you can pass a global configuration object to it:

```typescript
import {{ '{' }} NgChartsModule } from 'ng2-charts';
import {{ '{' }} NgChartsModule &#125; from 'ng2-charts';

// In your App's module:
imports: [
NgChartsModule.forRoot({{ '{' }} defaults: {{ '{' }} ... } })
NgChartsModule.forRoot({{ '{' }} defaults: {{ '{' }} ... &#125; &#125;)
]
```
Alternatively, include a provider in your module, or one of the parent modules:

```typescript
import {{ '{' }} NgChartsModule, NgChartsConfiguration } from 'ng2-charts';
import {{ '{' }} NgChartsModule, NgChartsConfiguration &#125; from 'ng2-charts';

imports: [
NgChartsModule
],
providers: [
{{ '{' }} provide: NgChartsConfiguration, useValue: {{ '{' }} generateColors: false }}
{{ '{' }} provide: NgChartsConfiguration, useValue: {{ '{' }} generateColors: false &#125;&#125;
]
```

Expand Down Expand Up @@ -129,12 +129,12 @@ <h2>API</h2>
points and labels

### Chart instance
You can get access to the chart instance by using the `@ViewChild` annotation and a suitable selector for
You can get access to the chart instance by using the `&#64;ViewChild` annotation and a suitable selector for
the directive (see the Angular [docs](https://angular.io/api/core/ViewChild)). For example, to get the chart
instance and call the `toBase64Image()` method, you can add the following to the parent component:

```typescript
@ViewChild(BaseChartDirective) chart?: BaseChartDirective;
&#64;ViewChild(BaseChartDirective) chart?: BaseChartDirective;

public someAction(): void {{ '{' }}
this.chart?.toBase64Image();
Expand All @@ -159,37 +159,37 @@ <h2>API</h2>
private _selectedTheme: Theme = 'light-theme';
public get selectedTheme() {{ '{' }}
return this._selectedTheme;
}
&#125;
public set selectedTheme(value) {{ '{' }}
this._selectedTheme = value;
let overrides: ChartOptions;
if (this.selectedTheme === 'dark-theme') {{ '{' }}
overrides = {{ '{' }}
scales: {{ '{' }}
x: [{{ '{' }}
ticks: {{ '{' }} fontColor: 'white' },
gridLines: {{ '{' }} color: 'rgba(255,255,255,0.1)' }
}],
ticks: {{ '{' }} fontColor: 'white' &#125;,
gridLines: {{ '{' }} color: 'rgba(255,255,255,0.1)' &#125;
&#125;],
y: [{{ '{' }}
ticks: {{ '{' }} fontColor: 'white' },
gridLines: {{ '{' }} color: 'rgba(255,255,255,0.1)' }
}]
}
};
} else {{ '{' }}
ticks: {{ '{' }} fontColor: 'white' &#125;,
gridLines: {{ '{' }} color: 'rgba(255,255,255,0.1)' &#125;
&#125;]
&#125;
&#125;;
&#125; else {{ '{' }}
overrides = {{ '{' }}
scales: undefined
};
}
&#125;;
&#125;

this.themeService.setColorschemesOptions(overrides);
}
&#125;

constructor(private themeService: ThemeService) {{ '{' }} }
constructor(private themeService: ThemeService) {{ '{' }} &#125;

setCurrentTheme(theme: Theme) {{ '{' }}
this.selectedTheme = theme;
}
&#125;
```

The `overrides` object has the same type as the chart options object `ChartOptions`, and wherever a simple
Expand Down
9 changes: 1 addition & 8 deletions libs/ng2-charts-schematics/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/ng2-charts-schematics/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
"jestConfig": "libs/ng2-charts-schematics/jest.config.ts"
}
}
},
Expand Down
9 changes: 1 addition & 8 deletions libs/ng2-charts/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/ng2-charts/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
"jestConfig": "libs/ng2-charts/jest.config.ts"
}
},
"lint": {
Expand Down
17 changes: 13 additions & 4 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
"inputs": ["production", "^production"],
"cache": true
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"cache": true
},
"e2e": {
"inputs": ["default", "^production"],
"cache": true
Expand All @@ -25,6 +21,19 @@
"{workspaceRoot}/.eslintignore"
],
"cache": true
},
"@nx/jest:jest": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"cache": true,
"options": {
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"namedInputs": {
Expand Down
Loading

0 comments on commit af93508

Please sign in to comment.