Skip to content

Commit

Permalink
fix(docs/refactor-examples): enhance chart documentation (#1421)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
  • Loading branch information
matthiashader and danielleroux authored Aug 26, 2024
1 parent fbd0b25 commit 4804d54
Show file tree
Hide file tree
Showing 96 changed files with 7,538 additions and 438 deletions.
5 changes: 5 additions & 0 deletions .changeset/pink-ducks-thank.md
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
9 changes: 5 additions & 4 deletions packages/angular-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@
"@angular/platform-browser": "^14.2.0",
"@angular/platform-browser-dynamic": "^14.2.0",
"@angular/router": "^14.2.0",
"@siemens/ix-icons": "^2.0.0",
"@siemens/ix": "workspace:*",
"@siemens/ix-angular": "workspace:*",
"@siemens/ix-aggrid": "workspace:*",
"@siemens/ix-angular": "workspace:*",
"@siemens/ix-echarts": "workspace:*",
"example-styles": "workspace:*",
"@siemens/ix-icons": "^2.0.0",
"ag-grid-angular": "^30.0.0",
"ag-grid-community": "^30.2.0",
"ngx-echarts": "~14.0.0",
"echarts": "^5.4.1",
"echarts-gl": "^2.0.9",
"example-styles": "workspace:*",
"ngx-echarts": "~14.0.0",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
Expand Down
37 changes: 37 additions & 0 deletions packages/angular-test-app/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ import DropdownIcon from '../preview-examples/dropdown-icon';
import DropdownQuickActions from '../preview-examples/dropdown-quick-actions';
import DropdownSubmenu from '../preview-examples/dropdown-submenu';
import Echarts from '../preview-examples/echarts';
import EchartsSpecial3d from '../preview-examples/echarts-special-3d';
import EchartsBarHorizontalStacked from '../preview-examples/echarts-bar-horizontal-stacked';
import EchartsBarSimple from '../preview-examples/echarts-bar-simple';
import EchartsCircle from '../preview-examples/echarts-circle';
import EchartsEmptyState from '../preview-examples/echarts-empty-state';
import EchartsGauge from '../preview-examples/echarts-gauge';
import EchartsLineAdvanced from '../preview-examples/echarts-line-advanced';
import EchartsLineMultipleYAxis from '../preview-examples/echarts-line-multiple-y-axis';
import EchartsLineSimple from '../preview-examples/echarts-line-simple';
import EchartsSpecialToolbox from '../preview-examples/echarts-special-toolbox';
import EchartsSpecialZoom from '../preview-examples/echarts-special-zoom';
import EchartsPie from '../preview-examples/echarts-pie';
import EchartsProgressCircle from '../preview-examples/echarts-progress-circle';
import EchartsProgressArc from '../preview-examples/echarts-progress-arc';
import EmptyState from '../preview-examples/empty-state';
import EmptyStateCompact from '../preview-examples/empty-state-compact';
import EmptyStateCompactBreak from '../preview-examples/empty-state-compact-break';
Expand Down Expand Up @@ -385,6 +399,29 @@ const routes: Routes = [
path: 'echarts',
component: Echarts,
},
{
path: 'echarts-special-3d',
component: EchartsSpecial3d,
},
{ path: 'echarts-bar-simple', component: EchartsBarSimple },
{
path: 'echarts-bar-horizontal-stacked',
component: EchartsBarHorizontalStacked,
},
{ path: 'echarts-circle', component: EchartsCircle },
{ path: 'echarts-empty-state', component: EchartsEmptyState },
{ path: 'echarts-gauge', component: EchartsGauge },
{
path: 'echarts-line-multiple-y-axis',
component: EchartsLineMultipleYAxis,
},
{ path: 'echarts-line-advanced', component: EchartsLineAdvanced },
{ path: 'echarts-line-simple', component: EchartsLineSimple },
{ path: 'echarts-toolbox', component: EchartsSpecialToolbox },
{ path: 'echarts-pie', component: EchartsPie },
{ path: 'echarts-progress-arc', component: EchartsProgressArc },
{ path: 'echarts-progress-circle', component: EchartsProgressCircle },
{ path: 'echarts-zoom', component: EchartsSpecialZoom },
{
path: 'empty-state-compact-break',
component: EmptyStateCompactBreak,
Expand Down
28 changes: 28 additions & 0 deletions packages/angular-test-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ import DropdownIcon from '../preview-examples/dropdown-icon';
import DropdownQuickActions from '../preview-examples/dropdown-quick-actions';
import DropdownSubmenu from '../preview-examples/dropdown-submenu';
import Echarts from '../preview-examples/echarts';
import EchartsSpecial3d from 'src/preview-examples/echarts-special-3d';
import EchartsBarSimple from '../preview-examples/echarts-bar-simple';
import EchartsBarHorizontalStacked from '../preview-examples/echarts-bar-horizontal-stacked';
import EchartsCircle from '../preview-examples/echarts-circle';
import EchartsEmptyState from '../preview-examples/echarts-empty-state';
import EchartsGauge from '../preview-examples/echarts-gauge';
import EchartsLineAdvanced from '../preview-examples/echarts-line-advanced';
import EchartsLineMultipleYAxis from '../preview-examples/echarts-line-multiple-y-axis';
import EchartsLineSimple from '../preview-examples/echarts-line-simple';
import EchartsPie from '../preview-examples/echarts-pie';
import EchartsSpecialToolbox from '../preview-examples/echarts-special-toolbox';
import EchartsSpecialZoom from '../preview-examples/echarts-special-zoom';
import EchartsProgressArc from '../preview-examples/echarts-progress-arc';
import EchartsProgressCircle from '../preview-examples/echarts-progress-circle';
import EmptyState from '../preview-examples/empty-state';
import EmptyStateCompact from '../preview-examples/empty-state-compact';
import EmptyStateCompactBreak from '../preview-examples/empty-state-compact-break';
Expand Down Expand Up @@ -234,6 +248,20 @@ import WorkflowVertical from '../preview-examples/workflow-vertical';
DropdownSubmenu,
Dropdown,
Echarts,
EchartsSpecial3d,
EchartsBarSimple,
EchartsBarHorizontalStacked,
EchartsCircle,
EchartsEmptyState,
EchartsGauge,
EchartsLineAdvanced,
EchartsLineMultipleYAxis,
EchartsLineSimple,
EchartsPie,
EchartsSpecialToolbox,
EchartsProgressArc,
EchartsProgressCircle,
EchartsSpecialZoom,
EmptyStateCompactBreak,
EmptyStateCompact,
EmptyState,
Expand Down
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>
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);
});
}
}
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>
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 packages/angular-test-app/src/preview-examples/echarts-circle.html
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 packages/angular-test-app/src/preview-examples/echarts-circle.ts
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);
});
}
}
Loading

0 comments on commit 4804d54

Please sign in to comment.