Skip to content

Commit

Permalink
demo(line): Color secondary axis data red
Browse files Browse the repository at this point in the history
  • Loading branch information
paviad committed Mar 11, 2019
1 parent 79d022e commit 915a5a5
Show file tree
Hide file tree
Showing 8 changed files with 603 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/bazel-out

# dependencies
/node_modules
node_modules

# profiling files
chrome-profiler-events.json
Expand Down
1 change: 1 addition & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
],
"styles": [
"src/styles.scss",
"src/assets/bootstrap.css",
"node_modules/prismjs/themes/prism.css"
],
"scripts": [
Expand Down
2 changes: 1 addition & 1 deletion src/app/line-chart/line-chart.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<tr>
<th *ngFor="let label of lineChartLabels">{{label}}</th>
</tr>
<tr *ngFor="let d of lineChartData">
<tr *ngFor="let d of lineChartData; let i=index" [class]="'line-'+i">
<td *ngFor="let label of lineChartLabels; let j=index">{{d && d.data[j]}}</td>
</tr>
</table>
Expand Down
4 changes: 4 additions & 0 deletions src/app/line-chart/line-chart.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
.flex-item {
flex-basis: 50%;
}

tr.line-2 {
color: red;
}
14 changes: 10 additions & 4 deletions src/app/line-chart/line-chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class LineChartComponent implements OnInit {
public lineChartData: ChartDataSets[] = [
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' },
{ data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B' },
{ data: [18, 48, 77, 9, 100, 27, 40], label: 'Series C', yAxisID: 'y-axis-1' }
{ data: [180, 480, 770, 90, 1000, 270, 400], label: 'Series C', yAxisID: 'y-axis-1' }
];
public lineChartLabels: Label[] = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
public lineChartOptions: (ChartOptions & { annotation: any }) = {
Expand All @@ -28,6 +28,12 @@ export class LineChartComponent implements OnInit {
{
id: 'y-axis-1',
position: 'right',
gridLines: {
color: 'rgba(255,0,0,0.3)',
},
ticks: {
fontColor: 'red',
}
}
]
},
Expand Down Expand Up @@ -66,9 +72,9 @@ export class LineChartComponent implements OnInit {
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(77,83,96,1)'
},
{ // grey
backgroundColor: 'rgba(148,159,177,0.2)',
borderColor: 'rgba(148,159,177,1)',
{ // red
backgroundColor: 'rgba(255,0,0,0.3)',
borderColor: 'red',
pointBackgroundColor: 'rgba(148,159,177,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
Expand Down
3 changes: 3 additions & 0 deletions src/app/material/material.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
MatButtonModule,
MatGridListModule,
MatCardModule,
MatTableModule,
} from '@angular/material';

@NgModule({
Expand All @@ -17,13 +18,15 @@ import {
MatButtonModule,
MatGridListModule,
MatCardModule,
MatTableModule,
],
exports: [
MatToolbarModule,
MatTabsModule,
MatButtonModule,
MatGridListModule,
MatCardModule,
MatTableModule,
]
})
export class MaterialModule { }
Loading

0 comments on commit 915a5a5

Please sign in to comment.