-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathformat_labels.js
32 lines (25 loc) · 1.08 KB
/
format_labels.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
'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;
};