-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add formatLabels module method for scatter{polar,geo,ternary,carpet}
... in an effort to bring texttemplate and hover coordinates formatting to the same place.
- Loading branch information
Showing
15 changed files
with
163 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright 2012-2019, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Axes = require('../../plots/cartesian/axes'); | ||
|
||
module.exports = function formatLabels(cdi, trace, fullLayout) { | ||
var labels = {}; | ||
|
||
var mockGd = {_fullLayout: fullLayout}; | ||
var xa = Axes.getFromTrace(mockGd, trace, 'x'); | ||
var ya = Axes.getFromTrace(mockGd, trace, 'y'); | ||
|
||
labels.xLabel = Axes.tickText(xa, cdi.x, true).text; | ||
labels.yLabel = Axes.tickText(ya, cdi.y, true).text; | ||
|
||
return labels; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2012-2019, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = function formatLabels(cdi, trace) { | ||
var labels = {}; | ||
|
||
var carpet = trace._carpet; | ||
var ij = carpet.ab2ij([cdi.a, cdi.b]); | ||
var i0 = Math.floor(ij[0]); | ||
var ti = ij[0] - i0; | ||
var j0 = Math.floor(ij[1]); | ||
var tj = ij[1] - j0; | ||
var xy = carpet.evalxy([], i0, j0, ti, tj); | ||
|
||
labels.yLabel = xy[1].toFixed(3); | ||
|
||
return labels; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright 2012-2019, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Axes = require('../../plots/cartesian/axes'); | ||
|
||
module.exports = function formatLabels(cdi, trace, fullLayout) { | ||
var labels = {}; | ||
|
||
var geo = fullLayout[trace.geo]._subplot; | ||
var ax = geo.mockAxis; | ||
var lonlat = cdi.lonlat; | ||
labels.lonLabel = Axes.tickText(ax, ax.c2l(lonlat[0]), true).text; | ||
labels.latLabel = Axes.tickText(ax, ax.c2l(lonlat[1]), true).text; | ||
|
||
return labels; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright 2012-2019, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Lib = require('../../lib'); | ||
var Axes = require('../../plots/cartesian/axes'); | ||
|
||
module.exports = function formatLabels(cdi, trace, fullLayout) { | ||
var labels = {}; | ||
|
||
var subplot = fullLayout[trace.subplot]._subplot; | ||
var radialAxis; | ||
var angularAxis; | ||
|
||
// for scatterpolargl texttemplate, _subplot is NOT defined, this takes part during the convert step | ||
// TODO we should consider moving the texttemplate formatting logic to the plot step | ||
if(!subplot) { | ||
subplot = fullLayout[trace.subplot]; | ||
radialAxis = subplot.radialaxis; | ||
angularAxis = subplot.angularaxis; | ||
} else { | ||
radialAxis = subplot.radialAxis; | ||
angularAxis = subplot.angularAxis; | ||
} | ||
|
||
var rVal = radialAxis.c2l(cdi.r); | ||
labels.rLabel = Axes.tickText(radialAxis, rVal, true).text; | ||
|
||
// N.B here the ° sign is part of the formatted value for thetaunit:'degrees' | ||
var thetaVal = angularAxis.thetaunit === 'degrees' ? Lib.rad2deg(cdi.theta) : cdi.theta; | ||
labels.thetaLabel = Axes.tickText(angularAxis, thetaVal, true).text; | ||
|
||
return labels; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright 2012-2019, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Axes = require('../../plots/cartesian/axes'); | ||
|
||
module.exports = function formatLabels(cdi, trace, fullLayout) { | ||
var labels = {}; | ||
|
||
var subplot = fullLayout[trace.subplot]._subplot; | ||
labels.aLabel = Axes.tickText(subplot.aaxis, cdi.a, true).text; | ||
labels.bLabel = Axes.tickText(subplot.baxis, cdi.b, true).text; | ||
labels.cLabel = Axes.tickText(subplot.caxis, cdi.c, true).text; | ||
|
||
return labels; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters