@363045841yyt/klinechart 0.7.5-alpha.2 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DrawingStyleToolbar.vue.d.ts +1 -15
- package/dist/components/DrawingStyleToolbar.vue.d.ts.map +1 -1
- package/dist/components/IndicatorParams.vue.d.ts.map +1 -1
- package/dist/components/IndicatorSelector.vue.d.ts.map +1 -1
- package/dist/components/KLineChart.vue.d.ts +5 -6
- package/dist/components/KLineChart.vue.d.ts.map +1 -1
- package/dist/components/KLineTooltip.vue.d.ts +1 -1
- package/dist/components/KLineTooltip.vue.d.ts.map +1 -1
- package/dist/components/MarkerTooltip.vue.d.ts +1 -12
- package/dist/components/MarkerTooltip.vue.d.ts.map +1 -1
- package/dist/composables/useFullscreenTeleportTarget.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/{klinechart.css → index.css} +1 -2
- package/dist/index.d.cts +25 -4
- package/dist/index.d.ts +25 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +792 -841
- package/dist/version.d.ts +1 -1
- package/dist/web-component.d.ts +18 -0
- package/dist/web-component.d.ts.map +1 -0
- package/package.json +10 -2
- package/src/__tests__/_mockController.ts +11 -1
- package/src/components/DrawingStyleToolbar.vue +1 -14
- package/src/components/IndicatorParams.vue +2 -1
- package/src/components/IndicatorSelector.vue +63 -63
- package/src/components/KLineChart.vue +248 -546
- package/src/components/KLineTooltip.vue +2 -2
- package/src/components/MarkerTooltip.vue +1 -12
- package/src/composables/useFullscreenTeleportTarget.ts +0 -2
- package/src/index.ts +72 -0
- package/src/web-component.ts +14 -0
|
@@ -70,7 +70,7 @@ export interface KLineData {
|
|
|
70
70
|
const props = defineProps<{
|
|
71
71
|
k: KLineData | null
|
|
72
72
|
index: number | null
|
|
73
|
-
data: KLineData
|
|
73
|
+
data: ReadonlyArray<KLineData>
|
|
74
74
|
pos: { x: number; y: number }
|
|
75
75
|
useAnchor?: boolean
|
|
76
76
|
anchorPlacement?: 'right-bottom' | 'left-bottom'
|
|
@@ -109,7 +109,7 @@ const UP_COLOR = '#ef4444'
|
|
|
109
109
|
const DOWN_COLOR = '#22c55e'
|
|
110
110
|
const NEUTRAL_COLOR = '#6b7280'
|
|
111
111
|
|
|
112
|
-
function calcDirection(k: KLineData, data: KLineData
|
|
112
|
+
function calcDirection(k: KLineData, data: ReadonlyArray<KLineData>, idx: number | null): number {
|
|
113
113
|
if (k.close >= k.open) return 1
|
|
114
114
|
const prev = typeof idx === 'number' && idx > 0 ? data[idx - 1] : undefined
|
|
115
115
|
if (prev && k.close > prev.close) return 1
|
|
@@ -19,18 +19,7 @@
|
|
|
19
19
|
<script setup lang="ts">
|
|
20
20
|
import { computed } from 'vue'
|
|
21
21
|
import type { ComponentPublicInstance } from 'vue'
|
|
22
|
-
|
|
23
|
-
interface MarkerEntity {
|
|
24
|
-
markerType: string
|
|
25
|
-
metadata: Record<string, unknown>
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface CustomMarkerEntity {
|
|
29
|
-
date: string
|
|
30
|
-
shape: string
|
|
31
|
-
label?: { text: string }
|
|
32
|
-
metadata: Record<string, unknown>
|
|
33
|
-
}
|
|
22
|
+
import type { MarkerEntity, CustomMarkerEntity } from '@363045841yyt/klinechart-core/engine/marker/registry'
|
|
34
23
|
|
|
35
24
|
const MARKER_TYPE_LABELS: Record<string, string> = {
|
|
36
25
|
support: '支撑位',
|
|
@@ -8,11 +8,9 @@ export function provideFullscreenTeleportTarget(targetRef: Ref<HTMLElement | nul
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function useFullscreenTeleportTarget() {
|
|
11
|
-
// null = no provider in ancestor tree (degraded scenario)
|
|
12
11
|
const targetRef = inject(FULLSCREEN_TARGET_KEY, null)
|
|
13
12
|
|
|
14
13
|
return computed<HTMLElement | string>(() => {
|
|
15
|
-
// targetRef null → no provider; targetRef.value null → container not mounted yet
|
|
16
14
|
return targetRef?.value ?? 'body'
|
|
17
15
|
})
|
|
18
16
|
}
|
package/src/index.ts
CHANGED
|
@@ -29,10 +29,14 @@ import type {
|
|
|
29
29
|
ChartControllerFactory,
|
|
30
30
|
ChartMountOptions,
|
|
31
31
|
ChartViewport,
|
|
32
|
+
IndicatorDefinition,
|
|
32
33
|
IndicatorInstance,
|
|
33
34
|
InteractionSnapshot,
|
|
34
35
|
KLineData,
|
|
35
36
|
} from '@363045841yyt/klinechart-core'
|
|
37
|
+
import {
|
|
38
|
+
createIndicatorSelectorController,
|
|
39
|
+
} from '@363045841yyt/klinechart-core'
|
|
36
40
|
|
|
37
41
|
export type {
|
|
38
42
|
ChartController,
|
|
@@ -252,6 +256,74 @@ export function useViewport(
|
|
|
252
256
|
return vp
|
|
253
257
|
}
|
|
254
258
|
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
// useIndicatorSelector — composable
|
|
261
|
+
// ---------------------------------------------------------------------------
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Bridge the indicator selector signals into Vue refs.
|
|
265
|
+
*
|
|
266
|
+
* Creates an internal IndicatorSelectorController for menu/search/filter UI
|
|
267
|
+
* state (catalog from `controller.catalog`), and delegates add/remove to the
|
|
268
|
+
* ChartController engine methods.
|
|
269
|
+
*/
|
|
270
|
+
export function useIndicatorSelector(controller: ChartController): {
|
|
271
|
+
catalog: ReadonlyArray<IndicatorDefinition>
|
|
272
|
+
filteredMain: Ref<ReadonlyArray<IndicatorDefinition>>
|
|
273
|
+
filteredSub: Ref<ReadonlyArray<IndicatorDefinition>>
|
|
274
|
+
menuOpen: Ref<boolean>
|
|
275
|
+
searchQuery: Ref<string>
|
|
276
|
+
add: (definitionId: string) => string | null
|
|
277
|
+
remove: (instanceId: string) => boolean
|
|
278
|
+
openMenu: () => void
|
|
279
|
+
closeMenu: () => void
|
|
280
|
+
toggleMenu: () => void
|
|
281
|
+
setSearchQuery: (q: string) => void
|
|
282
|
+
isActive: (definitionId: string) => boolean
|
|
283
|
+
} {
|
|
284
|
+
const selector = createIndicatorSelectorController({
|
|
285
|
+
catalog: controller.catalog,
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
onScopeDispose(() => selector.dispose())
|
|
289
|
+
|
|
290
|
+
const filteredMain = coreSignalToVueRef(selector.filteredMain)
|
|
291
|
+
const filteredSub = coreSignalToVueRef(selector.filteredSub)
|
|
292
|
+
const menuOpen = coreSignalToVueRef(selector.menuOpen)
|
|
293
|
+
const searchQuery = coreSignalToVueRef(selector.searchQuery)
|
|
294
|
+
|
|
295
|
+
function add(definitionId: string): string | null {
|
|
296
|
+
const def = controller.catalog.find((d) => d.id === definitionId)
|
|
297
|
+
if (def === undefined) return null
|
|
298
|
+
return controller.addIndicator(definitionId, def.role)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function remove(instanceId: string): boolean {
|
|
302
|
+
return controller.removeIndicator(instanceId)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function isActive(definitionId: string): boolean {
|
|
306
|
+
return controller.indicators
|
|
307
|
+
.peek()
|
|
308
|
+
.some((i) => i.definitionId === definitionId)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
catalog: controller.catalog,
|
|
313
|
+
filteredMain,
|
|
314
|
+
filteredSub,
|
|
315
|
+
menuOpen,
|
|
316
|
+
searchQuery,
|
|
317
|
+
add,
|
|
318
|
+
remove,
|
|
319
|
+
openMenu: () => selector.openMenu(),
|
|
320
|
+
closeMenu: () => selector.closeMenu(),
|
|
321
|
+
toggleMenu: () => selector.toggleMenu(),
|
|
322
|
+
setSearchQuery: (q: string) => selector.setSearchQuery(q),
|
|
323
|
+
isActive,
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
255
327
|
// ---------------------------------------------------------------------------
|
|
256
328
|
// <KLineChart /> SFC-equivalent component
|
|
257
329
|
//
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineCustomElement } from 'vue'
|
|
2
|
+
import KLineChartVue from './components/KLineChart.vue'
|
|
3
|
+
import type { SemanticChartConfig, DataFetcher } from '@363045841yyt/klinechart-core/semantic'
|
|
4
|
+
|
|
5
|
+
const KLineChartElement = defineCustomElement(KLineChartVue, {
|
|
6
|
+
shadowRoot: true,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
customElements.define('kline-chart', KLineChartElement)
|
|
10
|
+
|
|
11
|
+
export { KLineChartElement }
|
|
12
|
+
export default KLineChartElement
|
|
13
|
+
|
|
14
|
+
export type { SemanticChartConfig, DataFetcher }
|