mirror of
https://github.com/klinecharts/KLineChart.git
synced 2024-11-25 16:22:43 +08:00
impr: merge ts type
This commit is contained in:
parent
7d3390cea0
commit
e203b858a9
@ -15,7 +15,7 @@
|
||||
import type Nullable from './common/Nullable'
|
||||
import type DeepPartial from './common/DeepPartial'
|
||||
import type Bounding from './common/Bounding'
|
||||
import type KLineData from './common/KLineData'
|
||||
import { type KLineData } from './common/Data'
|
||||
import type Coordinate from './common/Coordinate'
|
||||
import type Point from './common/Point'
|
||||
import { UpdateLevel } from './common/Updater'
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import type DeepPartial from './common/DeepPartial'
|
||||
import { type Styles } from './common/Styles'
|
||||
import { formatDate, formatBigNumber } from './common/utils/format'
|
||||
import { formatDateToString, formatBigNumber } from './common/utils/format'
|
||||
|
||||
import { type IndicatorCreate } from './component/Indicator'
|
||||
import { type PaneOptions } from './pane/types'
|
||||
@ -36,7 +36,7 @@ export interface CustomApi {
|
||||
|
||||
export function getDefaultCustomApi (): CustomApi {
|
||||
return {
|
||||
formatDate,
|
||||
formatDate: formatDateToString,
|
||||
formatBigNumber
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type Coordinate from './Coordinate'
|
||||
import type KLineData from './KLineData'
|
||||
import { type KLineData } from './Data'
|
||||
|
||||
export default interface Crosshair extends Partial<Coordinate> {
|
||||
paneId?: string
|
||||
|
@ -12,7 +12,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default interface KLineData {
|
||||
import type Nullable from './Nullable'
|
||||
import { type DateTime } from './utils/format'
|
||||
|
||||
export interface KLineData {
|
||||
timestamp: number
|
||||
open: number
|
||||
high: number
|
||||
@ -22,3 +25,16 @@ export default interface KLineData {
|
||||
turnover?: number
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface VisibleData {
|
||||
dataIndex: number
|
||||
x: number
|
||||
data: Nullable<KLineData>
|
||||
}
|
||||
|
||||
export interface TimeWeightData {
|
||||
weight: number
|
||||
dataIndex: number
|
||||
dateTime: DateTime
|
||||
data: KLineData
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type Nullable from './Nullable'
|
||||
import type KLineData from './KLineData'
|
||||
import { type KLineData } from './Data'
|
||||
|
||||
enum LoadDataType {
|
||||
Init = 'init',
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type Nullable from './Nullable'
|
||||
import type KLineData from './KLineData'
|
||||
import { type KLineData } from './Data'
|
||||
|
||||
export interface Margin {
|
||||
marginLeft: number
|
||||
|
@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type Nullable from './Nullable'
|
||||
import type KLineData from './KLineData'
|
||||
|
||||
export default interface VisibleData {
|
||||
dataIndex: number
|
||||
x: number
|
||||
data: Nullable<KLineData>
|
||||
}
|
@ -14,6 +14,15 @@
|
||||
|
||||
import { isNumber, isValid } from './typeChecks'
|
||||
|
||||
export interface DateTime {
|
||||
year: string
|
||||
month: string
|
||||
day: string
|
||||
hour: string
|
||||
minute: string
|
||||
second: string
|
||||
}
|
||||
|
||||
const reEscapeChar = /\\(\\)?/g
|
||||
const rePropName = RegExp(
|
||||
'[^.[\\]]+' + '|' +
|
||||
@ -48,7 +57,7 @@ export function formatValue (data: unknown, key: string, defaultValue?: unknown)
|
||||
return defaultValue ?? '--'
|
||||
}
|
||||
|
||||
export function formatDate (dateTimeFormat: Intl.DateTimeFormat, timestamp: number, format: string): string {
|
||||
export function formatDateToDateTime (dateTimeFormat: Intl.DateTimeFormat, timestamp: number): DateTime {
|
||||
const date: Record<string, string> = {}
|
||||
dateTimeFormat.formatToParts(new Date(timestamp)).forEach(({ type, value }) => {
|
||||
switch (type) {
|
||||
@ -78,6 +87,11 @@ export function formatDate (dateTimeFormat: Intl.DateTimeFormat, timestamp: numb
|
||||
}
|
||||
}
|
||||
})
|
||||
return date as unknown as DateTime
|
||||
}
|
||||
|
||||
export function formatDateToString (dateTimeFormat: Intl.DateTimeFormat, timestamp: number, format: string): string {
|
||||
const date = formatDateToDateTime(dateTimeFormat, timestamp)
|
||||
return format.replace(/YYYY|MM|DD|HH|mm|ss/g, key => date[key])
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import type Nullable from '../common/Nullable'
|
||||
import type ExcludePickPartial from '../common/ExcludePickPartial'
|
||||
import type KLineData from '../common/KLineData'
|
||||
import { type KLineData } from '../common/Data'
|
||||
import type Bounding from '../common/Bounding'
|
||||
import type VisibleRange from '../common/VisibleRange'
|
||||
import type BarSpace from '../common/BarSpace'
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type IndicatorTemplate, IndicatorSeries } from '../../component/Indicator'
|
||||
|
||||
interface Avp {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type IndicatorStyle, PolygonType } from '../../common/Styles'
|
||||
import { formatValue } from '../../common/utils/format'
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Bias {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate, IndicatorSeries } from '../../component/Indicator'
|
||||
|
||||
interface Boll {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Brar {
|
||||
|
@ -11,7 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate, IndicatorSeries } from '../../component/Indicator'
|
||||
|
||||
interface Bbi {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Cci {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Cr {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Dma {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Dmi {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Emv {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate, IndicatorSeries } from '../../component/Indicator'
|
||||
|
||||
interface Ema {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Mtm {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate, IndicatorSeries } from '../../component/Indicator'
|
||||
|
||||
interface Ma {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type IndicatorStyle, PolygonType } from '../../common/Styles'
|
||||
|
||||
import { formatValue } from '../../common/utils/format'
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Obv {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Pvt {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Psy {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Roc {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Rsi {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate, IndicatorSeries } from '../../component/Indicator'
|
||||
|
||||
interface Sma {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
import { getMaxMin } from '../../common/utils/number'
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type IndicatorStyle } from '../../common/Styles'
|
||||
import { formatValue } from '../../common/utils/format'
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Trix {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type IndicatorStyle } from '../../common/Styles'
|
||||
import { formatValue } from '../../common/utils/format'
|
||||
import { isValid } from '../../common/utils/typeChecks'
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
interface Vr {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type KLineData from '../../common/KLineData'
|
||||
import { type KLineData } from '../../common/Data'
|
||||
import { type Indicator, type IndicatorTemplate } from '../../component/Indicator'
|
||||
|
||||
import { getMaxMin } from '../../common/utils/number'
|
||||
|
@ -35,7 +35,7 @@ import { logError, logTag, logWarn } from './common/utils/logger'
|
||||
import {
|
||||
clone, merge, isString, isNumber, isValid, isObject, isArray, isFunction, isBoolean
|
||||
} from './common/utils/typeChecks'
|
||||
import { formatValue, formatPrecision, formatBigNumber, formatDate, formatThousands, formatFoldDecimal } from './common/utils/format'
|
||||
import { formatValue, formatPrecision, formatBigNumber, formatDateToString, formatThousands, formatFoldDecimal } from './common/utils/format'
|
||||
import { calcTextWidth } from './common/utils/canvas'
|
||||
import { ActionType } from './common/Action'
|
||||
import { IndicatorSeries } from './component/Indicator'
|
||||
@ -141,7 +141,7 @@ const utils = {
|
||||
formatValue,
|
||||
formatPrecision,
|
||||
formatBigNumber,
|
||||
formatDate,
|
||||
formatDate: formatDateToString,
|
||||
formatThousands,
|
||||
formatFoldDecimal,
|
||||
calcTextWidth,
|
||||
|
@ -13,9 +13,8 @@
|
||||
*/
|
||||
|
||||
import type Nullable from '../common/Nullable'
|
||||
import type KLineData from '../common/KLineData'
|
||||
import { type KLineData, type VisibleData } from '../common/Data'
|
||||
import type Precision from '../common/Precision'
|
||||
import type VisibleData from '../common/VisibleData'
|
||||
import type DeepPartial from '../common/DeepPartial'
|
||||
import { getDefaultStyles, type Styles, type TooltipLegend } from '../common/Styles'
|
||||
import { isArray, isNumber, isString, isValid, merge } from '../common/utils/typeChecks'
|
||||
@ -133,6 +132,8 @@ export default class ChartStore {
|
||||
*/
|
||||
private _visibleDataList: VisibleData[] = []
|
||||
|
||||
// private _dataMap = new Map<number, TimeClassifyData[]>()
|
||||
|
||||
constructor (chart: Chart, options?: Options) {
|
||||
this._chart = chart
|
||||
this.setOptions(options)
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import type Nullable from '../common/Nullable'
|
||||
import type Coordinate from '../common/Coordinate'
|
||||
import type KLineData from '../common/KLineData'
|
||||
import { type KLineData } from '../common/Data'
|
||||
import type BarSpace from '../common/BarSpace'
|
||||
import type VisibleRange from '../common/VisibleRange'
|
||||
import { getDefaultVisibleRange } from '../common/VisibleRange'
|
||||
@ -27,6 +27,13 @@ import { isNumber, isString } from '../common/utils/typeChecks'
|
||||
import type ChartStore from './ChartStore'
|
||||
import { LoadDataType } from '../common/LoadDataCallback'
|
||||
|
||||
export interface TimeCategoryDataMapValue {
|
||||
category: number
|
||||
dataIndex: number
|
||||
timestamp: number
|
||||
data: KLineData
|
||||
}
|
||||
|
||||
interface LeftRightSide {
|
||||
left: number
|
||||
right: number
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type Nullable from '../common/Nullable'
|
||||
import type KLineData from '../common/KLineData'
|
||||
import { type KLineData } from '../common/Data'
|
||||
import type Crosshair from '../common/Crosshair'
|
||||
import { UpdateLevel } from '../common/Updater'
|
||||
import { isNumber } from '../common/utils/typeChecks'
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type Coordinate from '../common/Coordinate'
|
||||
import type VisibleData from '../common/VisibleData'
|
||||
import { type VisibleData } from '../common/Data'
|
||||
import { type GradientColor } from '../common/Styles'
|
||||
import Animation from '../common/Animation'
|
||||
import { isNumber, isArray, isValid } from '../common/utils/typeChecks'
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type Nullable from '../common/Nullable'
|
||||
import type VisibleData from '../common/VisibleData'
|
||||
import { type VisibleData } from '../common/Data'
|
||||
import type BarSpace from '../common/BarSpace'
|
||||
import { type EventHandler } from '../common/SyntheticEvent'
|
||||
import { ActionType } from '../common/Action'
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type Coordinate from '../common/Coordinate'
|
||||
import type VisibleData from '../common/VisibleData'
|
||||
import { type VisibleData } from '../common/Data'
|
||||
import { type CandleHighLowPriceMarkStyle } from '../common/Styles'
|
||||
|
||||
import ChildrenView from './ChildrenView'
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import type Nullable from '../common/Nullable'
|
||||
import type Bounding from '../common/Bounding'
|
||||
import type KLineData from '../common/KLineData'
|
||||
import { type KLineData } from '../common/Data'
|
||||
import type Precision from '../common/Precision'
|
||||
import type Crosshair from '../common/Crosshair'
|
||||
import {
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import View from './View'
|
||||
import type VisibleData from '../common/VisibleData'
|
||||
import { type VisibleData } from '../common/Data'
|
||||
import type BarSpace from '../common/BarSpace'
|
||||
import type YAxis from '../component/YAxis'
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type Nullable from '../common/Nullable'
|
||||
import type KLineData from '../common/KLineData'
|
||||
import { type KLineData } from '../common/Data'
|
||||
import type Crosshair from '../common/Crosshair'
|
||||
import { type IndicatorStyle, type TooltipStyle, type TooltipIconStyle, type TooltipTextStyle, type TooltipLegend, TooltipShowRule, type TooltipLegendChild, TooltipIconPosition } from '../common/Styles'
|
||||
import { ActionType } from '../common/Action'
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type Nullable from '../common/Nullable'
|
||||
import type VisibleData from '../common/VisibleData'
|
||||
import { type VisibleData } from '../common/Data'
|
||||
import type BarSpace from '../common/BarSpace'
|
||||
import { CandleType, type SmoothLineStyle } from '../common/Styles'
|
||||
import { formatValue } from '../common/utils/format'
|
||||
|
Loading…
Reference in New Issue
Block a user