forked from stdlib-js/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
1911 lines (1830 loc) · 43.3 KB
/
main.js
File metadata and controls
1911 lines (1830 loc) · 43.3 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
var EventEmitter = require( 'events' ).EventEmitter;
var logger = require( 'debug' );
var objectKeys = require( '@stdlib/utils/keys' );
var defineProperty = require( '@stdlib/utils/define-property' );
var setReadOnly = require( '@stdlib/utils/define-read-only-property' );
var isObject = require( '@stdlib/assert/is-plain-object' );
var copy = require( '@stdlib/utils/copy' );
var inherit = require( '@stdlib/utils/inherit' );
var mergeFcn = require( '@stdlib/utils/merge' ).factory;
var minstd = require( '@stdlib/random/base/minstd' );
var format = require( '@stdlib/string/format' );
var view = require( './view/view.js' );
var defaults = require( './defaults.js' );
var setX = require( './props/x/set.js' );
var getX = require( './props/x/get.js' );
var setY = require( './props/y/set.js' );
var getY = require( './props/y/get.js' );
var setLabels = require( './props/labels/set.js' );
var getLabels = require( './props/labels/get.js' );
var setIsDefined = require( './props/is-defined/set.js' );
var getIsDefined = require( './props/is-defined/get.js' );
var setColors = require( './props/colors/set.js' );
var getColors = require( './props/colors/get.js' );
var setLineStyle = require( './props/line-style/set.js' );
var getLineStyle = require( './props/line-style/get.js' );
var setLineOpacity = require( './props/line-opacity/set.js' );
var getLineOpacity = require( './props/line-opacity/get.js' );
var setLineWidth = require( './props/line-width/set.js' );
var getLineWidth = require( './props/line-width/get.js' );
var setSymbols = require( './props/symbols/set.js' );
var getSymbols = require( './props/symbols/get.js' );
var setSymbolsSize = require( './props/symbols-size/set.js' );
var getSymbolsSize = require( './props/symbols-size/get.js' );
var setSymbolsOpacity = require( './props/symbols-opacity/set.js' );
var getSymbolsOpacity = require( './props/symbols-opacity/get.js' );
var setWidth = require( './props/width/set.js' );
var getWidth = require( './props/width/get.js' );
var setHeight = require( './props/height/set.js' );
var getHeight = require( './props/height/get.js' );
var setPaddingLeft = require( './props/padding-left/set.js' );
var getPaddingLeft = require( './props/padding-left/get.js' );
var setPaddingRight = require( './props/padding-right/set.js' );
var getPaddingRight = require( './props/padding-right/get.js' );
var setPaddingTop = require( './props/padding-top/set.js' );
var getPaddingTop = require( './props/padding-top/get.js' );
var setPaddingBottom = require( './props/padding-bottom/set.js' );
var getPaddingBottom = require( './props/padding-bottom/get.js' );
var setXMin = require( './props/x-min/set.js' );
var getXMin = require( './props/x-min/get.js' );
var setXMax = require( './props/x-max/set.js' );
var getXMax = require( './props/x-max/get.js' );
var setYMin = require( './props/y-min/set.js' );
var getYMin = require( './props/y-min/get.js' );
var setYMax = require( './props/y-max/set.js' );
var getYMax = require( './props/y-max/get.js' );
var setXScale = require( './props/x-scale/set.js' );
var getXScale = require( './props/x-scale/get.js' );
var setYScale = require( './props/y-scale/set.js' );
var getYScale = require( './props/y-scale/get.js' );
var setXTickFormat = require( './props/x-tick-format/set.js' );
var getXTickFormat = require( './props/x-tick-format/get.js' );
var setYTickFormat = require( './props/y-tick-format/set.js' );
var getYTickFormat = require( './props/y-tick-format/get.js' );
var setXNumTicks = require( './props/x-num-ticks/set.js' );
var getXNumTicks = require( './props/x-num-ticks/get.js' );
var setYNumTicks = require( './props/y-num-ticks/set.js' );
var getYNumTicks = require( './props/y-num-ticks/get.js' );
var setXAxisOrient = require( './props/x-axis-orient/set.js' );
var getXAxisOrient = require( './props/x-axis-orient/get.js' );
var setYAxisOrient = require( './props/y-axis-orient/set.js' );
var getYAxisOrient = require( './props/y-axis-orient/get.js' );
var setXRug = require( './props/x-rug/set.js' );
var getXRug = require( './props/x-rug/get.js' );
var setYRug = require( './props/y-rug/set.js' );
var getYRug = require( './props/y-rug/get.js' );
var setXRugOrient = require( './props/x-rug-orient/set.js' );
var getXRugOrient = require( './props/x-rug-orient/get.js' );
var setYRugOrient = require( './props/y-rug-orient/set.js' );
var getYRugOrient = require( './props/y-rug-orient/get.js' );
var setXRugOpacity = require( './props/x-rug-opacity/set.js' );
var getXRugOpacity = require( './props/x-rug-opacity/get.js' );
var setYRugOpacity = require( './props/y-rug-opacity/set.js' );
var getYRugOpacity = require( './props/y-rug-opacity/get.js' );
var setXRugSize = require( './props/x-rug-size/set.js' );
var getXRugSize = require( './props/x-rug-size/get.js' );
var setYRugSize = require( './props/y-rug-size/set.js' );
var getYRugSize = require( './props/y-rug-size/get.js' );
var setDescription = require( './props/description/set.js' );
var getDescription = require( './props/description/get.js' );
var setTitle = require( './props/title/set.js' );
var getTitle = require( './props/title/get.js' );
var setXLabel = require( './props/x-label/set.js' );
var getXLabel = require( './props/x-label/get.js' );
var setYLabel = require( './props/y-label/set.js' );
var getYLabel = require( './props/y-label/get.js' );
var setEngine = require( './props/engine/set.js' );
var getEngine = require( './props/engine/get.js' );
var setAutoRender = require( './props/auto-render/set.js' );
var getAutoRender = require( './props/auto-render/get.js' );
var setRenderFormat = require( './props/render-format/set.js' );
var getRenderFormat = require( './props/render-format/get.js' );
var setViewer = require( './props/viewer/set.js' );
var getViewer = require( './props/viewer/get.js' );
var setAutoView = require( './props/auto-view/set.js' );
var getAutoView = require( './props/auto-view/get.js' );
var getGraphWidth = require( './props/graph-width/get.js' );
var getGraphHeight = require( './props/graph-height/get.js' );
var getXDomain = require( './props/x-domain/get.js' );
var getYDomain = require( './props/y-domain/get.js' );
var getXRange = require( './props/x-range/get.js' );
var getYRange = require( './props/y-range/get.js' );
var getXPos = require( './props/x-pos/get.js' );
var getYPos = require( './props/y-pos/get.js' );
var render = require( './render' );
var viewMethod = require( './view' );
// VARIABLES //
var debug = logger( 'plot:main' );
var PRIVATE_PROPS = [
'_autoRender',
'_autoView',
'_colors',
'_description',
'_engine',
'_height',
'_isDefined',
'_labels',
'_lineOpacity',
'_lineStyle',
'_lineWidth',
'_paddingBottom',
'_paddingLeft',
'_paddingRight',
'_paddingTop',
'_renderFormat',
'_symbols',
'_symbolsOpacity',
'_symbolsSize',
'_title',
'_viewer',
'_width',
'_xAxisOrient',
'_xData',
'_xLabel',
'_xMax',
'_xMin',
'_xNumTicks',
'_xRug',
'_xRugOpacity',
'_xRugOrient',
'_xRugSize',
'_xScale',
'_xTickFormat',
'_yAxisOrient',
'_yData',
'_yLabel',
'_yMax',
'_yMin',
'_yNumTicks',
'_yRug',
'_yRugOpacity',
'_yRugOrient',
'_yRugSize',
'_yScale',
'_yTickFormat'
];
// FUNCTIONS //
var merge = mergeFcn({
'extend': false
});
// MAIN //
/**
* Plot constructor.
*
* @constructor
* @param {Array} [x] - x-values
* @param {Array} [y] - y-values
* @param {Options} [options] - constructor options
* @param {boolean} [options.autoRender=false] - indicates whether to re-render on a change event
* @param {boolean} [options.autoView=false] - indicates whether to generate an updated view on a render event
* @param {(string|StringArray)} [options.colors='category10'] - data colors
* @param {string} [options.description=''] - plot description
* @param {string} [options.engine='svg'] - plot engine
* @param {PositiveNumber} [options.height=400] - plot height
* @param {Function} [options.isDefined] - accessor indicating whether a datum is defined
* @param {(StringArray|EmptyArray)} [options.labels] - data labels
* @param {(number|NumberArray)} [options.lineOpacity=0.9] - data line opacity
* @param {(string|StringArray)} [options.lineStyle='-'] - data line style(s)
* @param {(NonNegativeInteger|Array<NonNegativeInteger>)} [options.lineWidth=2] - data line width(s)
* @param {NonNegativeInteger} [options.paddingBottom=80] - bottom padding
* @param {NonNegativeInteger} [options.paddingLeft=90] - left padding
* @param {NonNegativeInteger} [options.paddingRight=20] - right padding
* @param {NonNegativeInteger} [options.paddingTop=80] - top padding
* @param {string} [options.renderFormat='vdom'] - plot render format
* @param {(string|StringArray)} [options.symbols='none'] - data symbols
* @param {(number|NumberArray)} [options.symbolsOpacity=0.9] - symbols opacity
* @param {(NonNegativeInteger|Array<NonNegativeInteger>)} [options.symbolsSize=6] - symbols size
* @param {string} [options.title=''] - plot title
* @param {string} [options.viewer='none'] - plot viewer
* @param {PositiveNumber} [options.width=400] - plot width
* @param {Array} [options.x=[]] - x-values
* @param {string} [options.xAxisOrient='bottom'] - x-axis orientation
* @param {string} [options.xLabel='x'] - x-axis label
* @param {(Date|FiniteNumber|null)} [options.xMax=null] - maximum value of x-axis domain
* @param {(Date|FiniteNumber|null)} [options.xMin=null] - minimum value of x-axis domain
* @param {(NonNegativeInteger|null)} [options.xNumTicks=5] - number of x-axis tick marks
* @param {(boolean|BooleanArray)} [options.xRug=false] - indicates whether to render a rug plot along the x-axis
* @param {(string|StringArray)} [options.xRugOrient='bottom'] - x-axis rug orientation
* @param {(number|NumberArray)} [options.xRugOpacity=0.1] - x-axis rug opacity
* @param {(NonNegativeInteger|Array<NonNegativeInteger>)} [options.xRugSize=6] - x-axis rug tick (tassel) size
* @param {string} [options.xScale='linear'] - x-axis scale
* @param {(string|null)} [options.xTickFormat=null] - x-axis tick format
* @param {Array} [options.y=[]] - y-values
* @param {string} [options.yAxisOrient='left'] - y-axis orientation
* @param {string} [options.yLabel='y'] - y-axis label
* @param {(FiniteNumber|null)} [options.yMax=null] - maximum value of y-axis domain
* @param {(FiniteNumber|null)} [options.yMin=null] - minimum value of y-axis domain
* @param {(NonNegativeInteger|null)} [options.yNumTicks=5] - number of y-axis tick marks
* @param {(boolean|BooleanArray)} [options.yRug=false] - indicates whether to render a rug plot along the y-axis
* @param {(string|StringArray)} [options.yRugOrient='left'] - y-axis rug orientation
* @param {(number|NumberArray)} [options.yRugOpacity=0.1] - y-axis rug opacity
* @param {(NonNegativeInteger|Array<NonNegativeInteger>)} [options.yRugSize=6] - y-axis rug tick (tassel) size
* @param {string} [options.yScale='linear'] - y-axis scale
* @param {(string|null)} [options.yTickFormat=null] - y-axis tick format
* @throws {TypeError} must provide valid options
* @returns {Plot} Plot instance
*
* @example
* var plot = new Plot();
*/
function Plot() {
var options;
var nargs;
var keys;
var self;
var opts;
var key;
var i;
nargs = arguments.length;
if ( !(this instanceof Plot) ) {
if ( nargs === 0 ) {
return new Plot();
}
if ( nargs === 1 ) {
return new Plot( arguments[0] );
}
if ( nargs === 2 ) {
return new Plot( arguments[0], arguments[1] );
}
return new Plot( arguments[0], arguments[1], arguments[2] );
}
self = this;
opts = defaults();
if ( nargs === 0 ) {
options = {};
} else if ( nargs === 1 ) {
options = arguments[ 0 ];
if ( !isObject( options ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
}
} else if ( nargs === 2 ) {
options = {
'x': arguments[ 0 ],
'y': arguments[ 1 ]
};
} else if ( nargs > 2 ) {
if ( !isObject( arguments[2] ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arguments[2] ) );
}
options = copy( arguments[2] ); // avoid mutation
options.x = arguments[ 0 ];
options.y = arguments[ 1 ];
}
opts = merge( opts, options );
debug( 'Creating an instance with the following configuration: %s.', JSON.stringify( opts ) );
EventEmitter.call( this );
for ( i = 0; i < PRIVATE_PROPS.length; i++ ) {
defineProperty( this, PRIVATE_PROPS[i], {
'configurable': false,
'enumerable': false,
'writable': true,
'value': null
});
}
// Set a clipping path id:
defineProperty( this, '_clipPathId', {
'configurable': false,
'enumerable': false,
'writable': false,
'value': minstd().toString() // TODO: uuid
});
// Initialize an internal cache for renderers...
defineProperty( this, '$', {
'configurable': false,
'enumerable': false,
'writable': false,
'value': {}
});
defineProperty( this.$, 'svg', {
'configurable': false,
'enumerable': false,
'writable': false,
'value': {}
});
// Set options...
keys = objectKeys( opts );
for ( i = 0; i < keys.length; i++ ) {
key = keys[ i ];
this[ key ] = opts[ key ];
}
// Add event listeners:
this.on( 'change', onChange );
this.on( 'render', onRender );
return this;
/**
* Callback invoked upon receiving a change event.
*
* @private
*/
function onChange() {
/* eslint-disable no-underscore-dangle */
debug( 'Received a change event.' );
if ( self._autoRender ) {
self.render();
}
}
/**
* Callback invoked upon receiving a render event.
*
* @private
* @param {*} plot - rendered plot
*/
function onRender( plot ) {
/* eslint-disable no-underscore-dangle */
debug( 'Received a render event.' );
if ( self._autoView ) {
debug( 'Viewer: %s.', self._viewer );
debug( 'Generating view...' );
view( self, self._viewer, plot );
}
}
}
/*
* Inherit from the `EventEmitter` prototype.
*/
inherit( Plot, EventEmitter );
/**
* `x` values.
*
* @name x
* @memberof Plot.prototype
* @type {Array}
* @throws {TypeError} must be an array
* @default []
*
* @example
* var plot = new Plot();
* plot.x = [ [ 1417563950959, 1417563952959 ] ];
*
* @example
* var plot = new Plot({
* 'x': [ [ 1417563950959, 1417563952959 ] ]
* });
* var x = plot.x;
* // returns [ [ 1417563950959, 1417563952959 ] ]
*/
defineProperty( Plot.prototype, 'x', {
'configurable': false,
'enumerable': true,
'set': setX,
'get': getX
});
/**
* `y` values.
*
* @name y
* @memberof Plot.prototype
* @type {Array}
* @throws {TypeError} must be an array
* @default []
*
* @example
* var plot = new Plot();
* plot.x = [ [ 1417563950959, 1417563952959 ] ];
* plot.y = [ [ 0.25, 0.23 ] ];
*
* @example
* var plot = new Plot({
* 'x': [ [ 1417563950959, 1417563952959 ] ],
* 'y': [ [ 0.25, 0.23 ] ]
* });
* var y = plot.y;
* // returns [ [ 0.25, 0.23 ] ]
*/
defineProperty( Plot.prototype, 'y', {
'configurable': false,
'enumerable': true,
'set': setY,
'get': getY
});
/**
* Data labels.
*
* @name labels
* @memberof Plot.prototype
* @type {(StringArray|EmptyArray)}
* @throws {TypeError} must be either an array of strings or an empty array
* @default []
*
* @example
* var plot = new Plot();
* plot.labels = [ 'beep', 'boop' ];
*
* @example
* var plot = new Plot({
* 'labels': [ 'beep', 'boop' ]
* });
* var labels = plot.labels;
* // returns [ 'beep', 'boop' ]
*/
defineProperty( Plot.prototype, 'labels', {
'configurable': false,
'enumerable': true,
'set': setLabels,
'get': getLabels
});
/**
* Accessor which defines whether a datum is defined.
*
* ## Notes
*
* - This accessor is used to define how missing values are encoded.
* - The default behavior is to ignore values which are `NaN`.
*
* @name isDefined
* @memberof Plot.prototype
* @type {Function}
* @param {*} d - datum
* @param {integer} i - index
* @throws {TypeError} must be a function
*
* @example
* var plot = new Plot();
* plot.isDefined = function isDefined( d ) {
* // Check for `NaN`:
* return ( d === d );
* }
*
* @example
* function isDefined( d ) {
* // Check for `NaN`:
* return ( d === d );
* }
* var plot = new Plot({
* 'isDefined': isDefined
* });
* var fcn = plot.isDefined;
* // returns <Function>
*/
defineProperty( Plot.prototype, 'isDefined', {
'configurable': false,
'enumerable': true,
'set': setIsDefined,
'get': getIsDefined
});
/**
* Data colors. When retrieved, the returned value is always an `array`.
*
* @name colors
* @memberof Plot.prototype
* @type {(string|StringArray)}
* @throws {TypeError} must be either a string or an array of strings
* @default 'category10'
*
* @example
* var plot = new Plot();
* plot.colors = 'category20';
*
* @example
* var plot = new Plot({
* 'colors': 'category20'
* });
* var colors = plot.colors;
* // returns [...]
*/
defineProperty( Plot.prototype, 'colors', {
'configurable': false,
'enumerable': true,
'set': setColors,
'get': getColors
});
/**
* Data line style(s).
*
* ## Notes
*
* - When retrieved, the returned value is always an `array`.
*
* @name lineStyle
* @memberof Plot.prototype
* @type {(string|StringArray)}
* @throws {TypeError} must be a string or string array
* @throws {Error} must be a supported line style
* @default '-'
*
* @example
* var plot = new Plot();
* plot.lineStyle = [ '-', 'none' ];
*
* @example
* var plot = new Plot({
* 'lineStyle': 'none'
* });
* var lineStyle = plot.lineStyle;
* // returns [ 'none' ]
*/
defineProperty( Plot.prototype, 'lineStyle', {
'configurable': false,
'enumerable': true,
'set': setLineStyle,
'get': getLineStyle
});
/**
* Data line opacity.
*
* ## Notes
*
* - When retrieved, the returned value is always an `array`.
*
* @name lineOpacity
* @memberof Plot.prototype
* @type {(number|NumberArray)}
* @throws {TypeError} must be a number or number array
* @throws {RangeError} must be a number on the interval `[0,1]`
* @default '0.9'
*
* @example
* var plot = new Plot();
* plot.lineOpacity = [ 1.0, 0.5 ];
*
* @example
* var plot = new Plot({
* 'lineOpacity': 0.5
* });
* var opacity = plot.lineOpacity;
* // returns [ 0.5 ]
*/
defineProperty( Plot.prototype, 'lineOpacity', {
'configurable': false,
'enumerable': true,
'set': setLineOpacity,
'get': getLineOpacity
});
/**
* Data line width.
*
* ## Notes
*
* - When retrieved, the returned value is always an `array`.
*
* @name lineWidth
* @memberof Plot.prototype
* @type {(NonNegativeInteger|NonNegativeIntegerArray)}
* @throws {TypeError} must be a nonnegative integer or nonnegative integer array
* @default 2
*
* @example
* var plot = new Plot();
* plot.lineWidth = 1;
*
* @example
* var plot = new Plot({
* 'lineWidth': [ 1, 3 ]
* });
* var width = plot.lineWidth;
* // returns [ 1, 3 ]
*/
defineProperty( Plot.prototype, 'lineWidth', {
'configurable': false,
'enumerable': true,
'set': setLineWidth,
'get': getLineWidth
});
/**
* Data symbols. When retrieved, the returned value is always an `array`.
*
* @name symbols
* @memberof Plot.prototype
* @type {(string|StringArray)}
* @throws {TypeError} must be a string or string array
* @throws {Error} must be a supported symbol
* @default 'none'
*
* @example
* var plot = new Plot();
* plot.symbols = [ 'open-circle', 'closed-circle' ];
*
* @example
* var plot = new Plot({
* 'symbols': 'closed-circle'
* });
* var symbols = plot.symbols;
* // returns [ 'closed-circle' ]
*/
defineProperty( Plot.prototype, 'symbols', {
'configurable': false,
'enumerable': true,
'set': setSymbols,
'get': getSymbols
});
/**
* Symbols size. When retrieved, the returned value is always an `array`.
*
* @name symbolsSize
* @memberof Plot.prototype
* @type {(NonNegativeInteger|NonNegativeIntegerArray)}
* @throws {TypeError} must be a nonnegative integer or nonnegative integer array
* @default 6
*
* @example
* var plot = new Plot();
* plot.symbolsSize = 4;
*
* @example
* var plot = new Plot({
* 'symbolsSize': [ 4, 6 ]
* });
* var size = plot.symbolsSize;
* // returns [ 4, 6 ]
*/
defineProperty( Plot.prototype, 'symbolsSize', {
'configurable': false,
'enumerable': true,
'set': setSymbolsSize,
'get': getSymbolsSize
});
/**
* Symbols opacity. When retrieved, the returned value is always an `array`.
*
* @name symbolsOpacity
* @memberof Plot.prototype
* @type {(number|NumberArray)}
* @throws {TypeError} must be a number or number array
* @throws {RangeError} must be a number on the interval `[0,1]`
* @default 0.9
*
* @example
* var plot = new Plot();
* plot.symbolsOpacity = [ 0.2, 0.5 ];
*
* @example
* var plot = new Plot({
* 'symbolsOpacity': 0.2
* });
* var opacity = plot.symbolsOpacity;
* // returns [ 0.2 ]
*/
defineProperty( Plot.prototype, 'symbolsOpacity', {
'configurable': false,
'enumerable': true,
'set': setSymbolsOpacity,
'get': getSymbolsOpacity
});
/**
* Plot width.
*
* @name width
* @memberof Plot.prototype
* @type {PositiveNumber}
* @throws {TypeError} must be a positive number
* @default 400 (px)
*
* @example
* var plot = new Plot();
* plot.width = 100;
*
* @example
* var plot = new Plot({
* 'width': 480
* });
* var width = plot.width;
* // returns 480
*/
defineProperty( Plot.prototype, 'width', {
'configurable': false,
'enumerable': true,
'set': setWidth,
'get': getWidth
});
/**
* Plot height.
*
* @name height
* @memberof Plot.prototype
* @type {PositiveNumber}
* @throws {TypeError} must be a positive number
* @default 400 (px)
*
* @example
* var plot = new Plot();
* plot.height = 100;
*
* @example
* var plot = new Plot({
* 'height': 360
* });
* var height = plot.height;
* // returns 360
*/
defineProperty( Plot.prototype, 'height', {
'configurable': false,
'enumerable': true,
'set': setHeight,
'get': getHeight
});
/**
* Plot left padding.
*
* ## Notes
*
* - Typically used to create space for a left-oriented y-axis.
*
* @name paddingLeft
* @memberof Plot.prototype
* @type {NonNegativeInteger}
* @throws {TypeError} must be a nonnegative integer
* @default 90 (px)
*
* @example
* var plot = new Plot();
* plot.paddingLeft = 100;
*
* @example
* var plot = new Plot({
* 'paddingLeft': 100
* });
* var padding = plot.paddingLeft;
* // returns 100
*/
defineProperty( Plot.prototype, 'paddingLeft', {
'configurable': false,
'enumerable': true,
'set': setPaddingLeft,
'get': getPaddingLeft
});
/**
* Plot right padding.
*
* ## Notes
*
* - Typically used to create space for a right-oriented y-axis.
*
* @name paddingRight
* @memberof Plot.prototype
* @type {NonNegativeInteger}
* @throws {TypeError} must be a nonnegative integer
* @default 20 (px)
*
* @example
* var plot = new Plot();
* plot.paddingRight = 100;
*
* @example
* var plot = new Plot({
* 'paddingRight': 100
* });
* var padding = plot.paddingRight;
* // returns 100
*/
defineProperty( Plot.prototype, 'paddingRight', {
'configurable': false,
'enumerable': true,
'set': setPaddingRight,
'get': getPaddingRight
});
/**
* Plot top padding.
*
* ## Notes
*
* - Typically used to create space for a title or top-oriented x-axis.
*
* @name paddingTop
* @memberof Plot.prototype
* @type {NonNegativeInteger}
* @throws {TypeError} must be a nonnegative integer
* @default 80 (px)
*
* @example
* var plot = new Plot();
* plot.paddingTop = 100;
*
* @example
* var plot = new Plot({
* 'paddingTop': 100
* });
* var padding = plot.paddingTop;
* // returns 100
*/
defineProperty( Plot.prototype, 'paddingTop', {
'configurable': false,
'enumerable': true,
'set': setPaddingTop,
'get': getPaddingTop
});
/**
* Plot bottom padding.
*
* ## Notes
*
* - Typically used to create space for a bottom-oriented y-axis.
*
* @name paddingBottom
* @memberof Plot.prototype
* @type {NonNegativeInteger}
* @throws {TypeError} must be a nonnegative integer
* @default 80 (px)
*
* @example
* var plot = new Plot();
* plot.paddingBottom = 100;
*
* @example
* var plot = new Plot({
* 'paddingBottom': 100
* });
* var padding = plot.paddingBottom;
* // returns 100
*/
defineProperty( Plot.prototype, 'paddingBottom', {
'configurable': false,
'enumerable': true,
'set': setPaddingBottom,
'get': getPaddingBottom
});
/**
* Minimum value of the x-axis domain.
*
* ## Notes
*
* - When retrieved, if the value has been set to `null`, the returned value is computed from the `x` data.
*
* @name xMin
* @memberof Plot.prototype
* @type {(FiniteNumber|null)}
* @throws {TypeError} must be a finite number or null
* @default null
*
* @example
* var plot = new Plot();
* plot.xMin = -1.0;
*
* @example
* var plot = new Plot({
* 'xMin': -10.0
* });
* var xmin = plot.xMin;
* // returns -10.0
*/
defineProperty( Plot.prototype, 'xMin', {
'configurable': false,
'enumerable': true,
'set': setXMin,
'get': getXMin
});
/**
* Maximum value of the x-axis domain.
*
* ## Notes
*
* - When retrieved, if the value has been set to `null`, the returned value is computed from the `x` data.
*
* @name xMax
* @memberof Plot.prototype
* @type {(FiniteNumber|null)}
* @throws {TypeError} must be a finite number or null
* @default null
*
* @example
* var plot = new Plot();
* plot.xMax = 100.0;
*
* @example
* var plot = new Plot({
* 'xMax': 10.0
* });
* var xmax = plot.xMax;
* // returns 10.0
*/
defineProperty( Plot.prototype, 'xMax', {
'configurable': false,
'enumerable': true,
'set': setXMax,
'get': getXMax
});
/**
* Minimum value of the y-axis domain.
*
* ## Notes
*
* - When retrieved, if the value has been set to `null`, the returned value is computed from the `y` data.
*
* @name yMin
* @memberof Plot.prototype
* @type {(FiniteNumber|null)}
* @throws {TypeError} must be a finite number or null
* @default null
*
* @example
* var plot = new Plot();
* plot.yMin = -100.0;
*
* @example
* var plot = new Plot({
* 'yMin': 3.14
* });
* var ymin = plot.yMin;
* // returns 3.14
*/
defineProperty( Plot.prototype, 'yMin', {
'configurable': false,
'enumerable': true,
'set': setYMin,
'get': getYMin
});
/**
* Maximum value of the y-axis domain.
*
* ## Notes
*
* - When retrieved, if the value has been set to `null`, the returned value is computed from the `y` data.
*
* @name yMax
* @memberof Plot.prototype
* @type {(FiniteNumber|null)}
* @throws {TypeError} must be a finite number or null
* @default null
*
* @example
* var plot = new Plot();