Skip to content

Commit 2d48411

Browse files
committed
rebase main into this branch
1 parent 4ccc036 commit 2d48411

6 files changed

Lines changed: 66 additions & 9 deletions

File tree

src/Chart.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export default class Chart implements ProChart
108108
return this._chart.resize();
109109
}
110110

111-
112111
/**
113112
* Store Proxy Methods
114113
*/

src/extension/brush.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Coordinate, LineAttrs, LineStyle, OverlayTemplate, SmoothLineStyle } from "klinecharts";
2+
import _ from "lodash";
3+
4+
const brush = (): OverlayTemplate => {
5+
return {
6+
name: "brush",
7+
totalStep: 3,
8+
needDefaultPointFigure: false,
9+
needDefaultXAxisFigure: false,
10+
needDefaultYAxisFigure: false,
11+
styles: {},
12+
createPointFigures: ({ coordinates }) => {
13+
const lines: LineAttrs[] = []
14+
if (coordinates.length > 1) {
15+
const filteredCoords = coordinates.filter((_, i) => i !== 1)
16+
17+
lines.push({ coordinates: filteredCoords })
18+
console.info("brush - createPointFigures - lines", filteredCoords, 'and coordinates', coordinates);
19+
}
20+
21+
return [
22+
{
23+
type: 'line',
24+
attrs: lines,
25+
styles: { style: 'solid', smooth: true } as SmoothLineStyle
26+
},
27+
];
28+
},
29+
performEventMoveForDrawing: ({ currentStep, points, performPoint }) => {
30+
if (currentStep >= 2) {
31+
console.info("brush - performEventMoveForDrawing before", { currentStep, points, performPoint: { ...performPoint } });
32+
points.push(performPoint);
33+
}
34+
}
35+
}
36+
};
37+
38+
export default brush;

src/extension/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import abcd from './abcd'
1818
import xabcd from './xabcd'
1919

2020
import positionLine from './position/orderLine'
21+
import brush from './brush'
2122

2223
const overlays = [
23-
arrow(),
24+
arrow(), brush(),
2425
circle(), rect(), triangle(), parallelogram(),
2526
fibonacciCircle(), fibonacciSegment(), fibonacciSpiral(),
2627
fibonacciSpeedResistanceFan(), fibonacciExtension(), gannBox(),

src/extension/parallelogram.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,13 @@ const parallelogram = (): ProOverlayTemplate => {
6868
},
6969
performEventPressedMove: ({ points, performPointIndex, performPoint }) => {
7070
if (performPointIndex < 2) {
71-
// @ts-expect-error
72-
points[0].price = performPoint.price
73-
// @ts-expect-error
74-
points[1].price = performPoint.price
71+
points[0].value = performPoint.value
72+
points[1].value = performPoint.value
7573
}
7674
},
7775
performEventMoveForDrawing: ({ currentStep, points, performPoint }) => {
7876
if (currentStep === 2) {
79-
// @ts-expect-error
80-
points[0].price = performPoint.price
77+
points[0].value = performPoint.value
8178
}
8279
},
8380
setProperties: (_properties: DeepPartial<OverlayProperties>) => {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
export default () => (
16+
<svg class="icon-overlay" viewBox="0 0 22 22">
17+
<path d="M17.0643,7.033864912109375L18,3.585784912109375L14.5078,4.509695912109375L15.3537,5.344934912109375L6.02026,14.560584912109375C5.87635,14.517484912109374,5.72366,14.494284912109375,5.5655,14.494284912109375C4.7009,14.494284912109375,4,15.186384912109375,4,16.040084912109375C4,16.893784912109375,4.7009,17.585784912109375,5.5655,17.585784912109375C6.43011,17.585784912109375,7.13101,16.893784912109375,7.13101,16.040084912109375C7.13101,15.722284912109375,7.03392,15.426984912109376,6.86744,15.181384912109374L16.0917,6.073604912109375L17.0643,7.033864912109375Z" stroke-opacity="0" stroke="none"/>
18+
</svg>
19+
)

src/widget/drawing-bar/icons/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import remove from './remove'
5959
import type { SelectDataSourceItem } from '../../../component'
6060

6161
import i18n from '../../../i18n'
62+
import brush from './brush'
6263

6364
export const mapping = {
6465
horizontalStraightLine,
@@ -97,7 +98,8 @@ export const mapping = {
9798
unlock,
9899
visible,
99100
invisible,
100-
remove
101+
remove,
102+
brush
101103
}
102104

103105
export function createSingleLineOptions (locale: string): SelectDataSourceItem[] {
@@ -112,6 +114,7 @@ export function createSingleLineOptions (locale: string): SelectDataSourceItem[]
112114
{ key: 'rayLine', text: i18n('ray_line', locale) },
113115
{ key: 'segment', text: i18n('segment', locale) },
114116
{ key: 'arrow', text: i18n('arrow', locale) },
117+
{ key: 'brush', text: i18n('brush', locale) },
115118
{ key: 'priceLine', text: i18n('price_line', locale) }
116119
]
117120
}

0 commit comments

Comments
 (0)