-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
59 lines (49 loc) · 1.98 KB
/
index.js
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
import Visualization from 'zeppelin-vis'
import AdvancedTransformation from 'zeppelin-tabledata/advanced-transformation'
import { renderSimpleCard, } from './cards/simple.js'
export default class ZeppelinNumber extends Visualization {
constructor(targetEl, config) {
super(targetEl, config)
const spec = {
charts: {
'simple': {
transform: { method: 'raw', },
sharedAxis: false,
axis: {
'main title': { dimension: 'single', axisType: 'key', },
'secondary title': { dimension: 'multiple', axisType: 'aggregator', },
},
parameter: {
'fontColor': { valueType: 'string', defaultValue: 'black', description: 'font color', },
'fontSize': { widget: 'option', valueType: 'string', defaultValue: 'medium', description: 'font size', optionValues: ['small', 'medium', 'large',], },
'alignment': { widget: 'option', valueType: 'string', defaultValue: 'center', description: 'alignment', optionValues: ['left', 'right', 'center',], },
'iconName': { valueType: 'string', defaultValue: '', description: 'font awesome icon name. Ex: users' },
'showTitle': { widget: 'checkbox', valueType: 'boolean', defaultValue: true, description: 'show title', },
'prefix': { valueType: 'string', defaultValue: '', description: 'prefix', },
'suffix': { valueType: 'string', defaultValue: '', description: 'suffix', },
},
}
},
}
this.transformation = new AdvancedTransformation(config, spec)
}
render(data) {
const {
chartChanged, parameterChanged,
chart, parameter, column, transformer,
} = data
const rows = transformer()
let content = ''
try {
if (chart === 'simple') {
content = renderSimpleCard(rows, column, parameter)
}
} catch (error) {
console.error(error)
}
this.targetEl.html(content)
}
getTransformation() {
return this.transformation
}
}