forked from react-financial/react-financial-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixing scaling when data is discontinuous
Chart will correctly allowing panning when there's missing data. Moved timeFormat to scales to be used with other scales.
- Loading branch information
1 parent
afe3ba9
commit 4b20255
Showing
10 changed files
with
81 additions
and
96 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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { ScaleContinuousNumeric } from "d3-scale"; | ||
import { ScaleContinuousNumeric, ScaleTime } from "d3-scale"; | ||
export { | ||
default as discontinuousTimeScaleProvider, | ||
discontinuousTimeScaleProviderBuilder, | ||
} from "./discontinuousTimeScaleProvider"; | ||
export { default as financeDiscontinuousScale } from "./financeDiscontinuousScale"; | ||
export * from "./timeFormat"; | ||
|
||
export const defaultScaleProvider = (xScale: ScaleContinuousNumeric<number, number>) => { | ||
return (data: any, xAccessor: any) => ({ data, xScale, xAccessor, displayXAccessor: xAccessor }); | ||
export const defaultScaleProvider = (xScale: ScaleContinuousNumeric<number, number> | ScaleTime<number, number>) => { | ||
return (data: any[], xAccessor: any) => ({ data, xScale, xAccessor, displayXAccessor: xAccessor }); | ||
}; |
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,29 @@ | ||
import { timeSecond, timeMinute, timeHour, timeDay, timeWeek, timeMonth, timeYear } from "d3-time"; | ||
import { timeFormat as d3TimeFormat } from "d3-time-format"; | ||
|
||
const formatMillisecond = d3TimeFormat(".%L"); | ||
const formatSecond = d3TimeFormat(":%S"); | ||
const formatMinute = d3TimeFormat("%H:%M"); | ||
const formatHour = d3TimeFormat("%H:%M"); | ||
const formatDay = d3TimeFormat("%e"); | ||
const formatWeek = d3TimeFormat("%e"); | ||
const formatMonth = d3TimeFormat("%b"); | ||
const formatYear = d3TimeFormat("%Y"); | ||
|
||
export const timeFormat = (date: Date) => { | ||
return (timeSecond(date) < date | ||
? formatMillisecond | ||
: timeMinute(date) < date | ||
? formatSecond | ||
: timeHour(date) < date | ||
? formatMinute | ||
: timeDay(date) < date | ||
? formatHour | ||
: timeMonth(date) < date | ||
? timeWeek(date) < date | ||
? formatDay | ||
: formatWeek | ||
: timeYear(date) < date | ||
? formatMonth | ||
: formatYear)(date); | ||
}; |
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