@@ -99,7 +99,7 @@ export interface IndicatorDrawParams<D, C, E> {
9999
100100export type IndicatorDrawCallback < D , C , E > = ( params : IndicatorDrawParams < D , C , E > ) => boolean
101101
102- export type IndicatorCalcCallback < D , C , E > = ( dataList : KLineData [ ] , indicator : Indicator < D , C , E > ) => Promise < D [ ] > | D [ ]
102+ export type IndicatorCalcCallback < D , C , E > = ( dataList : KLineData [ ] , indicator : Indicator < D , C , E > ) => Promise < Record < number , D > > | Record < number , D >
103103
104104export type IndicatorShouldUpdateCallback < D , C , E > = ( prev : Indicator < D , C , E > , current : Indicator < D , C , E > ) => ( boolean | { calc : boolean , draw : boolean } )
105105
@@ -227,7 +227,7 @@ export interface Indicator<D = unknown, C = unknown, E = unknown> {
227227 /**
228228 * Calculation result
229229 */
230- result : D [ ]
230+ result : Record < number , D >
231231}
232232
233233export type IndicatorTemplate < D = unknown , C = unknown , E = unknown > = ExcludePickPartial < Omit < Indicator < D , C , E > , 'result' | 'paneId' > , 'name' | 'calc' >
@@ -244,7 +244,7 @@ export type EachFigureCallback<D> = (figure: IndicatorFigure<D>, figureStyles: I
244244
245245export function eachFigures < D = unknown > (
246246 indicator : Indicator ,
247- dataIndex : number ,
247+ timestamps : NeighborData < Nullable < number > > ,
248248 defaultStyles : IndicatorStyle ,
249249 eachFigureCallback : EachFigureCallback < D >
250250) : void {
@@ -295,9 +295,9 @@ export function eachFigures<D = unknown> (
295295 if ( isValid ( figure . type ) ) {
296296 const ss = figure . styles ?.( {
297297 data : {
298- prev : result [ dataIndex - 1 ] ,
299- current : result [ dataIndex ] ,
300- next : result [ dataIndex + 1 ]
298+ prev : result [ timestamps . prev ?? '' ] ,
299+ current : result [ timestamps . current ?? '' ] ,
300+ next : result [ timestamps . next ?? '' ]
301301 } ,
302302 indicator,
303303 defaultStyles
@@ -347,14 +347,14 @@ export default class IndicatorImp<D = unknown, C = unknown, E = unknown> impleme
347347 return { calc, draw }
348348 }
349349
350- calc : IndicatorCalcCallback < D , C , E > = ( ) => [ ]
350+ calc : IndicatorCalcCallback < D , C , E > = ( ) => ( { } )
351351 regenerateFigures : Nullable < IndicatorRegenerateFiguresCallback < D , C > > = null
352352 createTooltipDataSource : Nullable < IndicatorCreateTooltipDataSourceCallback < D > > = null
353353 draw : Nullable < IndicatorDrawCallback < D , C , E > > = null
354354
355355 onDataStateChange : Nullable < IndicatorOnDataStateChangeCallback < D > > = null
356356
357- result : D [ ] = [ ]
357+ result : Record < number , D > = { }
358358
359359 private _prevIndicator : Indicator < D , C , E >
360360 private _lockSeriesPrecision = false
0 commit comments