page-echarts-start.component.ts 979 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {Component, AfterViewInit} from '@angular/core';
  2. import * as echarts from "echarts"
  3. @Component({
  4. selector: 'app-page-echarts-start',
  5. templateUrl: './page-echarts-start.component.html',
  6. styleUrls: ['./page-echarts-start.component.scss']
  7. })
  8. export class PageEchartsStartComponent implements AfterViewInit {
  9. ngAfterViewInit(): void {
  10. this.createEcharts();
  11. }
  12. async createEcharts() {
  13. let chartDom = document.getElementById('chart');
  14. let myChart = echarts.init(chartDom);
  15. let option;
  16. option = {
  17. title: {
  18. text: 'ECharts Getting Started Example'
  19. },
  20. tooltip: {},
  21. legend: {
  22. data: ['sales']
  23. },
  24. xAxis: {
  25. data: ['Shirts', 'Cardigans', 'Chiffons', 'Pants', 'Heels', 'Socks']
  26. },
  27. yAxis: {},
  28. series: [
  29. {
  30. name: 'sales',
  31. type: 'bar',
  32. data: [5, 20, 36, 10, 10, 20]
  33. }
  34. ]
  35. };
  36. option && myChart.setOption(option);
  37. }
  38. }