-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add texttemplate
attribute to shape.label
#6527
Merged
Merged
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
7071ff9
support shape.label.texttemplate attribute
emilykl b153b2d
add mock
emilykl 0fb52cd
add label.texttemplate to draw_newshape
emilykl a5b9aa8
update plot-schema
emilykl ead380a
rename some functions/variables, add comments, improve docstrings
emilykl eaf1927
add baseline for new mock
emilykl 9575eb3
update some editTypes, fix drag behavior
emilykl 10550bb
update plot-schema
emilykl 5f54668
add additional shape label template vars, exclude paths
emilykl 0b2bb2a
handle datetimes and log axes, small refactor, fix docstrings
emilykl 657ec2e
improved mock for shape label text templates
emilykl 91ceff2
update mocks, fix attr bug
emilykl ad4841f
improve docstring
emilykl b7eeb59
update plot-schema
emilykl 9276af4
update plot-schema
emilykl 48e273e
simplify exports/imports for shapeLabelTexttemplateVars
emilykl efea57b
small cleanup
emilykl 8eb9cf7
revise label_texttemplate to handle log
archmoj 4a3a7ae
small cleanup, disable slope variable for non-lines
emilykl c619433
small adjustment to mock
emilykl ba780f9
update image baseline
emilykl e1ac9d7
improved coerce behavior
emilykl e6f76d5
fix texttemplate behavior for log axes and simplify
emilykl a9a559e
add category axis to mock
emilykl b82896a
handle paper-referenced shapes
emilykl 970943b
update image baseline
emilykl 66a12de
fix mock
emilykl 3b32d8d
update image baseline
emilykl 0163281
simplify parsing logic
emilykl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,82 @@ | ||
'use strict'; | ||
|
||
function d2l(v, axis) { | ||
return ( | ||
axis.type === 'log' ? v : | ||
axis.d2l(v) | ||
); | ||
} | ||
|
||
function getPos(x, xa) { | ||
return ( | ||
xa.type === 'date' ? x : | ||
d2l(x, xa) | ||
); | ||
} | ||
|
||
function x0Fn(shape, xa) { return getPos(shape.x0, xa); } | ||
function x1Fn(shape, xa) { return getPos(shape.x1, xa); } | ||
function y0Fn(shape, xa, ya) { return getPos(shape.y0, ya); } | ||
function y1Fn(shape, xa, ya) { return getPos(shape.y1, ya); } | ||
|
||
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((d2l(shape.x1, xa) - d2l(shape.x0, xa)), 2) + | ||
Math.pow((d2l(shape.y1, ya) - d2l(shape.y0, ya)), 2) | ||
); | ||
} | ||
|
||
function xcenterFn(shape, xa) { | ||
var val = (d2l(shape.x1, xa) + d2l(shape.x0, xa)) / 2; | ||
return (xa.type === 'date') ? xa.l2d(val) : val; | ||
} | ||
|
||
function ycenterFn(shape, xa, ya) { | ||
var val = (d2l(shape.y1, ya) + d2l(shape.y0, ya)) / 2; | ||
return (ya.type === 'date') ? ya.l2d(val) : val; | ||
} | ||
|
||
function slopeFn(shape, xa, ya) { | ||
return (shape.type !== 'line') ? undefined : ( | ||
(d2l(shape.y1, ya) - d2l(shape.y0, ya)) / | ||
(d2l(shape.x1, xa) - d2l(shape.x0, xa)) | ||
emilykl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
} | ||
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let
defaults
do the overriding - ie don't coercetext
if there's atexttemplate
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and even better - don't try to coerce
texttemplate
iftype==='path'
- then you don't need theif(options.type !== 'path')
below :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see the comment below about new shapes - you may be right that the
if
below is still needed, but it'll still be better if we only coerce what's needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcjohnson Changed the coercion in
defaults.js
but I believe we still need theif(texttemplate)
statement (see updated code) -- correct me if wrong!