-
-
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 all 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,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.
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!