import { Component, OnInit, OnDestroy } from '@angular/core'; @Component({ selector: 'cm-chart-doc-1', templateUrl: './cm-chart-doc-1.component.html', styleUrls: ['./cm-chart-doc-1.component.css'] }) export class CosmosChartDoc1Component implements OnInit, OnDestroy { public option: any; constructor() { } ngOnInit() { this.option = { title: { text: '大规模散点图' }, tooltip: { trigger: 'axis', showDelay: 0, axisPointer: { show: true, type: 'cross', lineStyle: { type: 'dashed', width: 1 } }, zlevel: 1 }, legend: { data: ['sin', 'cos'] }, toolbox: { show: true, feature: { mark: { show: true }, dataZoom: { show: true }, dataView: { show: true, readOnly: false }, restore: { show: true }, saveAsImage: { show: true } } }, xAxis: [ { type: 'value', scale: true } ], yAxis: [ { type: 'value', scale: true } ], series: [ { name: 'sin', type: 'scatter', large: true, symbolSize: 3, data: (function () { var d = []; var len = 10000; var x = 0; while (len--) { x = Number((Math.random() * 10).toFixed(3)) - 0; d.push([ x, //Math.random() * 10 Number((Math.sin(x) - x * (len % 2 ? 0.1 : -0.1) * Math.random()).toFixed(3)) - 0 ]); } //console.log(d) return d; })() }, { name: 'cos', type: 'scatter', large: true, symbolSize: 2, data: (function () { var d = []; var len = 20000; var x = 0; while (len--) { x = Number((Math.random() * 10).toFixed(3)) - 0; d.push([ x, //Math.random() * 10 Number((Math.cos(x) - x * (len % 2 ? 0.1 : -0.1) * Math.random()).toFixed(3)) - 0 ]); } //console.log(d) return d; })() } ] }; } ngOnDestroy() { } }