Skip to content

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

Merged
merged 102 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
9492c99
Add a dummy scattersmith trace
waxlamp Apr 5, 2021
2ac5084
Modify scattersmith trace to use `re` and `im` data series
waxlamp Apr 20, 2021
9366507
Perform gamma transform (with fixed z0 of unity)
waxlamp Apr 21, 2021
e45b7b8
Force smith chart to use radial range [0, 1]
waxlamp Apr 21, 2021
6425813
Add a WIP function to draw circular "real" lines
waxlamp Apr 28, 2021
f7cd0b0
WIP
waxlamp Jun 9, 2021
3914dc0
Display real ticks at 0.2, 0.5, 1.0, 2.0, 5.0
waxlamp Jun 9, 2021
97a2224
Draw grid lines for imaginary axis
waxlamp Jun 9, 2021
e2f6abd
Draw imaginary axis line properly
waxlamp Jun 9, 2021
7cbf9bc
Clip imaginary axis grid lines to correct angular bounds
waxlamp Jun 9, 2021
7a6f86c
Draw imaginary axis tick labels
waxlamp Jun 16, 2021
edee054
Draw tick labels for real axis
waxlamp Jun 16, 2021
eeba96d
Adjust placement of real axis tick labels
waxlamp Jun 16, 2021
be8a250
Automatic lint fixes
waxlamp Jun 18, 2021
17e60c0
Restrict points to within the smith chart area
waxlamp Jun 18, 2021
c821377
Fix non-automatic lint errors
waxlamp Jun 18, 2021
7ee57e6
Add mock and baseline for smith chart
waxlamp Jun 30, 2021
dc43dd1
Add "smith_lines" baseline
waxlamp Jul 7, 2021
2d6b6bf
Update smith_basic baseline
waxlamp Jul 7, 2021
bb444af
Add "smith_axes" mock and baseline
waxlamp Jul 7, 2021
0fcb0fe
Merge remote-tracking branch 'origin/master' into smith
waxlamp Jul 7, 2021
2abb96c
Update plot-schema.json
waxlamp Jul 7, 2021
166199a
Fix mock validation errors
waxlamp Jul 8, 2021
7346245
Add smith chart to list of subplots
waxlamp Jul 8, 2021
7e67229
Force smith mocks to run at the end
waxlamp Jul 8, 2021
1eb2d51
Rename "radialaxis" to "realaxis"
waxlamp Jul 16, 2021
202d4a5
Rename angularaxis to imaginaryaxis
waxlamp Jul 16, 2021
ce8f742
Merge remote-tracking branch 'origin/master' into smith
waxlamp Jul 19, 2021
7e3e69c
Disable unnecessary tick options
waxlamp Jul 28, 2021
71148d2
Remove options for axis types
waxlamp Jul 28, 2021
61ed436
Remove range options
waxlamp Jul 28, 2021
b822f04
Remove axis processing code for imaginary axis
waxlamp Jul 28, 2021
de9770d
Remove category options
waxlamp Jul 28, 2021
ed8c75a
Remove thetaunit option
waxlamp Jul 28, 2021
afd67e6
Remove period option
waxlamp Jul 28, 2021
06e0c59
Add a scattersmith test
waxlamp Aug 3, 2021
1dc00c7
Add a smith plot react test
waxlamp Aug 3, 2021
135a6e5
Merge remote-tracking branch 'origin/master' into smith
waxlamp Aug 3, 2021
eb94f46
Fix lint errors
waxlamp Aug 3, 2021
dee7fc9
Update schema diff
waxlamp Aug 3, 2021
7dc4ac8
Remove invalid options from mock
waxlamp Aug 3, 2021
6258e63
Remove "polar" category from smith trace
waxlamp Aug 4, 2021
752226b
Remove unnecessary function
waxlamp Aug 4, 2021
03c78eb
Update plot description
waxlamp Aug 4, 2021
df36ae3
Remove `angle` and `side` options from realaxis
waxlamp Aug 4, 2021
83189cf
Change "polar" to "smith"
waxlamp Aug 4, 2021
090251f
Remove deprecated attributes
waxlamp Aug 4, 2021
eddfcde
Rename "polar" to "smith" where definitely possible
waxlamp Aug 4, 2021
66ff9c1
Fix lint errors
waxlamp Aug 4, 2021
7246742
Update plot-schema diff
waxlamp Aug 4, 2021
5d6b528
Update baselines
waxlamp Aug 4, 2021
8676ed2
Merge remote-tracking branch 'origin/master' into smith
waxlamp Aug 4, 2021
316be5c
Rename polar to smith
waxlamp Aug 6, 2021
43a3be8
Remove references to GL versions of smith plot
waxlamp Aug 6, 2021
fdf7776
Remove commented-out lines
waxlamp Aug 6, 2021
8d97671
Remove commented-out code
waxlamp Aug 10, 2021
cb07c28
Refactor constant value lists into variables
waxlamp Aug 10, 2021
2ca14f9
Remove 'backplot' layer and unused drag logic
waxlamp Aug 10, 2021
5c83a18
Reuse polar/helpers.js
waxlamp Aug 10, 2021
8f67a6b
Remove GL logic
waxlamp Aug 10, 2021
e7b47da
Use Lib.bigFont()
waxlamp Aug 10, 2021
3853720
Remove logic to handle category type
waxlamp Aug 10, 2021
e17fcef
Remove category type logic
waxlamp Aug 10, 2021
9c9806e
Remove `hoverinfo` attribute
waxlamp Aug 10, 2021
bb59e34
Remove `texttemplate` attributes
waxlamp Aug 10, 2021
3a9648d
Add hover test for smith plot
waxlamp Aug 11, 2021
736cf2c
Add smith plot test
waxlamp Aug 11, 2021
33edd05
Use option fonts to control tick label rendering
waxlamp Aug 11, 2021
5605f78
Change "name" attr to "smith"
waxlamp Aug 11, 2021
9861349
Rename polarsublayer to smithsublayer
waxlamp Aug 11, 2021
23c1aed
Add and use a `_smithlayer`
waxlamp Aug 11, 2021
f6c748c
Rename axis attr variables
waxlamp Aug 13, 2021
b26f21c
Remove `hole` attribute
waxlamp Aug 13, 2021
8ace040
Remove `sector` attribute
waxlamp Aug 13, 2021
021d708
Remove `gridshape` attribute
waxlamp Aug 13, 2021
80de25d
Remove conditions on 'linear' type
waxlamp Aug 13, 2021
6aabf51
Remove unnecessary type check
waxlamp Aug 13, 2021
8351bfa
Remove unused zoom functions
waxlamp Aug 13, 2021
71eedaa
Remove other drag infrastructure
waxlamp Aug 13, 2021
6b0f08f
Remove the rest of the zoom infrastructure
waxlamp Aug 13, 2021
0063041
Restore texttemplate feature
waxlamp Aug 14, 2021
52f53ce
Merge remote-tracking branch 'origin/master' into smith
waxlamp Aug 16, 2021
d5ad834
Autofix lint errors
waxlamp Aug 16, 2021
994bd49
Remove category axis type processing
waxlamp Aug 16, 2021
d25ea5a
Update schema
waxlamp Aug 16, 2021
e18c8e8
Enable default fonts if spec doesn't specify any
waxlamp Aug 16, 2021
25c75e4
Regenerate baselines
waxlamp Aug 16, 2021
600eee1
Remove unnecessary constants
waxlamp Aug 16, 2021
0128452
Restore selection behavior
waxlamp Aug 16, 2021
c2b84ec
Fix lint errors
waxlamp Aug 16, 2021
d9f8b24
Add select test for scattersmith
waxlamp Aug 16, 2021
14a64c6
Use light blue bgcolor for zzz_smith_line
waxlamp Aug 18, 2021
6fdabfc
Use dark blue bgcolor in zzz_smith_line baseline
waxlamp Aug 18, 2021
08e4e63
Use gray paper bgcolor for smith axes baseline
waxlamp Aug 18, 2021
7f8cb5d
Update baselines
waxlamp Aug 18, 2021
5a329da
Add text labels to baselines
waxlamp Aug 18, 2021
aa13b91
Add baseline for connectgaps
waxlamp Aug 18, 2021
ffd19e7
Add a scattersmith mock to the mock list
waxlamp Aug 18, 2021
383b6f1
Add fill baseline
waxlamp Aug 18, 2021
7da2e28
Add a single plot baseline
waxlamp Sep 1, 2021
fd0f370
Coerce `hoverformat`
waxlamp Sep 1, 2021
c1613b2
Add tests modeled after tests in polar
waxlamp Sep 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Plotly.register([
require('./scatterpolar'),
require('./scatterpolargl'),
require('./barpolar'),
require('./scattersmith'),

// transforms
require('./aggregate'),
Expand Down
3 changes: 3 additions & 0 deletions lib/scattersmith.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('../src/traces/scattersmith');
3 changes: 3 additions & 0 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3729,6 +3729,9 @@ function makePlotFramework(gd) {
// single polar layer for the whole plot
fullLayout._polarlayer = fullLayout._paper.append('g').classed('polarlayer', true);

// single smith layer for the whole plot
fullLayout._smithlayer = fullLayout._paper.append('g').classed('smithlayer', true);

// single ternary layer for the whole plot
fullLayout._ternarylayer = fullLayout._paper.append('g').classed('ternarylayer', true);

Expand Down
21 changes: 21 additions & 0 deletions src/plots/smith/constants.js
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'
],
};
75 changes: 75 additions & 0 deletions src/plots/smith/index.js
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
};
163 changes: 163 additions & 0 deletions src/plots/smith/layout_attributes.js
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({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these may not be supported.
Let's test all the working features in the image test.

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),'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polar > smith ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcjohnson Do we need uirevision for smith charts?

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'
};
Loading