-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat(core): axisMeasure #259
base: master
Are you sure you want to change the base?
Conversation
break; | ||
case "center": | ||
// @ts-ignore | ||
coordCenter = scale.invert(0.5); |
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.
Same comment as for line 118
Awesome! Seems to work and looks pretty good! I added some comments.
Instead of precalculating stuff, you could calculate the rule length on the fly. E.g., take |
* | ||
* __Default value:__ `1` | ||
*/ | ||
multiplierValue?: number; |
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.
Hmm. I'm not sure about this. What if someone would like to have 1, 5, 10, 50, 100, 50, etc? No need to implement it now, but how would multiplierValue
work with that?
I would be careful when adding nice-to-have options, as they may become a nuisance later on.
*/ | ||
export default class AxisMeasureSource extends SingleAxisLazySource { | ||
/** @type {number} */ | ||
startPos = 0; |
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.
These could be class-private variables (i.e., start with #).
On the other hand, you could have just a single variable that stores the object that you might publish when the domain changes. However, when propagating new data objects, it's best to always create a new object, not mutate an existing one.
/** @type {number} */ | ||
centerPos = 0; | ||
/** @type {string} */ | ||
measureLabel = ""; |
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.
Local to onDomainChanged()
. Shouldn't be here.
/** @type {string} */ | ||
measureLabel = ""; | ||
/** @type {number} */ | ||
measureDomainSize = 1; |
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.
Same here and in the following few variables.
this.publishData([ | ||
[ | ||
{ | ||
startPos: startPos, |
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.
When the property and variable names are the same, you can make it more succinct:
{
startPos,
endPos,
centerPos,
...
}
Implemented an axisMeasure lazy datasource which can be used to create a visual clue to the level of zoom, publishing the
startPos
,endPos
,centerPos
,measureDomainSize
,measurePixelSize
andmeasureLabel
fields at each scale domain change.Its behavior can be changed by several parameters:
minMeasureSize
,hideMeasureThreshold
,multiplierValue
andalignMeasure
.The parameters and fields usage is shown in two examples in
packages/core/example/axes
and they are also documented in thelazy.md
part of the documentation.The range of measureValues and measureLabels is determined by querying
genome.totalSize
, so this feature works only on genomeAxes (to make it more general, the scale#zoomExtent
might need to be made available for simple Axes).