Debian Codegraph @

bqplot/js/src/ScatterGLModel.ts

raw
1 /* Copyright 2015 Bloomberg Finance L.P.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 import { MarkModel } from './MarkModel';
17 import * as serialize from './serialize';
18
19 export class ScatterGLModel extends MarkModel {
20 defaults() {
21 return {
22 ...MarkModel.prototype.defaults(),
23 _model_name: 'ScatterGLModel',
24 _view_name: 'ScatterGL',
25 x: [],
26 y: [],
27 color: null,
28 skew: null,
29 marker: 'circle',
30 stroke: null,
31 stroke_width: 1.5,
32 default_skew: 0.5,
33 default_size: 64,
34 names: [],
35 display_names: true,
36 fill: true,
37 drag_color: null,
38 drag_size: 5.0,
39 names_unique: true,
40 };
41 }
42
43 initialize(attributes, options) {
44 super.initialize(attributes, options);
45 this.update_domains();
46 }
47
48 update_domains() {
49 // color scale needs an issue in DateScaleModel to be fixed. It
50 // should be moved here as soon as that is fixed.
51 const scales = this.get('scales');
52 for (const key in scales) {
53 if (scales.hasOwnProperty(key) && key != 'color') {
54 const scale = scales[key];
55 if (!this.get('preserve_domain')[key]) {
56 scale.compute_and_set_domain(this.get(key), this.model_id + key);
57 } else {
58 scale.del_domain([], this.model_id + key);
59 }
60 }
61 }
62 }
63
64 static serializers = {
65 ...MarkModel.serializers,
66 x: serialize.array_or_json_serializer,
67 y: serialize.array_or_json_serializer,
68 color: serialize.array_or_json_serializer,
69 size: serialize.array_or_json_serializer,
70 rotation: serialize.array_or_json_serializer,
71 opacity: serialize.array_or_json_serializer,
72 opacities: serialize.array_or_json_serializer,
73 };
74 }