forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout_attributes.js
163 lines (136 loc) · 4.85 KB
/
layout_attributes.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
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
'use strict';
var colorAttrs = require('../../components/color/attributes');
var axesAttrs = require('../cartesian/layout_attributes');
var domainAttrs = require('../domain').attributes;
var extendFlat = require('../../lib').extendFlat;
var overrideAll = require('../../plot_api/edit_types').overrideAll;
var axisLineGridAttr = overrideAll({
color: axesAttrs.color,
showline: extendFlat({}, axesAttrs.showline, {dflt: true}),
linecolor: axesAttrs.linecolor,
linewidth: axesAttrs.linewidth,
showgrid: extendFlat({}, axesAttrs.showgrid, {dflt: true}),
gridcolor: axesAttrs.gridcolor,
gridwidth: axesAttrs.gridwidth
}, 'plot', 'from-root');
var axisTickAttrs = overrideAll({
tickmode: axesAttrs.tickmode,
tickvals: axesAttrs.tickvals,
ticktext: axesAttrs.ticktext,
ticks: axesAttrs.ticks,
ticklen: axesAttrs.ticklen,
tickwidth: axesAttrs.tickwidth,
tickcolor: axesAttrs.tickcolor,
showticklabels: axesAttrs.showticklabels,
showtickprefix: axesAttrs.showtickprefix,
tickprefix: axesAttrs.tickprefix,
showticksuffix: axesAttrs.showticksuffix,
ticksuffix: axesAttrs.ticksuffix,
showexponent: axesAttrs.showexponent,
exponentformat: axesAttrs.exponentformat,
minexponent: axesAttrs.minexponent,
separatethousands: axesAttrs.separatethousands,
tickfont: axesAttrs.tickfont,
tickangle: axesAttrs.tickangle,
tickformat: axesAttrs.tickformat,
tickformatstops: axesAttrs.tickformatstops,
layer: axesAttrs.layer
}, 'plot', 'from-root');
var realAxisAttrs = {
visible: extendFlat({}, axesAttrs.visible, {dflt: true}),
title: {
// radial title is not gui-editable at the moment,
// so it needs dflt: '', similar to carpet axes.
text: extendFlat({}, axesAttrs.title.text, {editType: 'plot', dflt: ''}),
font: extendFlat({}, axesAttrs.title.font, {editType: 'plot'}),
// TODO
// - might need a 'titleside' and even 'titledirection' down the road
// - what about standoff ??
editType: 'plot'
},
hoverformat: axesAttrs.hoverformat,
uirevision: {
valType: 'any',
editType: 'none',
description: [
'Controls persistence of user-driven changes in axis `range`,',
'`autorange`, `angle`, and `title` if in `editable: true` configuration.',
'Defaults to `smith<N>.uirevision`.'
].join(' ')
},
editType: 'calc',
};
extendFlat(
realAxisAttrs,
// N.B. realaxis grid lines are circular,
// but realaxis lines are straight from circle center to outer bound
axisLineGridAttr,
axisTickAttrs
);
var imaginaryAxisAttrs = {
visible: extendFlat({}, axesAttrs.visible, {dflt: true}),
direction: {
valType: 'enumerated',
values: ['counterclockwise', 'clockwise'],
dflt: 'counterclockwise',
editType: 'calc',
description: [
'Sets the direction corresponding to positive angles.'
].join(' ')
},
rotation: {
valType: 'angle',
editType: 'calc',
description: [
'Sets that start position (in degrees) of the angular axis',
'By default, smith subplots with `direction` set to *counterclockwise*',
'get a `rotation` of *0*',
'which corresponds to due East (like what mathematicians prefer).',
'In turn, smith with `direction` set to *clockwise* get a rotation of *90*',
'which corresponds to due North (like on a compass),'
].join(' ')
},
hoverformat: axesAttrs.hoverformat,
uirevision: {
valType: 'any',
editType: 'none',
description: [
'Controls persistence of user-driven changes in axis `rotation`.',
'Defaults to `smith<N>.uirevision`.'
].join(' ')
},
editType: 'calc'
};
extendFlat(
imaginaryAxisAttrs,
// N.B. angular grid lines are straight lines from circle center to outer bound
// the angular line is circular bounding the smith plot area.
axisLineGridAttr,
// N.B. ticksuffix defaults to '°' for angular axes with `thetaunit: 'degrees'`
axisTickAttrs
);
module.exports = {
// TODO for x/y/zoom system for paper-based zooming:
// x: {},
// y: {},
// zoom: {},
domain: domainAttrs({name: 'smith', editType: 'plot'}),
bgcolor: {
valType: 'color',
editType: 'plot',
dflt: colorAttrs.background,
description: 'Set the background color of the subplot'
},
realaxis: realAxisAttrs,
imaginaryaxis: imaginaryAxisAttrs,
uirevision: {
valType: 'any',
editType: 'none',
description: [
'Controls persistence of user-driven changes in axis attributes,',
'if not overridden in the individual axes.',
'Defaults to `layout.uirevision`.'
].join(' ')
},
editType: 'calc'
};