mirror of
https://github.com/klinecharts/KLineChart.git
synced 2024-11-25 16:22:43 +08:00
impr: some custom callbacks add chart instance
This commit is contained in:
parent
9a4bba1176
commit
4b0b05c878
@ -47,6 +47,7 @@ import { type PaneOptions, PANE_DEFAULT_HEIGHT, PaneIdConstants, PaneState, PANE
|
|||||||
|
|
||||||
import type AxisImp from './component/Axis'
|
import type AxisImp from './component/Axis'
|
||||||
import { AxisPosition } from './component/Axis'
|
import { AxisPosition } from './component/Axis'
|
||||||
|
import type { YAxis } from './component/YAxis'
|
||||||
|
|
||||||
import type { IndicatorFilter, Indicator, IndicatorCreate } from './component/Indicator'
|
import type { IndicatorFilter, Indicator, IndicatorCreate } from './component/Indicator'
|
||||||
import type { OverlayFilter, Overlay, OverlayCreate } from './component/Overlay'
|
import type { OverlayFilter, Overlay, OverlayCreate } from './component/Overlay'
|
||||||
@ -54,7 +55,6 @@ import type { OverlayFilter, Overlay, OverlayCreate } from './component/Overlay'
|
|||||||
import { getIndicatorClass } from './extension/indicator/index'
|
import { getIndicatorClass } from './extension/indicator/index'
|
||||||
|
|
||||||
import Event from './Event'
|
import Event from './Event'
|
||||||
import type { YAxis } from './component/YAxis'
|
|
||||||
|
|
||||||
export enum DomPosition {
|
export enum DomPosition {
|
||||||
Root = 'root',
|
Root = 'root',
|
||||||
|
14
src/Store.ts
14
src/Store.ts
@ -1263,7 +1263,7 @@ export default class Store {
|
|||||||
this._overlays.get(paneId)?.push(overlay)
|
this._overlays.get(paneId)?.push(overlay)
|
||||||
}
|
}
|
||||||
if (overlay.isStart()) {
|
if (overlay.isStart()) {
|
||||||
overlay.onDrawStart?.(({ overlay }))
|
overlay.onDrawStart?.(({ overlay, chart: this._chart }))
|
||||||
}
|
}
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
@ -1345,7 +1345,7 @@ export default class Store {
|
|||||||
filterMap.forEach((overlays, paneId) => {
|
filterMap.forEach((overlays, paneId) => {
|
||||||
const paneOverlays = this.getOverlaysByPaneId(paneId)
|
const paneOverlays = this.getOverlaysByPaneId(paneId)
|
||||||
overlays.forEach(overlay => {
|
overlays.forEach(overlay => {
|
||||||
overlay.onRemoved?.({ overlay })
|
overlay.onRemoved?.({ overlay, chart: this._chart })
|
||||||
if (!updatePaneIds.includes(paneId)) {
|
if (!updatePaneIds.includes(paneId)) {
|
||||||
updatePaneIds.push(paneId)
|
updatePaneIds.push(paneId)
|
||||||
}
|
}
|
||||||
@ -1393,7 +1393,7 @@ export default class Store {
|
|||||||
if (overlay !== null) {
|
if (overlay !== null) {
|
||||||
sortFlag = true
|
sortFlag = true
|
||||||
if (isFunction(overlay.onMouseLeave)) {
|
if (isFunction(overlay.onMouseLeave)) {
|
||||||
overlay.onMouseLeave({ overlay, figureKey, figureIndex, ...event })
|
overlay.onMouseLeave({ chart: this._chart, overlay, figureKey, figureIndex, ...event })
|
||||||
ignoreUpdateFlag = true
|
ignoreUpdateFlag = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1401,7 +1401,7 @@ export default class Store {
|
|||||||
if (infoOverlay !== null) {
|
if (infoOverlay !== null) {
|
||||||
sortFlag = true
|
sortFlag = true
|
||||||
if (isFunction(infoOverlay.onMouseEnter)) {
|
if (isFunction(infoOverlay.onMouseEnter)) {
|
||||||
infoOverlay.onMouseEnter({ overlay: infoOverlay, figureKey: info.figureKey, figureIndex: info.figureIndex, ...event })
|
infoOverlay.onMouseEnter({ chart: this._chart, overlay: infoOverlay, figureKey: info.figureKey, figureIndex: info.figureIndex, ...event })
|
||||||
ignoreUpdateFlag = true
|
ignoreUpdateFlag = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1423,13 +1423,13 @@ export default class Store {
|
|||||||
const { paneId, overlay, figureType, figureKey, figureIndex } = this._clickOverlayInfo
|
const { paneId, overlay, figureType, figureKey, figureIndex } = this._clickOverlayInfo
|
||||||
const infoOverlay = info.overlay
|
const infoOverlay = info.overlay
|
||||||
if (!(infoOverlay?.isDrawing() ?? false)) {
|
if (!(infoOverlay?.isDrawing() ?? false)) {
|
||||||
infoOverlay?.onClick?.({ overlay: infoOverlay, figureKey: info.figureKey, figureIndex: info.figureIndex, ...event })
|
infoOverlay?.onClick?.({ chart: this._chart, overlay: infoOverlay, figureKey: info.figureKey, figureIndex: info.figureIndex, ...event })
|
||||||
}
|
}
|
||||||
if (overlay?.id !== infoOverlay?.id || figureType !== info.figureType || figureIndex !== info.figureIndex) {
|
if (overlay?.id !== infoOverlay?.id || figureType !== info.figureType || figureIndex !== info.figureIndex) {
|
||||||
this._clickOverlayInfo = info
|
this._clickOverlayInfo = info
|
||||||
if (overlay?.id !== infoOverlay?.id) {
|
if (overlay?.id !== infoOverlay?.id) {
|
||||||
overlay?.onDeselected?.({ overlay, figureKey, figureIndex, ...event })
|
overlay?.onDeselected?.({ chart: this._chart, overlay, figureKey, figureIndex, ...event })
|
||||||
infoOverlay?.onSelected?.({ overlay: infoOverlay, figureKey: info.figureKey, figureIndex: info.figureIndex, ...event })
|
infoOverlay?.onSelected?.({ chart: this._chart, overlay: infoOverlay, figureKey: info.figureKey, figureIndex: info.figureIndex, ...event })
|
||||||
this._chart.updatePane(UpdateLevel.Overlay, info.paneId)
|
this._chart.updatePane(UpdateLevel.Overlay, info.paneId)
|
||||||
if (paneId !== info.paneId) {
|
if (paneId !== info.paneId) {
|
||||||
this._chart.updatePane(UpdateLevel.Overlay, paneId)
|
this._chart.updatePane(UpdateLevel.Overlay, paneId)
|
||||||
|
@ -17,8 +17,7 @@ import type VisibleRange from '../common/VisibleRange'
|
|||||||
import type DrawPane from '../pane/DrawPane'
|
import type DrawPane from '../pane/DrawPane'
|
||||||
|
|
||||||
import type Bounding from '../common/Bounding'
|
import type Bounding from '../common/Bounding'
|
||||||
import type { KLineData } from '../common/Data'
|
import type { Chart } from '../Chart'
|
||||||
import type { Indicator } from './Indicator'
|
|
||||||
|
|
||||||
export interface AxisTick {
|
export interface AxisTick {
|
||||||
coord: number
|
coord: number
|
||||||
@ -51,10 +50,8 @@ export interface AxisValueToValueParams {
|
|||||||
export type AxisValueToValueCallback = (value: number, params: AxisValueToValueParams) => number
|
export type AxisValueToValueCallback = (value: number, params: AxisValueToValueParams) => number
|
||||||
|
|
||||||
export interface AxisCreateRangeParams {
|
export interface AxisCreateRangeParams {
|
||||||
|
chart: Chart
|
||||||
paneId: string
|
paneId: string
|
||||||
kLineDataList: KLineData[]
|
|
||||||
indicators: Indicator[]
|
|
||||||
dataVisibleRange: VisibleRange
|
|
||||||
defaultRange: AxisRange
|
defaultRange: AxisRange
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import type Nullable from '../common/Nullable'
|
|||||||
import type ExcludePickPartial from '../common/ExcludePickPartial'
|
import type ExcludePickPartial from '../common/ExcludePickPartial'
|
||||||
import type { KLineData } from '../common/Data'
|
import type { KLineData } from '../common/Data'
|
||||||
import type Bounding from '../common/Bounding'
|
import type Bounding from '../common/Bounding'
|
||||||
import type VisibleRange from '../common/VisibleRange'
|
|
||||||
import type BarSpace from '../common/BarSpace'
|
import type BarSpace from '../common/BarSpace'
|
||||||
import type Crosshair from '../common/Crosshair'
|
import type Crosshair from '../common/Crosshair'
|
||||||
import type { IndicatorStyle, IndicatorPolygonStyle, SmoothLineStyle, RectStyle, TextStyle, TooltipIconStyle, LineStyle, LineType, TooltipLegend } from '../common/Styles'
|
import type { IndicatorStyle, IndicatorPolygonStyle, SmoothLineStyle, RectStyle, TextStyle, TooltipIconStyle, LineStyle, LineType, TooltipLegend } from '../common/Styles'
|
||||||
@ -31,6 +30,7 @@ import type { ArcAttrs } from '../extension/figure/arc'
|
|||||||
import type { RectAttrs } from '../extension/figure/rect'
|
import type { RectAttrs } from '../extension/figure/rect'
|
||||||
import type { TextAttrs } from '../extension/figure/text'
|
import type { TextAttrs } from '../extension/figure/text'
|
||||||
import type { LoadDataType } from '../common/LoadDataCallback'
|
import type { LoadDataType } from '../common/LoadDataCallback'
|
||||||
|
import type { Chart } from '../Chart'
|
||||||
|
|
||||||
export enum IndicatorSeries {
|
export enum IndicatorSeries {
|
||||||
Normal = 'normal',
|
Normal = 'normal',
|
||||||
@ -90,12 +90,10 @@ export interface IndicatorTooltipData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IndicatorCreateTooltipDataSourceParams<D> {
|
export interface IndicatorCreateTooltipDataSourceParams<D> {
|
||||||
kLineDataList: KLineData[]
|
chart: Chart
|
||||||
indicator: Indicator<D>
|
indicator: Indicator<D>
|
||||||
visibleRange: VisibleRange
|
|
||||||
bounding: Bounding
|
bounding: Bounding
|
||||||
crosshair: Crosshair
|
crosshair: Crosshair
|
||||||
defaultStyles: IndicatorStyle
|
|
||||||
xAxis: XAxis
|
xAxis: XAxis
|
||||||
yAxis: YAxis
|
yAxis: YAxis
|
||||||
}
|
}
|
||||||
@ -104,12 +102,9 @@ export type IndicatorCreateTooltipDataSourceCallback<D> = (params: IndicatorCrea
|
|||||||
|
|
||||||
export interface IndicatorDrawParams<D> {
|
export interface IndicatorDrawParams<D> {
|
||||||
ctx: CanvasRenderingContext2D
|
ctx: CanvasRenderingContext2D
|
||||||
kLineDataList: KLineData[]
|
chart: Chart
|
||||||
indicator: Indicator<D>
|
indicator: Indicator<D>
|
||||||
visibleRange: VisibleRange
|
|
||||||
bounding: Bounding
|
bounding: Bounding
|
||||||
barSpace: BarSpace
|
|
||||||
defaultStyles: IndicatorStyle
|
|
||||||
xAxis: XAxis
|
xAxis: XAxis
|
||||||
yAxis: YAxis
|
yAxis: YAxis
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,6 @@ import type ExcludePickPartial from '../common/ExcludePickPartial'
|
|||||||
import type Point from '../common/Point'
|
import type Point from '../common/Point'
|
||||||
import type Coordinate from '../common/Coordinate'
|
import type Coordinate from '../common/Coordinate'
|
||||||
import type Bounding from '../common/Bounding'
|
import type Bounding from '../common/Bounding'
|
||||||
import type BarSpace from '../common/BarSpace'
|
|
||||||
import type Precision from '../common/Precision'
|
|
||||||
import type { OverlayStyle } from '../common/Styles'
|
import type { OverlayStyle } from '../common/Styles'
|
||||||
import type { MouseTouchEvent } from '../common/SyntheticEvent'
|
import type { MouseTouchEvent } from '../common/SyntheticEvent'
|
||||||
import { clone, isArray, isFunction, isNumber, isString, isValid, merge } from '../common/utils/typeChecks'
|
import { clone, isArray, isFunction, isNumber, isString, isValid, merge } from '../common/utils/typeChecks'
|
||||||
@ -27,7 +25,7 @@ import { clone, isArray, isFunction, isNumber, isString, isValid, merge } from '
|
|||||||
import type { XAxis } from './XAxis'
|
import type { XAxis } from './XAxis'
|
||||||
import type { YAxis } from './YAxis'
|
import type { YAxis } from './YAxis'
|
||||||
import type ChartStore from '../Store'
|
import type ChartStore from '../Store'
|
||||||
import type { Options } from '../Options'
|
import type { Chart } from '../Chart'
|
||||||
|
|
||||||
export enum OverlayMode {
|
export enum OverlayMode {
|
||||||
Normal = 'normal',
|
Normal = 'normal',
|
||||||
@ -67,21 +65,11 @@ export interface OverlayFigure {
|
|||||||
ignoreEvent?: boolean | OverlayFigureIgnoreEventType[]
|
ignoreEvent?: boolean | OverlayFigureIgnoreEventType[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OverlayPrecision extends Precision {
|
|
||||||
max: number
|
|
||||||
min: number
|
|
||||||
excludePriceVolumeMax: number
|
|
||||||
excludePriceVolumeMin: number
|
|
||||||
[key: string]: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OverlayCreateFiguresCallbackParams {
|
export interface OverlayCreateFiguresCallbackParams {
|
||||||
options: Options
|
chart: Chart
|
||||||
overlay: Overlay
|
overlay: Overlay
|
||||||
coordinates: Coordinate[]
|
coordinates: Coordinate[]
|
||||||
bounding: Bounding
|
bounding: Bounding
|
||||||
barSpace: BarSpace
|
|
||||||
precision: OverlayPrecision
|
|
||||||
xAxis: Nullable<XAxis>
|
xAxis: Nullable<XAxis>
|
||||||
yAxis: Nullable<YAxis>
|
yAxis: Nullable<YAxis>
|
||||||
}
|
}
|
||||||
@ -90,6 +78,7 @@ export interface OverlayEvent extends Partial<MouseTouchEvent> {
|
|||||||
figureKey?: string
|
figureKey?: string
|
||||||
figureIndex?: number
|
figureIndex?: number
|
||||||
overlay: Overlay
|
overlay: Overlay
|
||||||
|
chart: Chart
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OverlayEventCallback = (event: OverlayEvent) => boolean
|
export type OverlayEventCallback = (event: OverlayEvent) => boolean
|
||||||
|
@ -169,10 +169,8 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const range = this.createRange({
|
const range = this.createRange({
|
||||||
|
chart,
|
||||||
paneId,
|
paneId,
|
||||||
kLineDataList: chartStore.getDataList(),
|
|
||||||
dataVisibleRange: chartStore.getVisibleRange(),
|
|
||||||
indicators,
|
|
||||||
defaultRange
|
defaultRange
|
||||||
})
|
})
|
||||||
let realFrom = range.realFrom
|
let realFrom = range.realFrom
|
||||||
|
@ -25,22 +25,31 @@ const fibonacciLine: OverlayTemplate = {
|
|||||||
needDefaultPointFigure: true,
|
needDefaultPointFigure: true,
|
||||||
needDefaultXAxisFigure: true,
|
needDefaultXAxisFigure: true,
|
||||||
needDefaultYAxisFigure: true,
|
needDefaultYAxisFigure: true,
|
||||||
createPointFigures: ({ coordinates, bounding, overlay, precision, options, yAxis }) => {
|
createPointFigures: ({ chart, coordinates, bounding, overlay, yAxis }) => {
|
||||||
const points = overlay.points
|
const points = overlay.points
|
||||||
|
|
||||||
if (coordinates.length > 0) {
|
if (coordinates.length > 0) {
|
||||||
const currentPrecision = (yAxis?.isInCandle() ?? true) ? precision.price : precision.excludePriceVolumeMax
|
let precision = 0
|
||||||
|
if (yAxis?.isInCandle() ?? true) {
|
||||||
|
precision = chart.getPriceVolumePrecision().price
|
||||||
|
} else {
|
||||||
|
const indicators = chart.getIndicators({ paneId: overlay.paneId }).get(overlay.paneId) ?? []
|
||||||
|
indicators.forEach(indicator => {
|
||||||
|
precision = Math.max(precision, indicator.precision)
|
||||||
|
})
|
||||||
|
}
|
||||||
const lines: LineAttrs[] = []
|
const lines: LineAttrs[] = []
|
||||||
const texts: TextAttrs[] = []
|
const texts: TextAttrs[] = []
|
||||||
const startX = 0
|
const startX = 0
|
||||||
const endX = bounding.width
|
const endX = bounding.width
|
||||||
if (coordinates.length > 1 && isNumber(points[0].value) && isNumber(points[1].value)) {
|
if (coordinates.length > 1 && isNumber(points[0].value) && isNumber(points[1].value)) {
|
||||||
const { decimalFold, thousandsSeparator } = options
|
const { decimalFold, thousandsSeparator } = chart.getOptions()
|
||||||
const percents = [1, 0.786, 0.618, 0.5, 0.382, 0.236, 0]
|
const percents = [1, 0.786, 0.618, 0.5, 0.382, 0.236, 0]
|
||||||
const yDif = coordinates[0].y - coordinates[1].y
|
const yDif = coordinates[0].y - coordinates[1].y
|
||||||
const valueDif = points[0].value - points[1].value
|
const valueDif = points[0].value - points[1].value
|
||||||
percents.forEach(percent => {
|
percents.forEach(percent => {
|
||||||
const y = coordinates[1].y + yDif * percent
|
const y = coordinates[1].y + yDif * percent
|
||||||
const value = decimalFold.format(thousandsSeparator.format(((points[1].value ?? 0) + valueDif * percent).toFixed(currentPrecision)))
|
const value = decimalFold.format(thousandsSeparator.format(((points[1].value ?? 0) + valueDif * percent).toFixed(precision)))
|
||||||
lines.push({ coordinates: [{ x: startX, y }, { x: endX, y }] })
|
lines.push({ coordinates: [{ x: startX, y }, { x: endX, y }] })
|
||||||
texts.push({
|
texts.push({
|
||||||
x: startX,
|
x: startX,
|
||||||
|
@ -20,10 +20,18 @@ const priceLine: OverlayTemplate = {
|
|||||||
needDefaultPointFigure: true,
|
needDefaultPointFigure: true,
|
||||||
needDefaultXAxisFigure: true,
|
needDefaultXAxisFigure: true,
|
||||||
needDefaultYAxisFigure: true,
|
needDefaultYAxisFigure: true,
|
||||||
createPointFigures: ({ coordinates, bounding, precision, overlay, options, yAxis }) => {
|
createPointFigures: ({ chart, coordinates, bounding, overlay, yAxis }) => {
|
||||||
const { decimalFold, thousandsSeparator } = options
|
let precision = 0
|
||||||
|
if (yAxis?.isInCandle() ?? true) {
|
||||||
|
precision = chart.getPriceVolumePrecision().price
|
||||||
|
} else {
|
||||||
|
const indicators = chart.getIndicators({ paneId: overlay.paneId }).get(overlay.paneId) ?? []
|
||||||
|
indicators.forEach(indicator => {
|
||||||
|
precision = Math.max(precision, indicator.precision)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const { decimalFold, thousandsSeparator } = chart.getOptions()
|
||||||
const { value = 0 } = (overlay.points)[0]
|
const { value = 0 } = (overlay.points)[0]
|
||||||
const currentPrecision = (yAxis?.isInCandle() ?? true) ? precision.price : precision.excludePriceVolumeMax
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
type: 'line',
|
type: 'line',
|
||||||
@ -35,7 +43,7 @@ const priceLine: OverlayTemplate = {
|
|||||||
attrs: {
|
attrs: {
|
||||||
x: coordinates[0].x,
|
x: coordinates[0].x,
|
||||||
y: coordinates[0].y,
|
y: coordinates[0].y,
|
||||||
text: decimalFold.format(thousandsSeparator.format(value.toFixed(currentPrecision))),
|
text: decimalFold.format(thousandsSeparator.format(value.toFixed(precision))),
|
||||||
baseline: 'bottom'
|
baseline: 'bottom'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ const simpleTag: OverlayTemplate = {
|
|||||||
ignoreEvent: true
|
ignoreEvent: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createYAxisFigures: ({ overlay, coordinates, bounding, yAxis, precision }) => {
|
createYAxisFigures: ({ chart, overlay, coordinates, bounding, yAxis }) => {
|
||||||
const isFromZero = yAxis?.isFromZero() ?? false
|
const isFromZero = yAxis?.isFromZero() ?? false
|
||||||
let textAlign: CanvasTextAlign = 'left'
|
let textAlign: CanvasTextAlign = 'left'
|
||||||
let x = 0
|
let x = 0
|
||||||
@ -58,7 +58,7 @@ const simpleTag: OverlayTemplate = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isValid(text) && isNumber(overlay.points[0].value)) {
|
if (!isValid(text) && isNumber(overlay.points[0].value)) {
|
||||||
text = formatPrecision(overlay.points[0].value, precision.price)
|
text = formatPrecision(overlay.points[0].value, chart.getPriceVolumePrecision().price)
|
||||||
}
|
}
|
||||||
return { type: 'text', attrs: { x, y: coordinates[0].y, text, align: textAlign, baseline: 'middle' } }
|
return { type: 'text', attrs: { x, y: coordinates[0].y, text, align: textAlign, baseline: 'middle' } }
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,10 @@ const percentage: AxisTemplate = {
|
|||||||
realValueToValue: (value, { range }) => {
|
realValueToValue: (value, { range }) => {
|
||||||
return (value - range.realFrom) / range.realRange * range.range + range.from
|
return (value - range.realFrom) / range.realRange * range.range + range.from
|
||||||
},
|
},
|
||||||
createRange: ({ defaultRange, dataVisibleRange, kLineDataList }) => {
|
createRange: ({ chart, defaultRange }) => {
|
||||||
const kLineData = kLineDataList[dataVisibleRange.from]
|
const kLineDataList = chart.getDataList()
|
||||||
|
const visibleRange = chart.getVisibleRange()
|
||||||
|
const kLineData = kLineDataList[visibleRange.from]
|
||||||
if (isValid(kLineData)) {
|
if (isValid(kLineData)) {
|
||||||
const { from, to, range } = defaultRange
|
const { from, to, range } = defaultRange
|
||||||
const realFrom = (defaultRange.from - kLineData.close) / kLineData.close * 100
|
const realFrom = (defaultRange.from - kLineData.close) / kLineData.close * 100
|
||||||
|
@ -295,14 +295,12 @@ export default class IndicatorTooltipView extends View<YAxis> {
|
|||||||
if (isFunction(indicator.createTooltipDataSource)) {
|
if (isFunction(indicator.createTooltipDataSource)) {
|
||||||
const widget = this.getWidget()
|
const widget = this.getWidget()
|
||||||
const pane = widget.getPane()
|
const pane = widget.getPane()
|
||||||
const chartStore = pane.getChart().getChartStore()
|
const chart = pane.getChart()
|
||||||
const { name: customName, calcParamsText: customCalcParamsText, legends: customLegends, icons: customIcons } = indicator.createTooltipDataSource({
|
const { name: customName, calcParamsText: customCalcParamsText, legends: customLegends, icons: customIcons } = indicator.createTooltipDataSource({
|
||||||
kLineDataList: dataList,
|
chart,
|
||||||
indicator,
|
indicator,
|
||||||
visibleRange: chartStore.getVisibleRange(),
|
|
||||||
bounding: widget.getBounding(),
|
bounding: widget.getBounding(),
|
||||||
crosshair,
|
crosshair,
|
||||||
defaultStyles: styles,
|
|
||||||
xAxis: pane.getChart().getXAxisPane().getAxisComponent(),
|
xAxis: pane.getChart().getXAxisPane().getAxisComponent(),
|
||||||
yAxis: pane.getAxisComponent()
|
yAxis: pane.getAxisComponent()
|
||||||
})
|
})
|
||||||
|
@ -68,7 +68,6 @@ export default class IndicatorView extends CandleBarView {
|
|||||||
const yAxis = pane.getAxisComponent()
|
const yAxis = pane.getAxisComponent()
|
||||||
const chartStore = chart.getChartStore()
|
const chartStore = chart.getChartStore()
|
||||||
const dataList = chartStore.getDataList()
|
const dataList = chartStore.getDataList()
|
||||||
const visibleRange = chartStore.getVisibleRange()
|
|
||||||
const indicators = chartStore.getIndicatorsByPaneId(pane.getId())
|
const indicators = chartStore.getIndicatorsByPaneId(pane.getId())
|
||||||
const defaultStyles = chartStore.getOptions().styles.indicator
|
const defaultStyles = chartStore.getOptions().styles.indicator
|
||||||
ctx.save()
|
ctx.save()
|
||||||
@ -84,12 +83,9 @@ export default class IndicatorView extends CandleBarView {
|
|||||||
ctx.save()
|
ctx.save()
|
||||||
isCover = indicator.draw({
|
isCover = indicator.draw({
|
||||||
ctx,
|
ctx,
|
||||||
kLineDataList: dataList,
|
chart,
|
||||||
indicator,
|
indicator,
|
||||||
visibleRange,
|
|
||||||
bounding,
|
bounding,
|
||||||
barSpace: chartStore.getBarSpace(),
|
|
||||||
defaultStyles,
|
|
||||||
xAxis,
|
xAxis,
|
||||||
yAxis
|
yAxis
|
||||||
})
|
})
|
||||||
|
@ -16,7 +16,6 @@ import type Nullable from '../common/Nullable'
|
|||||||
import type Coordinate from '../common/Coordinate'
|
import type Coordinate from '../common/Coordinate'
|
||||||
import type Point from '../common/Point'
|
import type Point from '../common/Point'
|
||||||
import type Bounding from '../common/Bounding'
|
import type Bounding from '../common/Bounding'
|
||||||
import type BarSpace from '../common/BarSpace'
|
|
||||||
import type { OverlayStyle } from '../common/Styles'
|
import type { OverlayStyle } from '../common/Styles'
|
||||||
import type { EventHandler, EventName, MouseTouchEvent, MouseTouchEventCallback } from '../common/SyntheticEvent'
|
import type { EventHandler, EventName, MouseTouchEvent, MouseTouchEventCallback } from '../common/SyntheticEvent'
|
||||||
import { isBoolean, isNumber, isValid } from '../common/utils/typeChecks'
|
import { isBoolean, isNumber, isValid } from '../common/utils/typeChecks'
|
||||||
@ -26,7 +25,7 @@ import type { Options } from '../Options'
|
|||||||
import type { Axis } from '../component/Axis'
|
import type { Axis } from '../component/Axis'
|
||||||
import type { XAxis } from '../component/XAxis'
|
import type { XAxis } from '../component/XAxis'
|
||||||
import type { YAxis } from '../component/YAxis'
|
import type { YAxis } from '../component/YAxis'
|
||||||
import type { OverlayPrecision, OverlayFigure, OverlayFigureIgnoreEventType, Overlay } from '../component/Overlay'
|
import type { OverlayFigure, OverlayFigureIgnoreEventType, Overlay } from '../component/Overlay'
|
||||||
import type OverlayImp from '../component/Overlay'
|
import type OverlayImp from '../component/Overlay'
|
||||||
import { OVERLAY_FIGURE_KEY_PREFIX, OverlayMode, getAllOverlayFigureIgnoreEventTypes } from '../component/Overlay'
|
import { OVERLAY_FIGURE_KEY_PREFIX, OverlayMode, getAllOverlayFigureIgnoreEventTypes } from '../component/Overlay'
|
||||||
|
|
||||||
@ -40,6 +39,8 @@ import type DrawWidget from '../widget/DrawWidget'
|
|||||||
import type DrawPane from '../pane/DrawPane'
|
import type DrawPane from '../pane/DrawPane'
|
||||||
|
|
||||||
import View from './View'
|
import View from './View'
|
||||||
|
import type { Chart } from '../Chart'
|
||||||
|
import type Precision from '../common/Precision'
|
||||||
|
|
||||||
export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||||
constructor (widget: DrawWidget<DrawPane<C>>) {
|
constructor (widget: DrawWidget<DrawPane<C>>) {
|
||||||
@ -50,7 +51,8 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
private _initEvent (): void {
|
private _initEvent (): void {
|
||||||
const pane = this.getWidget().getPane()
|
const pane = this.getWidget().getPane()
|
||||||
const paneId = pane.getId()
|
const paneId = pane.getId()
|
||||||
const chartStore = pane.getChart().getChartStore()
|
const chart = pane.getChart()
|
||||||
|
const chartStore = chart.getChartStore()
|
||||||
this.registerEvent('mouseMoveEvent', (event: MouseTouchEvent) => {
|
this.registerEvent('mouseMoveEvent', (event: MouseTouchEvent) => {
|
||||||
const progressOverlayInfo = chartStore.getProgressOverlayInfo()
|
const progressOverlayInfo = chartStore.getProgressOverlayInfo()
|
||||||
if (progressOverlayInfo !== null) {
|
if (progressOverlayInfo !== null) {
|
||||||
@ -64,7 +66,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
const key = `${OVERLAY_FIGURE_KEY_PREFIX}point_${index}`
|
const key = `${OVERLAY_FIGURE_KEY_PREFIX}point_${index}`
|
||||||
if (overlay.isDrawing() && progressOverlayPaneId === paneId) {
|
if (overlay.isDrawing() && progressOverlayPaneId === paneId) {
|
||||||
overlay.eventMoveForDrawing(this._coordinateToPoint(overlay, event))
|
overlay.eventMoveForDrawing(this._coordinateToPoint(overlay, event))
|
||||||
overlay.onDrawing?.({ overlay, figureKey: key, figureIndex: index, ...event })
|
overlay.onDrawing?.({ chart, overlay, figureKey: key, figureIndex: index, ...event })
|
||||||
}
|
}
|
||||||
return this._figureMouseMoveEvent(
|
return this._figureMouseMoveEvent(
|
||||||
overlay,
|
overlay,
|
||||||
@ -96,11 +98,11 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
const key = `${OVERLAY_FIGURE_KEY_PREFIX}point_${index}`
|
const key = `${OVERLAY_FIGURE_KEY_PREFIX}point_${index}`
|
||||||
if (overlay.isDrawing() && progressOverlayPaneId === paneId) {
|
if (overlay.isDrawing() && progressOverlayPaneId === paneId) {
|
||||||
overlay.eventMoveForDrawing(this._coordinateToPoint(overlay, event))
|
overlay.eventMoveForDrawing(this._coordinateToPoint(overlay, event))
|
||||||
overlay.onDrawing?.({ overlay, figureKey: key, figureIndex: index, ...event })
|
overlay.onDrawing?.({ chart, overlay, figureKey: key, figureIndex: index, ...event })
|
||||||
overlay.nextStep()
|
overlay.nextStep()
|
||||||
if (!overlay.isDrawing()) {
|
if (!overlay.isDrawing()) {
|
||||||
chartStore.progressOverlayComplete()
|
chartStore.progressOverlayComplete()
|
||||||
overlay.onDrawEnd?.({ overlay, figureKey: key, figureIndex: index, ...event })
|
overlay.onDrawEnd?.({ chart, overlay, figureKey: key, figureIndex: index, ...event })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this._figureMouseClickEvent(
|
return this._figureMouseClickEvent(
|
||||||
@ -131,7 +133,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
chartStore.progressOverlayComplete()
|
chartStore.progressOverlayComplete()
|
||||||
const index = overlay.points.length - 1
|
const index = overlay.points.length - 1
|
||||||
const key = `${OVERLAY_FIGURE_KEY_PREFIX}point_${index}`
|
const key = `${OVERLAY_FIGURE_KEY_PREFIX}point_${index}`
|
||||||
overlay.onDrawEnd?.({ overlay, figureKey: key, figureIndex: index, ...event })
|
overlay.onDrawEnd?.({ chart, overlay, figureKey: key, figureIndex: index, ...event })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const index = overlay.points.length - 1
|
const index = overlay.points.length - 1
|
||||||
@ -163,7 +165,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
}).registerEvent('mouseUpEvent', (event: MouseTouchEvent) => {
|
}).registerEvent('mouseUpEvent', (event: MouseTouchEvent) => {
|
||||||
const { overlay, figureIndex, figureKey } = chartStore.getPressedOverlayInfo()
|
const { overlay, figureIndex, figureKey } = chartStore.getPressedOverlayInfo()
|
||||||
if (overlay !== null) {
|
if (overlay !== null) {
|
||||||
overlay.onPressedMoveEnd?.({ overlay, figureKey, figureIndex, ...event })
|
overlay.onPressedMoveEnd?.({ chart, overlay, figureKey, figureIndex, ...event })
|
||||||
}
|
}
|
||||||
chartStore.setPressedOverlayInfo({
|
chartStore.setPressedOverlayInfo({
|
||||||
paneId,
|
paneId,
|
||||||
@ -178,7 +180,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
const { overlay, figureType, figureIndex, figureKey } = chartStore.getPressedOverlayInfo()
|
const { overlay, figureType, figureIndex, figureKey } = chartStore.getPressedOverlayInfo()
|
||||||
if (overlay !== null) {
|
if (overlay !== null) {
|
||||||
if (!overlay.lock) {
|
if (!overlay.lock) {
|
||||||
if (!(overlay.onPressedMoving?.({ overlay, figureIndex, figureKey, ...event }) ?? false)) {
|
if (!(overlay.onPressedMoving?.({ chart, overlay, figureIndex, figureKey, ...event }) ?? false)) {
|
||||||
const point = this._coordinateToPoint(overlay, event)
|
const point = this._coordinateToPoint(overlay, event)
|
||||||
if (figureType === EventOverlayInfoFigureType.Point) {
|
if (figureType === EventOverlayInfoFigureType.Point) {
|
||||||
overlay.eventPressedPointMove(point, figureIndex)
|
overlay.eventPressedPointMove(point, figureIndex)
|
||||||
@ -262,7 +264,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
const pane = this.getWidget().getPane()
|
const pane = this.getWidget().getPane()
|
||||||
const paneId = pane.getId()
|
const paneId = pane.getId()
|
||||||
overlay.startPressedMove(this._coordinateToPoint(overlay, event))
|
overlay.startPressedMove(this._coordinateToPoint(overlay, event))
|
||||||
overlay.onPressedMoveStart?.({ overlay, figureIndex, figureKey, ...event })
|
overlay.onPressedMoveStart?.({ chart: pane.getChart(), overlay, figureIndex, figureKey, ...event })
|
||||||
pane.getChart().getChartStore().setPressedOverlayInfo({ paneId, overlay, figureType, figureKey, figureIndex, attrsIndex })
|
pane.getChart().getChartStore().setPressedOverlayInfo({ paneId, overlay, figureType, figureKey, figureIndex, attrsIndex })
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -279,14 +281,14 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
|
|
||||||
private _figureMouseDoubleClickEvent (overlay: OverlayImp, _figureType: EventOverlayInfoFigureType, figureKey: string, figureIndex: number, _attrsIndex: number): MouseTouchEventCallback {
|
private _figureMouseDoubleClickEvent (overlay: OverlayImp, _figureType: EventOverlayInfoFigureType, figureKey: string, figureIndex: number, _attrsIndex: number): MouseTouchEventCallback {
|
||||||
return (event: MouseTouchEvent) => {
|
return (event: MouseTouchEvent) => {
|
||||||
overlay.onDoubleClick?.({ ...event, figureIndex, figureKey, overlay })
|
overlay.onDoubleClick?.({ ...event, chart: this.getWidget().getPane().getChart(), figureIndex, figureKey, overlay })
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _figureMouseRightClickEvent (overlay: OverlayImp, _figureType: EventOverlayInfoFigureType, figureKey: string, figureIndex: number, _attrsIndex: number): MouseTouchEventCallback {
|
private _figureMouseRightClickEvent (overlay: OverlayImp, _figureType: EventOverlayInfoFigureType, figureKey: string, figureIndex: number, _attrsIndex: number): MouseTouchEventCallback {
|
||||||
return (event: MouseTouchEvent) => {
|
return (event: MouseTouchEvent) => {
|
||||||
if (!(overlay.onRightClick?.({ overlay, figureIndex, figureKey, ...event }) ?? false)) {
|
if (!(overlay.onRightClick?.({ chart: this.getWidget().getPane().getChart(), overlay, figureIndex, figureKey, ...event }) ?? false)) {
|
||||||
this.getWidget().getPane().getChart().getChartStore().removeOverlay(overlay)
|
this.getWidget().getPane().getChart().getChartStore().removeOverlay(overlay)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -390,32 +392,15 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
const bounding = widget.getBounding()
|
const bounding = widget.getBounding()
|
||||||
const chartStore = chart.getChartStore()
|
const chartStore = chart.getChartStore()
|
||||||
const options = chartStore.getOptions()
|
const options = chartStore.getOptions()
|
||||||
const barSpace = chartStore.getBarSpace()
|
|
||||||
const precision = chartStore.getPrecision()
|
const precision = chartStore.getPrecision()
|
||||||
const hoverOverlayInfo = chartStore.getHoverOverlayInfo()
|
const hoverOverlayInfo = chartStore.getHoverOverlayInfo()
|
||||||
const clickOverlayInfo = chartStore.getClickOverlayInfo()
|
const clickOverlayInfo = chartStore.getClickOverlayInfo()
|
||||||
const overlays = this.getCompleteOverlays(chartStore, paneId)
|
const overlays = this.getCompleteOverlays(chartStore, paneId)
|
||||||
const paneIndicators = chartStore.getIndicatorsByPaneId(paneId)
|
|
||||||
const overlayPrecision = paneIndicators.reduce((prev, indicator) => {
|
|
||||||
const precision = indicator.precision
|
|
||||||
prev[indicator.name] = precision
|
|
||||||
prev.max = Math.max(prev.max, precision)
|
|
||||||
prev.min = Math.min(prev.min, precision)
|
|
||||||
prev.excludePriceVolumeMax = Math.max(prev.excludePriceVolumeMax, precision)
|
|
||||||
prev.excludePriceVolumeMin = Math.min(prev.excludePriceVolumeMin, precision)
|
|
||||||
return prev
|
|
||||||
}, {
|
|
||||||
...precision,
|
|
||||||
max: Math.max(precision.price, precision.volume),
|
|
||||||
min: Math.min(precision.price, precision.volume),
|
|
||||||
excludePriceVolumeMax: Number.MIN_SAFE_INTEGER,
|
|
||||||
excludePriceVolumeMin: Number.MAX_SAFE_INTEGER
|
|
||||||
})
|
|
||||||
overlays.forEach(overlay => {
|
overlays.forEach(overlay => {
|
||||||
if (overlay.visible) {
|
if (overlay.visible) {
|
||||||
this._drawOverlay(
|
this._drawOverlay(
|
||||||
ctx, overlay, bounding, barSpace,
|
ctx, overlay, bounding,
|
||||||
overlayPrecision, options, xAxis, yAxis,
|
precision, options, xAxis, yAxis,
|
||||||
hoverOverlayInfo, clickOverlayInfo, chartStore
|
hoverOverlayInfo, clickOverlayInfo, chartStore
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -426,8 +411,8 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
|
|
||||||
if (isValid(overlay) && overlay.visible) {
|
if (isValid(overlay) && overlay.visible) {
|
||||||
this._drawOverlay(
|
this._drawOverlay(
|
||||||
ctx, overlay, bounding, barSpace,
|
ctx, overlay, bounding,
|
||||||
overlayPrecision, options, xAxis, yAxis,
|
precision, options, xAxis, yAxis,
|
||||||
hoverOverlayInfo, clickOverlayInfo, chartStore
|
hoverOverlayInfo, clickOverlayInfo, chartStore
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -438,8 +423,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
ctx: CanvasRenderingContext2D,
|
ctx: CanvasRenderingContext2D,
|
||||||
overlay: OverlayImp,
|
overlay: OverlayImp,
|
||||||
bounding: Bounding,
|
bounding: Bounding,
|
||||||
barSpace: BarSpace,
|
precision: Precision,
|
||||||
precision: OverlayPrecision,
|
|
||||||
options: Options,
|
options: Options,
|
||||||
xAxis: Nullable<XAxis>,
|
xAxis: Nullable<XAxis>,
|
||||||
yAxis: Nullable<YAxis>,
|
yAxis: Nullable<YAxis>,
|
||||||
@ -465,7 +449,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
if (coordinates.length > 0) {
|
if (coordinates.length > 0) {
|
||||||
const figures = new Array<OverlayFigure>().concat(
|
const figures = new Array<OverlayFigure>().concat(
|
||||||
this.getFigures(
|
this.getFigures(
|
||||||
overlay, coordinates, bounding, barSpace, precision, options, xAxis, yAxis
|
chartStore.getChart(), overlay, coordinates, bounding, xAxis, yAxis
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
this.drawFigures(
|
this.drawFigures(
|
||||||
@ -520,16 +504,14 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected getFigures (
|
protected getFigures (
|
||||||
|
chart: Chart,
|
||||||
o: Overlay,
|
o: Overlay,
|
||||||
coordinates: Coordinate[],
|
coordinates: Coordinate[],
|
||||||
bounding: Bounding,
|
bounding: Bounding,
|
||||||
barSpace: BarSpace,
|
|
||||||
precision: OverlayPrecision,
|
|
||||||
options: Options,
|
|
||||||
xAxis: Nullable<XAxis>,
|
xAxis: Nullable<XAxis>,
|
||||||
yAxis: Nullable<YAxis>
|
yAxis: Nullable<YAxis>
|
||||||
): OverlayFigure | OverlayFigure[] {
|
): OverlayFigure | OverlayFigure[] {
|
||||||
return o.createPointFigures?.({ overlay: o, coordinates, bounding, barSpace, precision, options, xAxis, yAxis }) ?? []
|
return o.createPointFigures?.({ chart, overlay: o, coordinates, bounding, xAxis, yAxis }) ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
protected drawDefaultFigures (
|
protected drawDefaultFigures (
|
||||||
@ -537,7 +519,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
|||||||
overlay: OverlayImp,
|
overlay: OverlayImp,
|
||||||
coordinates: Coordinate[],
|
coordinates: Coordinate[],
|
||||||
_bounding: Bounding,
|
_bounding: Bounding,
|
||||||
_precision: OverlayPrecision,
|
_precision: Precision,
|
||||||
options: Options,
|
options: Options,
|
||||||
_xAxis: Nullable<XAxis>,
|
_xAxis: Nullable<XAxis>,
|
||||||
_yAxis: Nullable<YAxis>,
|
_yAxis: Nullable<YAxis>,
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
import type Nullable from '../common/Nullable'
|
import type Nullable from '../common/Nullable'
|
||||||
import type Coordinate from '../common/Coordinate'
|
import type Coordinate from '../common/Coordinate'
|
||||||
import type Bounding from '../common/Bounding'
|
import type Bounding from '../common/Bounding'
|
||||||
import type BarSpace from '../common/BarSpace'
|
|
||||||
import type Precision from '../common/Precision'
|
import type Precision from '../common/Precision'
|
||||||
import { isNumber } from '../common/utils/typeChecks'
|
import { isNumber } from '../common/utils/typeChecks'
|
||||||
|
|
||||||
@ -23,13 +22,14 @@ import { FormatDateType, type Options } from '../Options'
|
|||||||
|
|
||||||
import type { XAxis } from '../component/XAxis'
|
import type { XAxis } from '../component/XAxis'
|
||||||
import type { YAxis } from '../component/YAxis'
|
import type { YAxis } from '../component/YAxis'
|
||||||
import type { OverlayPrecision, OverlayFigure, Overlay } from '../component/Overlay'
|
import type { OverlayFigure, Overlay } from '../component/Overlay'
|
||||||
import type OverlayImp from '../component/Overlay'
|
import type OverlayImp from '../component/Overlay'
|
||||||
|
|
||||||
import type { EventOverlayInfo, ProgressOverlayInfo } from '../Store'
|
import type { EventOverlayInfo, ProgressOverlayInfo } from '../Store'
|
||||||
import type ChartStore from '../Store'
|
import type ChartStore from '../Store'
|
||||||
|
|
||||||
import OverlayYAxisView from './OverlayYAxisView'
|
import OverlayYAxisView from './OverlayYAxisView'
|
||||||
|
import type { Chart } from '../Chart'
|
||||||
|
|
||||||
export default class OverlayXAxisView extends OverlayYAxisView<XAxis> {
|
export default class OverlayXAxisView extends OverlayYAxisView<XAxis> {
|
||||||
override coordinateToPointTimestampDataIndexFlag (): boolean {
|
override coordinateToPointTimestampDataIndexFlag (): boolean {
|
||||||
@ -79,15 +79,13 @@ export default class OverlayXAxisView extends OverlayYAxisView<XAxis> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override getFigures (
|
override getFigures (
|
||||||
|
chart: Chart,
|
||||||
o: Overlay,
|
o: Overlay,
|
||||||
coordinates: Coordinate[],
|
coordinates: Coordinate[],
|
||||||
bounding: Bounding,
|
bounding: Bounding,
|
||||||
barSpace: BarSpace,
|
|
||||||
precision: OverlayPrecision,
|
|
||||||
options: Options,
|
|
||||||
xAxis: Nullable<XAxis>,
|
xAxis: Nullable<XAxis>,
|
||||||
yAxis: Nullable<YAxis>
|
yAxis: Nullable<YAxis>
|
||||||
): OverlayFigure | OverlayFigure[] {
|
): OverlayFigure | OverlayFigure[] {
|
||||||
return o.createXAxisFigures?.({ overlay: o, coordinates, bounding, barSpace, precision, options, xAxis, yAxis }) ?? []
|
return o.createXAxisFigures?.({ chart, overlay: o, coordinates, bounding, xAxis, yAxis }) ?? []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,21 +15,23 @@
|
|||||||
import type Nullable from '../common/Nullable'
|
import type Nullable from '../common/Nullable'
|
||||||
import type Coordinate from '../common/Coordinate'
|
import type Coordinate from '../common/Coordinate'
|
||||||
import type Bounding from '../common/Bounding'
|
import type Bounding from '../common/Bounding'
|
||||||
import type BarSpace from '../common/BarSpace'
|
|
||||||
import type { Options } from '../Options'
|
import type { Options } from '../Options'
|
||||||
import { formatPrecision } from '../common/utils/format'
|
import { formatPrecision } from '../common/utils/format'
|
||||||
import { isNumber } from '../common/utils/typeChecks'
|
import { isNumber } from '../common/utils/typeChecks'
|
||||||
|
import type Precision from '../common/Precision'
|
||||||
|
|
||||||
import type { Axis } from '../component/Axis'
|
import type { Axis } from '../component/Axis'
|
||||||
import type { XAxis } from '../component/XAxis'
|
import type { XAxis } from '../component/XAxis'
|
||||||
import type { YAxis } from '../component/YAxis'
|
import type { YAxis } from '../component/YAxis'
|
||||||
import type { OverlayPrecision, OverlayFigure, Overlay } from '../component/Overlay'
|
import type { OverlayFigure, Overlay } from '../component/Overlay'
|
||||||
import type OverlayImp from '../component/Overlay'
|
import type OverlayImp from '../component/Overlay'
|
||||||
|
|
||||||
import type { EventOverlayInfo } from '../Store'
|
import type { EventOverlayInfo } from '../Store'
|
||||||
|
|
||||||
import OverlayView from './OverlayView'
|
import OverlayView from './OverlayView'
|
||||||
|
|
||||||
|
import type { Chart } from '../Chart'
|
||||||
|
|
||||||
export default class OverlayYAxisView<C extends Axis = YAxis> extends OverlayView<C> {
|
export default class OverlayYAxisView<C extends Axis = YAxis> extends OverlayView<C> {
|
||||||
override coordinateToPointTimestampDataIndexFlag (): boolean {
|
override coordinateToPointTimestampDataIndexFlag (): boolean {
|
||||||
return false
|
return false
|
||||||
@ -40,7 +42,7 @@ export default class OverlayYAxisView<C extends Axis = YAxis> extends OverlayVie
|
|||||||
overlay: OverlayImp,
|
overlay: OverlayImp,
|
||||||
coordinates: Coordinate[],
|
coordinates: Coordinate[],
|
||||||
bounding: Bounding,
|
bounding: Bounding,
|
||||||
precision: OverlayPrecision,
|
precision: Precision,
|
||||||
options: Options,
|
options: Options,
|
||||||
xAxis: Nullable<XAxis>,
|
xAxis: Nullable<XAxis>,
|
||||||
yAxis: Nullable<YAxis>,
|
yAxis: Nullable<YAxis>,
|
||||||
@ -59,7 +61,7 @@ export default class OverlayYAxisView<C extends Axis = YAxis> extends OverlayVie
|
|||||||
overlay: Overlay,
|
overlay: Overlay,
|
||||||
coordinates: Coordinate[],
|
coordinates: Coordinate[],
|
||||||
bounding: Bounding,
|
bounding: Bounding,
|
||||||
precision: OverlayPrecision,
|
precision: Precision,
|
||||||
options: Options,
|
options: Options,
|
||||||
_xAxis: Nullable<XAxis>,
|
_xAxis: Nullable<XAxis>,
|
||||||
yAxis: Nullable<YAxis>,
|
yAxis: Nullable<YAxis>,
|
||||||
@ -101,15 +103,13 @@ export default class OverlayYAxisView<C extends Axis = YAxis> extends OverlayVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
override getFigures (
|
override getFigures (
|
||||||
|
chart: Chart,
|
||||||
overlay: Overlay,
|
overlay: Overlay,
|
||||||
coordinates: Coordinate[],
|
coordinates: Coordinate[],
|
||||||
bounding: Bounding,
|
bounding: Bounding,
|
||||||
barSpace: BarSpace,
|
|
||||||
precision: OverlayPrecision,
|
|
||||||
options: Options,
|
|
||||||
xAxis: Nullable<XAxis>,
|
xAxis: Nullable<XAxis>,
|
||||||
yAxis: Nullable<YAxis>
|
yAxis: Nullable<YAxis>
|
||||||
): OverlayFigure | OverlayFigure[] {
|
): OverlayFigure | OverlayFigure[] {
|
||||||
return overlay.createYAxisFigures?.({ overlay, coordinates, bounding, barSpace, precision, options, xAxis, yAxis }) ?? []
|
return overlay.createYAxisFigures?.({ chart, overlay, coordinates, bounding, xAxis, yAxis }) ?? []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user