@react-financial-charts/core
Advanced tools
Comparing version 1.0.0-alpha.13 to 1.0.0-alpha.14
@@ -6,2 +6,14 @@ # Change Log | ||
# [1.0.0-alpha.14](https://github.com/reactivemarkets/react-financial-charts/compare/v1.0.0-alpha.13...v1.0.0-alpha.14) (2020-09-02) | ||
### Bug Fixes | ||
* **core:** correcting xExtents type ([d3607fe](https://github.com/reactivemarkets/react-financial-charts/commit/d3607fedccda783badd2214b9d2ec27fa2faca31)) | ||
* **core:** correcting zoom anchor types ([052981a](https://github.com/reactivemarkets/react-financial-charts/commit/052981a9d7462c7c2e9bba4ae9486f1a1db14553)) | ||
# [1.0.0-alpha.13](https://github.com/reactivemarkets/react-financial-charts/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2020-09-01) | ||
@@ -8,0 +20,0 @@ |
@@ -56,6 +56,6 @@ import { ScaleContinuousNumeric, ScaleTime } from "d3-scale"; | ||
readonly xAccessor: (data: any) => TXAxis; | ||
readonly xExtents: ((data: any[]) => [TXAxis, TXAxis]) | (((datum: any) => TXAxis) | TXAxis)[]; | ||
readonly xExtents: ((data: any[]) => [TXAxis, TXAxis]) | (((data: any[]) => TXAxis) | TXAxis)[]; | ||
readonly xScale: ScaleContinuousNumeric<number, number> | ScaleTime<number, number>; | ||
readonly zIndex?: number; | ||
readonly zoomAnchor?: (options: IZoomAnchorOptions<any>) => TXAxis; | ||
readonly zoomAnchor?: (options: IZoomAnchorOptions<any, TXAxis>) => TXAxis; | ||
readonly zoomMultiplier?: number; | ||
@@ -96,3 +96,3 @@ } | ||
zIndex: number; | ||
zoomAnchor: <T>({ xScale, xAccessor, mouseXY, plotData }: IZoomAnchorOptions<T>) => number | Date; | ||
zoomAnchor: <TData, TXAxis_1 extends number | Date>(options: IZoomAnchorOptions<TData, TXAxis_1>) => TXAxis_1; | ||
zoomMultiplier: number; | ||
@@ -99,0 +99,0 @@ }; |
import { ScaleContinuousNumeric, ScaleTime } from "d3-scale"; | ||
export interface IZoomAnchorOptions<T> { | ||
readonly plotData: T[]; | ||
export interface IZoomAnchorOptions<TData, TXAxis extends number | Date> { | ||
readonly plotData: TData[]; | ||
readonly mouseXY: number[]; | ||
readonly xAccessor: (data: T) => number | Date; | ||
readonly xAccessor: (data: TData) => TXAxis; | ||
readonly xScale: ScaleContinuousNumeric<number, number> | ScaleTime<number, number>; | ||
} | ||
export declare const mouseBasedZoomAnchor: <T>({ xScale, xAccessor, mouseXY, plotData }: IZoomAnchorOptions<T>) => number | Date; | ||
export declare const lastVisibleItemBasedZoomAnchor: <T>({ xAccessor, plotData }: IZoomAnchorOptions<T>) => number | Date; | ||
export declare const rightDomainBasedZoomAnchor: <T>({ xScale }: IZoomAnchorOptions<T>) => number | Date; | ||
export declare const mouseBasedZoomAnchor: <TData, TXAxis extends number | Date>(options: IZoomAnchorOptions<TData, TXAxis>) => TXAxis; | ||
export declare const lastVisibleItemBasedZoomAnchor: <TData, TXAxis extends number | Date>(options: IZoomAnchorOptions<TData, TXAxis>) => TXAxis; | ||
export declare const rightDomainBasedZoomAnchor: <TData, TXAxis extends number | Date>(options: IZoomAnchorOptions<TData, TXAxis>) => number | Date; |
import { getCurrentItem } from "../utils/ChartDataUtil"; | ||
import { last } from "../utils/index"; | ||
export const mouseBasedZoomAnchor = ({ xScale, xAccessor, mouseXY, plotData }) => { | ||
export const mouseBasedZoomAnchor = (options) => { | ||
const { xScale, xAccessor, mouseXY, plotData } = options; | ||
const currentItem = getCurrentItem(xScale, xAccessor, mouseXY, plotData); | ||
return xAccessor(currentItem); | ||
}; | ||
export const lastVisibleItemBasedZoomAnchor = ({ xAccessor, plotData }) => { | ||
export const lastVisibleItemBasedZoomAnchor = (options) => { | ||
const { xAccessor, plotData } = options; | ||
const lastItem = last(plotData); | ||
return xAccessor(lastItem); | ||
}; | ||
export const rightDomainBasedZoomAnchor = ({ xScale }) => { | ||
export const rightDomainBasedZoomAnchor = (options) => { | ||
const { xScale } = options; | ||
const [, end] = xScale.domain(); | ||
@@ -13,0 +16,0 @@ return end; |
{ | ||
"name": "@react-financial-charts/core", | ||
"version": "1.0.0-alpha.13", | ||
"version": "1.0.0-alpha.14", | ||
"description": "Core code for react-financial-charts", | ||
@@ -53,3 +53,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "58441df036295c078f244f2bcdc42266afb4c42a" | ||
"gitHead": "3d5d01041abb8b11ae7528d0c08c6d984ff587a7" | ||
} |
@@ -5,10 +5,13 @@ import { ScaleContinuousNumeric, ScaleTime } from "d3-scale"; | ||
export interface IZoomAnchorOptions<T> { | ||
readonly plotData: T[]; | ||
export interface IZoomAnchorOptions<TData, TXAxis extends number | Date> { | ||
readonly plotData: TData[]; | ||
readonly mouseXY: number[]; | ||
readonly xAccessor: (data: T) => number | Date; | ||
readonly xAccessor: (data: TData) => TXAxis; | ||
readonly xScale: ScaleContinuousNumeric<number, number> | ScaleTime<number, number>; | ||
} | ||
export const mouseBasedZoomAnchor = <T>({ xScale, xAccessor, mouseXY, plotData }: IZoomAnchorOptions<T>) => { | ||
export const mouseBasedZoomAnchor = <TData, TXAxis extends number | Date>( | ||
options: IZoomAnchorOptions<TData, TXAxis>, | ||
) => { | ||
const { xScale, xAccessor, mouseXY, plotData } = options; | ||
const currentItem = getCurrentItem(xScale, xAccessor, mouseXY, plotData); | ||
@@ -18,3 +21,6 @@ return xAccessor(currentItem); | ||
export const lastVisibleItemBasedZoomAnchor = <T>({ xAccessor, plotData }: IZoomAnchorOptions<T>) => { | ||
export const lastVisibleItemBasedZoomAnchor = <TData, TXAxis extends number | Date>( | ||
options: IZoomAnchorOptions<TData, TXAxis>, | ||
) => { | ||
const { xAccessor, plotData } = options; | ||
const lastItem = last(plotData); | ||
@@ -24,5 +30,8 @@ return xAccessor(lastItem); | ||
export const rightDomainBasedZoomAnchor = <T>({ xScale }: IZoomAnchorOptions<T>) => { | ||
export const rightDomainBasedZoomAnchor = <TData, TXAxis extends number | Date>( | ||
options: IZoomAnchorOptions<TData, TXAxis>, | ||
) => { | ||
const { xScale } = options; | ||
const [, end] = xScale.domain(); | ||
return end; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
425276
7830