deno.land / x / billboardjs@3.6.0 / Chart / api / grid.y.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
/** * Copyright (c) 2017 ~ present NAVER Corp. * billboard.js project is licensed under the MIT license */import {extend} from "../../module/util";
/** * Update y grid lines. * @function ygrids * @instance * @memberof Chart * @param {Array} grids Y grid lines will be replaced with this argument. The format of this argument is the same as grid.y.lines. * @returns {object} * @example * // Show 2 y grid lines * chart.ygrids([ * {value: 100, text: "Label 1"}, * {value: 400, text: "Label 4"} * ]); * // --> Returns: [{value: 100, text: "Label 1"}, {value: 400, text: "Label 4"}] */function ygrids(grids: {value?: number, text?: string}[]): {value?: number, text?: string}[] { const $$ = this.internal; const {config} = $$;
if (!grids) { return config.grid_y_lines; }
config.grid_y_lines = grids; $$.redrawWithoutRescale();
return config.grid_y_lines;}
extend(ygrids, { /** * Add y grid lines.<br> * This API adds new y grid lines instead of replacing like ygrids. * @function ygrids․add * @instance * @memberof Chart * @param {Array|object} grids New y grid lines will be added. The format of this argument is the same as grid.y.lines and it's possible to give an Object if only one line will be added. * @returns {object} * @example * // Add a new x grid line * chart.ygrids.add( * {value: 400, text: "Label 4"} * ); * * // Add new x grid lines * chart.ygrids.add([ * {value: 200, text: "Label 2"}, * {value: 400, text: "Label 4"} * ]); */ add: function(grids: {value?: number, text?: string}[]): {value?: number, text?: string}[] { return this.ygrids( this.internal.config.grid_y_lines .concat(grids || []) ); },
/** * Remove y grid lines.<br> * This API removes x grid lines. * @function ygrids․remove * @instance * @memberof Chart * @param {object} params This argument should include value or class. If value is given, the y grid lines that have specified y value will be removed. If class is given, the y grid lines that have specified class will be removed. If args is not given, all of y grid lines will be removed. * @param {number} [params.value] target value * @param {string} [params.class] target class * @example * // y grid line on y = 200 will be removed * chart.ygrids.remove({value: 200}); * * // y grid lines that have 'grid-A' will be removed * chart.ygrids.remove({ * class: "grid-A" * }); * * // all of y grid lines will be removed * chart.ygrids.remove(); */ remove: function(params?: {value?: number, class?: string}): void { // TODO: multiple this.internal.removeGridLines(params, false); }});
export default {ygrids};
billboardjs

Version Info

Tagged at
2 years ago