Skip to content

Commit 6a6a0ad

Browse files
committed
chore: update chart component
1 parent a5d75b8 commit 6a6a0ad

File tree

3 files changed

+86
-149
lines changed

3 files changed

+86
-149
lines changed

examples-standalone/kendoangular-landing-page/src/app/components/charts/charts.component.html

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,41 @@
1313

1414
<div class="chart-item">
1515
<kendo-chart>
16-
<kendo-chart-title text="Units sold"></kendo-chart-title>
16+
<kendo-chart-title text="Hybrid car mileage report"></kendo-chart-title>
17+
<kendo-chart-legend position="top"></kendo-chart-legend>
18+
19+
<kendo-chart-value-axis>
20+
@for (item of valueAxes; track item.name) {
21+
<kendo-chart-value-axis-item
22+
[name]="item.name!"
23+
[title]="item.title!"
24+
[min]="item.min!"
25+
[max]="item.max!"
26+
[majorUnit]="item.majorUnit!"
27+
[color]="item.color!"
28+
>
29+
</kendo-chart-value-axis-item>
30+
}
31+
</kendo-chart-value-axis>
32+
1733
<kendo-chart-category-axis>
18-
<kendo-chart-category-axis-item [categories]="lineChartCategories" [title]="{ text: 'Months' }">
34+
<kendo-chart-category-axis-item [categories]="categories" [axisCrossingValue]="crossingValues">
1935
</kendo-chart-category-axis-item>
2036
</kendo-chart-category-axis>
21-
<kendo-chart-series>
22-
<kendo-chart-series-item type="line" [data]="lineChartData[0]"> </kendo-chart-series-item>
23-
<kendo-chart-series-item type="line" [data]="lineChartData[1]"> </kendo-chart-series-item>
24-
<kendo-chart-series-item type="line" [data]="lineChartData[2]"> </kendo-chart-series-item>
25-
</kendo-chart-series>
26-
</kendo-chart>
27-
</div>
2837

29-
<div class="chart-item">
30-
<kendo-chart>
3138
<kendo-chart-series>
32-
<kendo-chart-series-item type="heatmap" [data]="commitData">
33-
<kendo-chart-series-item-tooltip>
34-
<ng-template let-value="value">
35-
{{ value.value }} contributions on week {{ value.x }}, day
36-
{{ value.y }}
37-
</ng-template>
38-
</kendo-chart-series-item-tooltip>
39+
@for (item of series; track item.name) {
40+
<kendo-chart-series-item
41+
[name]="item.name!"
42+
[data]="item.data!"
43+
[type]="item.type!"
44+
[stack]="item.stack!"
45+
[color]="item.color"
46+
[axis]="item.axis!"
47+
>
3948
</kendo-chart-series-item>
49+
}
4050
</kendo-chart-series>
41-
42-
<kendo-chart-x-axis>
43-
<kendo-chart-x-axis-item [visible]="false"> </kendo-chart-x-axis-item>
44-
</kendo-chart-x-axis>
45-
46-
<kendo-chart-y-axis>
47-
<kendo-chart-y-axis-item [visible]="false"> </kendo-chart-y-axis-item>
48-
</kendo-chart-y-axis>
4951
</kendo-chart>
5052
</div>
5153
</div>

examples-standalone/kendoangular-landing-page/src/app/components/charts/charts.component.ts

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Component } from "@angular/core";
2-
import { KENDO_CHARTS, SeriesLabelsContentArgs } from "@progress/kendo-angular-charts";
3-
import { commitData } from "../../data/commit-data";
2+
import { KENDO_CHARTS, Series, SeriesLabelsContentArgs, ValueAxis } from "@progress/kendo-angular-charts";
43

54
@Component({
65
selector: "app-charts",
@@ -18,16 +17,66 @@ export class ChartsComponent {
1817
{ kind: "Other", share: 0.192 },
1918
];
2019

21-
public commitData = commitData();
20+
public series: Series[] = [
21+
{
22+
type: "column",
23+
data: [20, 40, 45, 30, 50],
24+
stack: true,
25+
name: "on battery",
26+
color: "#cc6e38",
27+
},
28+
{
29+
type: "column",
30+
data: [20, 30, 35, 35, 40],
31+
stack: true,
32+
name: "on gas",
33+
color: "#ef955f",
34+
},
35+
{
36+
type: "line",
37+
data: [30, 38, 40, 32, 42],
38+
name: "mpg",
39+
color: "#ec5e0a",
40+
axis: "mpg",
41+
},
42+
{
43+
type: "line",
44+
data: [7.8, 6.2, 5.9, 7.4, 5.6],
45+
name: "l/100 km",
46+
color: "#4e4141",
47+
axis: "l100km",
48+
},
49+
];
2250

23-
public lineChartCategories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"];
24-
public lineChartData = [
25-
[123, 276, 310, 212, 240, 156, 98],
26-
[165, 210, 287, 144, 190, 167, 212],
27-
[56, 140, 195, 46, 123, 78, 95],
51+
public valueAxes: ValueAxis[] = [
52+
{
53+
title: { text: "miles" },
54+
min: 0,
55+
max: 100,
56+
},
57+
{
58+
name: "km",
59+
title: { text: "km" },
60+
min: 0,
61+
max: 161,
62+
majorUnit: 32,
63+
},
64+
{
65+
name: "mpg",
66+
title: { text: "miles per gallon" },
67+
color: "#ec5e0a",
68+
},
69+
{
70+
name: "l100km",
71+
title: { text: "liters per 100km" },
72+
color: "#4e4141",
73+
},
2874
];
2975

76+
public categories: string[] = ["Mon", "Tue", "Wed", "Thu", "Fri"];
77+
3078
public labelContent(e: SeriesLabelsContentArgs): string {
3179
return e.category;
32-
}
80+
}
81+
public crossingValues: number[] = [0, 0, 10, 10];
3382
}

examples-standalone/kendoangular-landing-page/src/app/data/commit-data.ts

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)