Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
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
Uh oh!
There was an error while loading. Please reload this page.
Add a basic smith chart #5615
Changes from all commits
9492c992ac50849366507e45b7b86425813f7cd0b03914dc097a2224e2f6abd7cbf9bc7a6f86cedee054eeba96dbe8a25017e60c0c8213777ee57e6dc43dd12d6b6bfbb444af0fcb0fe2abb96c166199a73462457e672291eb2d51202d4a5ce8f7427e3e69c71148d261ed436b822f04de9770ded8c75aafd67e606e0c591dc00c7135a6e5eb94f46dee7fc97dc4ac86258e63752226b03c78ebdf36ae383189cf090251feddfcde66ff9c172467425d6b5288676ed2316be5c43a3be8fdf77768d97671cb07c282ca14f95c83a188f67a6be7b47da3853720e17fcef9c9806ebb59e343a9648d736cf2c33edd055605f78986134923c1aedf6c748cb26f21c8ace040021d70880de25d6aabf518351bfa71eedaa6b0f08f006304152f53ced5ad834994bd49d25ea5ae18c8e825c75e4600eee10128452c2b84ecd9f8b2414a64c66fdabfc08e4e637f8cb5d5a329daaa13b91ffd19e7383b6f17da2e28fd0f370c1613b2File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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({ | ||
Contributor 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),' | ||
Contributor 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 ? ContributorAuthor 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: { | ||
Contributor 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.
Uh oh!
There was an error while loading. Please reload this page.