Skip to content

Commit f418d10

Browse files
committed
fix: fix for latest canvas plugin
1 parent 5eaad65 commit f418d10

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
"@angular/core": "^12.2.9",
4040
"@commitlint/cli": "^16.2.3",
4141
"@commitlint/config-conventional": "^16.2.1",
42-
"@nativescript-community/gesturehandler": "^2.0.1",
42+
"@nativescript-community/arraybuffers": "^1.0.1",
43+
"@nativescript-community/gesturehandler": "^2.0.5",
4344
"@nativescript-community/tween": "0.0.14",
44-
"@nativescript-community/ui-canvas": "4.4.1",
45+
"@nativescript-community/ui-canvas": "4.4.4",
4546
"@nativescript/core": "8.2.2",
4647
"@nativescript/types-android": "8.2.0",
4748
"@nativescript/types-ios": "8.2.1",

plugin/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
"main": "charts/index.js",
3333
"typings": "charts/index.d.ts",
3434
"dependencies": {
35-
"@nativescript-community/gesturehandler": "^2.0.1",
36-
"@nativescript-community/ui-canvas": "^4.4.1",
35+
"@nativescript-community/arraybuffers": "^1.0.1",
36+
"@nativescript-community/gesturehandler": "^2.0.5",
37+
"@nativescript-community/ui-canvas": "^4.4.4",
3738
"additween": "^3.0.0",
3839
"downsample": "^1.4.0",
3940
"number-format.js": "^2.0.9"

src/charting/renderer/CandleStickChartRenderer.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ export class CandleStickChartRenderer extends LineScatterCandleRadarRenderer {
201201
if (customRender && customRender.drawLines) {
202202
customRender.drawLines(c, e, rangeBuffers, openBuffers, closeBuffers, renderPaint);
203203
} else {
204-
c.drawLines(Utils.arrayToNativeArray(rangeBuffers, false, false), renderPaint);
205-
c.drawLines(Utils.arrayToNativeArray(openBuffers, false, false), renderPaint);
206-
c.drawLines(Utils.arrayToNativeArray(closeBuffers, false, false), renderPaint);
204+
c.drawLines(Utils.pointsFromBuffer(rangeBuffers, false, false) as number[], renderPaint);
205+
c.drawLines(Utils.pointsFromBuffer(openBuffers, false, false) as number[], renderPaint);
206+
c.drawLines(Utils.pointsFromBuffer(closeBuffers, false, false) as number[], renderPaint);
207207
}
208208
}
209209
}

src/charting/utils/Utils.ts

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1+
import { Align, Canvas, FontMetrics, Matrix, Paint, Path, Rect, RectF, StaticLayout, Style } from '@nativescript-community/ui-canvas';
12
import {
2-
Align,
3-
Canvas,
4-
FontMetrics,
5-
Matrix,
6-
Paint,
7-
Path,
8-
Rect,
9-
RectF,
10-
StaticLayout,
11-
Style,
123
TypedArray,
134
arrayToNativeArray as arrayToNativeArrayFn,
145
createArrayBuffer as createArrayBufferFn,
@@ -17,7 +8,7 @@ import {
178
nativeArrayToArray as nativeArrayToArrayFn,
189
pointsFromBuffer as pointsFromBufferFn,
1910
supportsDirectArrayBuffers as supportsDirectArrayBuffersFn
20-
} from '@nativescript-community/ui-canvas';
11+
} from '@nativescript-community/arraybuffers';
2112
import Shape from '@nativescript-community/ui-canvas/shapes/shape';
2213
import { Color, ImageSource, ObservableArray, Trace } from '@nativescript/core';
2314
import { Screen } from '@nativescript/core/platform';
@@ -691,16 +682,16 @@ export namespace Utils {
691682
export const nativeArrayToArray = nativeArrayToArrayFn;
692683
export const arrayToNativeArray = arrayToNativeArrayFn;
693684

694-
const mTempArrays: { [k: string]: number[] | TypedArray } = {};
685+
const mTempArrays: { [k: string]: TypedArray } = {};
695686
export function getTempArray(length, useInts = false, canReturnBuffer = true, optKey?: string) {
696-
let key = length + '' + useInts;
687+
let key = length + '' + useInts + '' + canReturnBuffer;
697688
if (optKey) {
698689
key += optKey;
699690
}
700691
if (mTempArrays[key]) {
701692
return mTempArrays[key];
702693
}
703-
const buf = (mTempArrays[key] = createArrayBufferOrNativeArray(length, useInts, canReturnBuffer));
694+
const buf = (mTempArrays[key] = createArrayBuffer(length, useInts, canReturnBuffer));
704695
return buf;
705696
}
706697

src/charting/utils/ViewPortHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ export class ViewPortHandler {
379379
*/
380380
public limitTransAndScale(matrix: Matrix, content: Rect) {
381381
if (!this.mMatrixBuffer) {
382-
this.mMatrixBuffer = Utils.createArrayBufferOrNativeArray(9);
382+
this.mMatrixBuffer = Utils.createArrayBuffer(9);
383383
}
384384
const matrixBuffer = this.mMatrixBuffer;
385385
matrix.getValues(matrixBuffer);

0 commit comments

Comments
 (0)