deno.land / x / billboardjs@3.6.0 / Chart / Chart.ts

نووسراو ببینە
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
117
118
119
120
121
122
123
124
125
126
/** * Copyright (c) 2017 ~ present NAVER Corp. * billboard.js project is licensed under the MIT license */import ChartInternal from "../ChartInternal/ChartInternal";import {loadConfig} from "../config/config";import {extend, isFunction, notEmpty} from "../module/util";
import apiChart from "./api/chart";import apiColor from "./api/color";import apiData from "./api/data";import apiExport from "./api/export";import apiFocus from "./api/focus";import apiLegend from "./api/legend";import apiLoad from "./api/load";import apiShow from "./api/show";import apiTooltip from "./api/tooltip";
/** * Main chart class. * - Note: Instantiated via `bb.generate()`. * @class Chart * @example * var chart = bb.generate({ * data: { * columns: [ * ["x", "2015-11-02", "2015-12-01", "2016-01-01", "2016-02-01", "2016-03-01"], * ["count1", 11, 8, 7, 6, 5 ], * ["count2", 9, 3, 6, 2, 8 ] * ]} * } * @see {@link bb.generate} for the initialization. *//** * Access instance's primary node elements * @member {object} $ * @property {object} $ Access instance's primary node elements * @property {d3.selection} $.chart Wrapper element * @property {d3.selection} $.svg Main svg element * @property {d3.selection} $.defs Definition element * @property {d3.selection} $.main Main grouping element * @property {d3.selection} $.tooltip Tooltip element * @property {d3.selection} $.legend Legend element * @property {d3.selection} $.title Title element * @property {d3.selection} $.grid Grid element * @property {d3.selection} $.arc Arc element * @property {d3.selection} $.circles Data point circle elements * @property {object} $.bar Bar element object * @property {d3.selection} $.bar.bars Bar elements * @property {d3.selection} $.candlestick Candlestick elements * @property {object} $.line Line element object * @property {d3.selection} $.line.lines Line elements * @property {d3.selection} $.line.areas Areas elements * @property {object} $.text Text element object * @property {d3.selection} $.text.texts Data label text elements * @memberof Chart * @example * var chart = bb.generate({ ... }); * * chart.$.chart; // wrapper element * chart.$.line.circles; // all data point circle elements *//** * Plugin instance array * @member {Array} plugins * @memberof Chart * @example * var chart = bb.generate({ * ... * plugins: [ * new bb.plugin.stanford({ ... }), * new PluginA() * ] * }); * * chart.plugins; // [Stanford, PluginA] - instance array */export default class Chart { public plugins = []; public internal: ChartInternal;
constructor(options) { const $$ = new ChartInternal(this);
this.internal = $$;
// bind to namespaced APIs (function bindThis(fn, target, argThis) { Object.keys(fn).forEach(key => { const isFunc = isFunction(fn[key]); const isChild = target !== argThis; const isNotNil = notEmpty(fn[key]); const hasChild = isNotNil && Object.keys(fn[key]).length > 0;
if (isFunc && ((!isChild && hasChild) || isChild)) { target[key] = fn[key].bind(argThis); } else if (isNotNil && !isFunc) { target[key] = {}; } else { target[key] = fn[key]; }
hasChild && bindThis(fn[key], target[key], argThis); }); })(Chart.prototype, this, this);
loadConfig.call($$, options);
$$.beforeInit(); $$.init(); }}
// extend common APIs as part of Chart classextend(Chart.prototype, [ apiChart, apiColor, apiData, apiExport, apiFocus, apiLegend, apiLoad, apiShow, apiTooltip]);
billboardjs

Version Info

Tagged at
2 years ago