This repository has been archived by the owner on Feb 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
Clean domain method #317
Merged
+129
−30
Merged
Clean domain method #317
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b001abf
fixed for main domain method and chart wrapper and axis
ebrillhart 5140bb5
working in ensureZero method for area charts but not bar charts
ebrillhart 42072f8
cleanDomain works for candlestick and errorbar
ebrillhart 2488341
Merge branch 'master' into clean-domain-method
ebrillhart ffae64b
refactoring
ebrillhart f2ef08e
refactor clean domain
ebrillhart 3182c68
fix a linting error
ebrillhart cdf349a
trying to track down the problem
ebrillhart 2623873
working log scales for charts with baselines
boygirl e96be9e
revert axis change
boygirl edab685
lint
boygirl 0fa36cf
fix merge conflicts
ebrillhart 877a772
commit changes to review during pairing session
ebrillhart 39d5c7f
more attempts at debugging
ebrillhart 9e9d094
remove debugging messages
ebrillhart afe87dc
remove more debug messages
ebrillhart 5bc24e3
fix merge issues
ebrillhart 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { flatten, includes, isPlainObject } from "lodash"; | ||
import Data from "./data"; | ||
import Axis from "./axis"; | ||
import Scale from "./scale"; | ||
import { Helpers, Collection } from "victory-core"; | ||
|
||
export default { | ||
|
@@ -15,7 +16,30 @@ export default { | |
} | ||
const dataset = Data.getData(props); | ||
const domain = this.getDomainFromData(props, axis, dataset); | ||
return this.padDomain(domain, props, axis); | ||
return this.cleanDomain(this.padDomain(domain, props, axis), props); | ||
}, | ||
|
||
cleanDomain(domain, props) { | ||
// Some scale types break when certain data is supplies. This method will | ||
// remove data points that break scales. So far this method only removes | ||
// zeroes for log scales | ||
// TODO other cases? | ||
const scaleType = { | ||
x: Scale.getScaleType(props, "x"), | ||
y: Scale.getScaleType(props, "y") | ||
}; | ||
|
||
if (scaleType.x !== "log" && scaleType.y !== "log") { | ||
return domain; | ||
} | ||
|
||
const rules = (dom, axis) => { | ||
const domainOne = dom[0] === 0 ? 1 / Number.MAX_SAFE_INTEGER : dom[0]; | ||
const domainTwo = dom[1] === 0 ? -Math.abs(1 / Number.MAX_SAFE_INTEGER) : dom[1]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Be careful with the logic around having one of these be negative and the other positive. The domain is not always |
||
return scaleType[axis] === "log" ? [domainOne, domainTwo] : dom; | ||
}; | ||
|
||
return rules(domain, "x") && rules(domain, "y"); | ||
}, | ||
|
||
getDomainWithZero(props, axis) { | ||
|
@@ -36,7 +60,7 @@ export default { | |
} | ||
const dataset = Data.getData(props); | ||
const domain = ensureZero(this.getDomainFromData(props, axis, dataset)); | ||
return this.padDomain(domain, props, axis); | ||
return this.cleanDomain(this.padDomain(domain, props, axis), props); | ||
}, | ||
|
||
getDomainFromProps(props, axis) { | ||
|
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
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.
I think you can simplify this method if you add an
axis
argument