-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs/refactor-examples): enhance chart documentation (#1421)
Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
- Loading branch information
1 parent
fbd0b25
commit 4804d54
Showing
96 changed files
with
7,538 additions
and
438 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@siemens/ix-echarts': minor | ||
--- | ||
|
||
feat(echarts): add utility function to access color variables |
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
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
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
15 changes: 15 additions & 0 deletions
15
packages/angular-test-app/src/preview-examples/echarts-bar-horizontal-stacked.html
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: 2023 Siemens AG | ||
SPDX-License-Identifier: MIT | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
--> | ||
|
||
<div | ||
echarts | ||
[options]="options" | ||
[theme]="theme" | ||
class="echarts" | ||
></div> |
72 changes: 72 additions & 0 deletions
72
packages/angular-test-app/src/preview-examples/echarts-bar-horizontal-stacked.ts
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { Component, OnInit } from '@angular/core'; | ||
import { convertThemeName, registerTheme } from '@siemens/ix-echarts'; | ||
import { themeSwitcher } from '@siemens/ix'; | ||
import * as echarts from 'echarts/core'; | ||
import { BarSeriesOption, EChartsOption } from 'echarts'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: './echarts-bar-horizontal-stacked.html', | ||
styleUrls: ["../../../example-styles/dist/charts.css"], | ||
}) | ||
export default class EchartsBarHorizontalStacked implements OnInit { | ||
theme = convertThemeName(themeSwitcher.getCurrentTheme()); | ||
|
||
data = { | ||
years: ['2023', '2022', '2021', '2020', '2019'], | ||
salesEurope: [87, 22, 28, 43, 79], | ||
salesUS: [35, 24, 33, 5, 40], | ||
salesChina: [19, 44, 23, 5, 10], | ||
}; | ||
|
||
seriesData = [ | ||
{ name: 'Europe', data: this.data.salesEurope }, | ||
{ name: 'U.S', data: this.data.salesUS }, | ||
{ name: 'China', data: this.data.salesChina }, | ||
]; | ||
|
||
series: BarSeriesOption[] = this.seriesData.map(({ name, data }) => ({ | ||
name, | ||
data, | ||
type: 'bar', | ||
stack: 'x', | ||
})); | ||
|
||
options: EChartsOption = { | ||
xAxis: { | ||
type: 'value', | ||
name: 'Revenue (in Millions of USD)', | ||
nameLocation: 'middle', | ||
nameGap: 40, | ||
}, | ||
yAxis: { | ||
type: 'category', | ||
data: this.data.years, | ||
name: 'Years', | ||
nameLocation: 'end', | ||
}, | ||
legend: { | ||
show: true, | ||
bottom: '0', | ||
left: '0', | ||
}, | ||
series: this.series, | ||
}; | ||
|
||
ngOnInit() { | ||
registerTheme(echarts); | ||
|
||
themeSwitcher.themeChanged.on((theme: string) => { | ||
this.theme = convertThemeName(theme); | ||
}); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/angular-test-app/src/preview-examples/echarts-bar-simple.html
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: 2023 Siemens AG | ||
SPDX-License-Identifier: MIT | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
--> | ||
|
||
<div | ||
echarts | ||
[options]="options" | ||
[theme]="theme" | ||
class="echarts" | ||
></div> |
56 changes: 56 additions & 0 deletions
56
packages/angular-test-app/src/preview-examples/echarts-bar-simple.ts
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { Component, OnInit } from '@angular/core'; | ||
import { convertThemeName, registerTheme } from '@siemens/ix-echarts'; | ||
import { themeSwitcher } from '@siemens/ix'; | ||
import * as echarts from 'echarts/core'; | ||
import { EChartsOption } from 'echarts'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: './echarts-bar-simple.html', | ||
styleUrls: ["../../../example-styles/dist/charts.css"], | ||
}) | ||
export default class EchartsBarSimple implements OnInit { | ||
theme = convertThemeName(themeSwitcher.getCurrentTheme()); | ||
data = { | ||
products: ['Product A', 'Product B', 'Product C', 'Product D', 'Product E', 'Product F'], | ||
sales: [10.3, 9.2, 7.3, 6.4, 6.2, 4.4], | ||
}; | ||
|
||
options: EChartsOption = { | ||
xAxis: { | ||
data: this.data.products, | ||
name: 'Product', | ||
nameLocation: 'end', | ||
}, | ||
yAxis: { | ||
name: 'Number of sold products \n (in Mio)', | ||
nameLocation: 'end', | ||
}, | ||
legend: { | ||
show: true, | ||
}, | ||
series: [ | ||
{ | ||
data: this.data.sales, | ||
type: 'bar', | ||
}, | ||
], | ||
}; | ||
|
||
ngOnInit() { | ||
registerTheme(echarts); | ||
|
||
themeSwitcher.themeChanged.on((theme: string) => { | ||
this.theme = convertThemeName(theme); | ||
}); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/angular-test-app/src/preview-examples/echarts-circle.html
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: 2023 Siemens AG | ||
SPDX-License-Identifier: MIT | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
--> | ||
|
||
<div | ||
echarts | ||
[options]="options" | ||
[theme]="theme" | ||
class="echarts" | ||
></div> |
76 changes: 76 additions & 0 deletions
76
packages/angular-test-app/src/preview-examples/echarts-circle.ts
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { Component, OnInit } from '@angular/core'; | ||
import { | ||
convertThemeName, | ||
getComputedCSSProperty, | ||
registerTheme, | ||
} from '@siemens/ix-echarts'; | ||
import { themeSwitcher } from '@siemens/ix'; | ||
import * as echarts from 'echarts/core'; | ||
import { EChartsOption } from 'echarts'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: './echarts-circle.html', | ||
styleUrls: ["../../../example-styles/dist/charts.css"], | ||
}) | ||
export default class EchartsCircle implements OnInit { | ||
theme = convertThemeName(themeSwitcher.getCurrentTheme()); | ||
|
||
data = [ | ||
{ value: 72.17, name: 'Windows' }, | ||
{ value: 15.42, name: 'macOS' }, | ||
{ value: 4.03, name: 'Linux' }, | ||
{ value: 2.27, name: 'Chrome OS' }, | ||
{ value: 6.11, name: 'Other' }, | ||
]; | ||
|
||
options: EChartsOption = { | ||
tooltip: { | ||
trigger: 'item', | ||
}, | ||
legend: { | ||
icon: 'rect', | ||
bottom: '0', | ||
left: '0', | ||
}, | ||
series: [ | ||
{ | ||
name: 'OS Share', | ||
type: 'pie', | ||
radius: ['60%', '90%'], | ||
label: { | ||
show: true, | ||
color: getComputedCSSProperty('color-neutral'), | ||
}, | ||
emphasis: { | ||
label: { | ||
show: true, | ||
fontSize: 25, | ||
fontWeight: 'bold', | ||
}, | ||
}, | ||
labelLine: { | ||
show: true, | ||
}, | ||
data: this.data, | ||
}, | ||
], | ||
}; | ||
|
||
ngOnInit() { | ||
registerTheme(echarts); | ||
|
||
themeSwitcher.themeChanged.on((theme: string) => { | ||
this.theme = convertThemeName(theme); | ||
}); | ||
} | ||
} |
Oops, something went wrong.