-
-
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.
Merge pull request #6527 from plotly/shape-label-templates
Add `texttemplate` attribute to `shape.label`
- Loading branch information
Showing
11 changed files
with
585 additions
and
49 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
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
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,70 @@ | ||
'use strict'; | ||
|
||
// Wrapper functions to handle paper-referenced shapes, which have no axis | ||
|
||
function d2l(v, axis) { | ||
return axis ? axis.d2l(v) : v; | ||
} | ||
|
||
function l2d(v, axis) { | ||
return axis ? axis.l2d(v) : v; | ||
} | ||
|
||
|
||
function x0Fn(shape) { return shape.x0; } | ||
function x1Fn(shape) { return shape.x1; } | ||
function y0Fn(shape) { return shape.y0; } | ||
function y1Fn(shape) { return shape.y1; } | ||
|
||
function dxFn(shape, xa) { | ||
return d2l(shape.x1, xa) - d2l(shape.x0, xa); | ||
} | ||
|
||
function dyFn(shape, xa, ya) { | ||
return d2l(shape.y1, ya) - d2l(shape.y0, ya); | ||
} | ||
|
||
function widthFn(shape, xa) { | ||
return Math.abs(dxFn(shape, xa)); | ||
} | ||
|
||
function heightFn(shape, xa, ya) { | ||
return Math.abs(dyFn(shape, xa, ya)); | ||
} | ||
|
||
function lengthFn(shape, xa, ya) { | ||
return (shape.type !== 'line') ? undefined : | ||
Math.sqrt( | ||
Math.pow(dxFn(shape, xa), 2) + | ||
Math.pow(dyFn(shape, xa, ya), 2) | ||
); | ||
} | ||
|
||
function xcenterFn(shape, xa) { | ||
return l2d((d2l(shape.x1, xa) + d2l(shape.x0, xa)) / 2, xa); | ||
} | ||
|
||
function ycenterFn(shape, xa, ya) { | ||
return l2d((d2l(shape.y1, ya) + d2l(shape.y0, ya)) / 2, ya); | ||
} | ||
|
||
function slopeFn(shape, xa, ya) { | ||
return (shape.type !== 'line') ? undefined : ( | ||
dyFn(shape, xa, ya) / dxFn(shape, xa) | ||
); | ||
} | ||
|
||
module.exports = { | ||
x0: x0Fn, | ||
x1: x1Fn, | ||
y0: y0Fn, | ||
y1: y1Fn, | ||
slope: slopeFn, | ||
dx: dxFn, | ||
dy: dyFn, | ||
width: widthFn, | ||
height: heightFn, | ||
length: lengthFn, | ||
xcenter: xcenterFn, | ||
ycenter: ycenterFn, | ||
}; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.