Repository navigation
Expand file tree
/
Copy pathChartView.js
More file actions
116 lines (110 loc) · 2.58 KB
/
Copy pathChartView.js
File metadata and controls
116 lines (110 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* Created by will on 2016/7/5.
*/
import {NativeModules} from 'react-native';
let CV = NativeModules.JSChartView;
import ChartLegend from './ChartLegend.js';
/**
* @class Layer
*/
export default class ChartView{
/**
* 设置标题
* @memberOf ChartView
* @param {string}Title - 图表标题
* @returns {Promise.<void>}
*/
async setTitle(Title){
try{
await CV.setTitle(this.chartviewId,Title);
}catch(e){
console.error(e);
}
}
/**
* 获取标题
* @memberOf ChartView
* @returns {Promise.<boolean>}
*/
async getTitle(){
try{
var{title} = await CV.getTitle(this.chartviewId);
return title;
}catch(e){
console.error(e);
}
}
/**
* 获取统计图图例
* @memberOf ChartView
* @returns {Promise.<ChartLegend>}
*/
async getLegend(){
try{
var {chartLegendId} = await CV.getLegend(this.chartviewId);
var chartLegend = new ChartLegend();
chartLegend.chartLegendId = chartLegendId;
return chartLegend;
}catch(e){
console.error(e);
}
}
/**
* 接入统计数据
* @memberOf ChartView
* @param {object}data - 统计数据
* @returns {Promise.<void>}
*/
async addChartData(data,timeTag){
try{
if(arguments.length==2){
await CV.addChartDataWithTime(this.chartviewId,data,timeTag);
}else{
await CV.addChartData(this.chartviewId,data);
}
}catch(e){
console.error(e);
}
}
/**
* 移除统计数据。
* @memberOf ChartView
* @param {object} data - 统计数据
* @returns {Promise.<void>}
*/
async removeChartData(timeTag){
try{
if(arguments.length ==1){
await CV.removeChartDataWithTimeTag(this.chartviewId,timeTag);
}else{
await CV.removeAllData(this.chartviewId);
}
}catch(e){
console.error(e);
}
}
/**
* 销毁图表
* @memberOf ChartView
* @returns {Promise.<void>}
*/
async dispose(){
try{
await CV.dispose(this.chartviewId);
}catch(e){
console.error(e);
}
}
/**
* 更新图表
* @memberOf ChartView
* @returns {Promise.<void>}
*/
async update(){
try{
await CV.update(this.chartviewId);
}catch(e){
console.error(e);
}
}
}