-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add a basic smith chart #5615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a basic smith chart #5615
Changes from 99 commits
9492c99
2ac5084
9366507
e45b7b8
6425813
f7cd0b0
3914dc0
97a2224
e2f6abd
7cbf9bc
7a6f86c
edee054
eeba96d
be8a250
17e60c0
c821377
7ee57e6
dc43dd1
2d6b6bf
bb444af
0fcb0fe
2abb96c
166199a
7346245
7e67229
1eb2d51
202d4a5
ce8f742
7e3e69c
71148d2
61ed436
b822f04
de9770d
ed8c75a
afd67e6
06e0c59
1dc00c7
135a6e5
eb94f46
dee7fc9
7dc4ac8
6258e63
752226b
03c78eb
df36ae3
83189cf
090251f
eddfcde
66ff9c1
7246742
5d6b528
8676ed2
316be5c
43a3be8
fdf7776
8d97671
cb07c28
2ca14f9
5c83a18
8f67a6b
e7b47da
3853720
e17fcef
9c9806e
bb59e34
3a9648d
736cf2c
33edd05
5605f78
9861349
23c1aed
f6c748c
b26f21c
8ace040
021d708
80de25d
6aabf51
8351bfa
71eedaa
6b0f08f
0063041
52f53ce
d5ad834
994bd49
d25ea5a
e18c8e8
25c75e4
600eee1
0128452
c2b84ec
d9f8b24
14a64c6
6fdabfc
08e4e63
7f8cb5d
5a329da
aa13b91
ffd19e7
383b6f1
7da2e28
fd0f370
c1613b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('../src/traces/scattersmith'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
attr: 'subplot', | ||
name: 'smith', | ||
|
||
axisNames: ['imaginaryaxis', 'realaxis'], | ||
axisName2dataArray: {imaginaryaxis: 'theta', realaxis: 'r'}, | ||
|
||
layerNames: [ | ||
'draglayer', | ||
'plotbg', | ||
'angular-grid', | ||
'radial-grid', | ||
'frontplot', | ||
'angular-line', | ||
'radial-line', | ||
'angular-axis', | ||
'radial-axis' | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
'use strict'; | ||
|
||
var getSubplotCalcData = require('../get_data').getSubplotCalcData; | ||
var counterRegex = require('../../lib').counterRegex; | ||
|
||
var createSmith = require('./smith'); | ||
var constants = require('./constants'); | ||
|
||
var attr = constants.attr; | ||
var name = constants.name; | ||
var counter = counterRegex(name); | ||
|
||
var attributes = {}; | ||
attributes[attr] = { | ||
valType: 'subplotid', | ||
dflt: name, | ||
editType: 'calc', | ||
description: [ | ||
'Sets a reference between this trace\'s data coordinates and', | ||
'a smith subplot.', | ||
'If *smith* (the default value), the data refer to `layout.smith`.', | ||
'If *smith2*, the data refer to `layout.smith2`, and so on.' | ||
].join(' ') | ||
}; | ||
|
||
function plot(gd) { | ||
var fullLayout = gd._fullLayout; | ||
var calcData = gd.calcdata; | ||
var subplotIds = fullLayout._subplots[name]; | ||
|
||
for(var i = 0; i < subplotIds.length; i++) { | ||
var id = subplotIds[i]; | ||
var subplotCalcData = getSubplotCalcData(calcData, name, id); | ||
var subplot = fullLayout[id]._subplot; | ||
|
||
if(!subplot) { | ||
subplot = createSmith(gd, id); | ||
fullLayout[id]._subplot = subplot; | ||
} | ||
|
||
subplot.plot(subplotCalcData, fullLayout, gd._promises); | ||
} | ||
} | ||
|
||
function clean(newFullData, newFullLayout, oldFullData, oldFullLayout) { | ||
var oldIds = oldFullLayout._subplots[name] || []; | ||
|
||
for(var i = 0; i < oldIds.length; i++) { | ||
var id = oldIds[i]; | ||
var oldSubplot = oldFullLayout[id]._subplot; | ||
|
||
if(!newFullLayout[id] && !!oldSubplot) { | ||
oldSubplot.framework.remove(); | ||
oldSubplot.layers['radial-axis-title'].remove(); | ||
|
||
for(var k in oldSubplot.clipPaths) { | ||
oldSubplot.clipPaths[k].remove(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
attr: attr, | ||
name: name, | ||
idRoot: name, | ||
idRegex: counter, | ||
attrRegex: counter, | ||
attributes: attributes, | ||
layoutAttributes: require('./layout_attributes'), | ||
supplyLayoutDefaults: require('./layout_defaults'), | ||
plot: plot, | ||
clean: clean, | ||
toSVG: require('../cartesian').toSVG | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of these may not be supported. |
||
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),' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. polar > smith ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed this in one of the previous commits (not sure which one). |
||
].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: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexcjohnson Do we need |
||
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' | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.