scichart 3.1.329 → 3.1.346
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/Charting/ChartModifiers/RolloverModifier.d.ts +11 -0
- package/Charting/ChartModifiers/RolloverModifier.js +59 -46
- package/Charting/ChartModifiers/ZoomExtentsModifier.js +2 -2
- package/Charting/ChartModifiers/ZoomPanModifier.js +2 -0
- package/Charting/Model/BaseDataSeries.js +3 -6
- package/Charting/Model/HlcDataSeries.js +4 -5
- package/Charting/Model/OhlcDataSeries.js +2 -3
- package/Charting/Model/XyyDataSeries.js +2 -2
- package/Charting/Services/ChartTitleRenderer.d.ts +0 -4
- package/Charting/Services/ChartTitleRenderer.js +11 -45
- package/Charting/Services/TitleRenderer.d.ts +14 -6
- package/Charting/Services/TitleRenderer.js +85 -21
- package/Charting/Visuals/Annotations/OverviewCustomResizableAnnotation.js +2 -0
- package/Charting/Visuals/Axis/AxisBase2D.js +5 -14
- package/Charting/Visuals/Axis/AxisCore.d.ts +17 -11
- package/Charting/Visuals/Axis/AxisCore.js +14 -9
- package/Charting/Visuals/Axis/AxisTitleRenderer.d.ts +13 -17
- package/Charting/Visuals/Axis/AxisTitleRenderer.js +88 -108
- package/Charting/Visuals/Axis/IAxisCoreOptions.d.ts +2 -2
- package/Charting/Visuals/Axis/LabelProvider/LabelCache.js +1 -0
- package/Charting/Visuals/RenderableSeries/HitTest/BandSeriesHitTestProvider.js +11 -4
- package/Charting/Visuals/RenderableSeries/HitTest/BaseHitTestProvider.js +11 -4
- package/Charting/Visuals/RenderableSeries/HitTest/LineSeriesHitTestProvider.js +11 -4
- package/Charting/Visuals/SciChartSurface.d.ts +2 -0
- package/Charting/Visuals/SciChartSurface.js +11 -2
- package/Charting/Visuals/TextureManager/TextureManager.js +2 -2
- package/Charting3D/Model/DataSeries/UniformGridDataSeries3D.d.ts +1 -1
- package/Charting3D/Model/DataSeries/UniformGridDataSeries3D.js +1 -1
- package/Core/BuildStamp.d.ts +1 -1
- package/Core/BuildStamp.js +2 -2
- package/_wasm/scichart.browser.js +1 -1
- package/_wasm/scichart2d.js +1 -1
- package/_wasm/scichart2d.wasm +0 -0
- package/_wasm/scichart3d.js +1 -1
- package/_wasm/scichart3d.wasm +0 -0
- package/constants/app.js +2 -1
- package/index.d.ts +2 -0
- package/index.js +13 -11
- package/index.min.js +1 -1
- package/package.json +1 -1
- package/types/TextStyle.d.ts +2 -0
- package/types/TextStyle.js +1 -1
- package/utils/date.js +2 -0
- package/utils/text.d.ts +3 -2
- package/utils/text.js +45 -2
|
@@ -222,6 +222,17 @@ export declare class RolloverModifier extends ChartModifierBase2D implements IIn
|
|
|
222
222
|
type: string;
|
|
223
223
|
options: Required<Omit<IChartModifierBaseOptions, never>>;
|
|
224
224
|
};
|
|
225
|
+
/**
|
|
226
|
+
* Called internally to adjust the positions of tooltips if there are overlaps, or if it is a vertical chart
|
|
227
|
+
* @param tooltipArray
|
|
228
|
+
* @param allowTooltipOverlapping
|
|
229
|
+
* @param spacing
|
|
230
|
+
* @param seriesViewRect
|
|
231
|
+
* @param pixelRatio
|
|
232
|
+
* @param isVerticalChart
|
|
233
|
+
* @returns TTooltipProps[]
|
|
234
|
+
*/
|
|
235
|
+
protected CalculateTooltipPositions(tooltipArray: TTooltipProps[], allowTooltipOverlapping: boolean, spacing: number, seriesViewRect: Rect, pixelRatio: number, isVerticalChart?: boolean): TTooltipProps[];
|
|
225
236
|
/** @inheritDoc */
|
|
226
237
|
protected notifyPropertyChanged(propertyName: string): void;
|
|
227
238
|
private isVerticalChart;
|
|
@@ -389,6 +389,20 @@ var RolloverModifier = /** @class */ (function (_super) {
|
|
|
389
389
|
Object.assign(json.options, options);
|
|
390
390
|
return json;
|
|
391
391
|
};
|
|
392
|
+
/**
|
|
393
|
+
* Called internally to adjust the positions of tooltips if there are overlaps, or if it is a vertical chart
|
|
394
|
+
* @param tooltipArray
|
|
395
|
+
* @param allowTooltipOverlapping
|
|
396
|
+
* @param spacing
|
|
397
|
+
* @param seriesViewRect
|
|
398
|
+
* @param pixelRatio
|
|
399
|
+
* @param isVerticalChart
|
|
400
|
+
* @returns TTooltipProps[]
|
|
401
|
+
*/
|
|
402
|
+
RolloverModifier.prototype.CalculateTooltipPositions = function (tooltipArray, allowTooltipOverlapping, spacing, seriesViewRect, pixelRatio, isVerticalChart) {
|
|
403
|
+
if (isVerticalChart === void 0) { isVerticalChart = false; }
|
|
404
|
+
return (0, exports.calcTooltipPositions)(tooltipArray, allowTooltipOverlapping, spacing, seriesViewRect, pixelRatio, isVerticalChart);
|
|
405
|
+
};
|
|
392
406
|
/** @inheritDoc */
|
|
393
407
|
RolloverModifier.prototype.notifyPropertyChanged = function (propertyName) {
|
|
394
408
|
_super.prototype.notifyPropertyChanged.call(this, propertyName);
|
|
@@ -546,12 +560,10 @@ var RolloverModifier = /** @class */ (function (_super) {
|
|
|
546
560
|
}
|
|
547
561
|
var tooltipArray = [];
|
|
548
562
|
rsList.forEach(function (rs, index) {
|
|
549
|
-
var visibleYMin = rs.yAxis.visibleRange.min;
|
|
550
|
-
var visibleYMax = rs.yAxis.visibleRange.max;
|
|
551
563
|
var hitTestInfo = _this.hitTestRenderableSeries(rs, _this.mousePoint);
|
|
552
564
|
if (hitTestInfo) {
|
|
553
565
|
if (rs.type !== SeriesType_1.ESeriesType.StackedColumnSeries || hitTestInfo.isHit) {
|
|
554
|
-
var isVisible =
|
|
566
|
+
var isVisible = 0 <= hitTestInfo.yCoord && hitTestInfo.yCoord <= _this.parentSurface.seriesViewRect.height;
|
|
555
567
|
if (isVisible) {
|
|
556
568
|
var absoluteXCoord = _this.isVerticalChart() ? hitTestInfo.yCoord : hitTestInfo.xCoord;
|
|
557
569
|
var absoluteYCoord = _this.isVerticalChart() ? hitTestInfo.xCoord : hitTestInfo.yCoord;
|
|
@@ -561,7 +573,7 @@ var RolloverModifier = /** @class */ (function (_super) {
|
|
|
561
573
|
}
|
|
562
574
|
}
|
|
563
575
|
if (rs.type === SeriesType_1.ESeriesType.BandSeries) {
|
|
564
|
-
var isVisibleY1 =
|
|
576
|
+
var isVisibleY1 = 0 <= hitTestInfo.y1Coord && hitTestInfo.y1Coord <= _this.parentSurface.seriesViewRect.height;
|
|
565
577
|
if (isVisibleY1) {
|
|
566
578
|
var absoluteXCoord = _this.isVerticalChart() ? hitTestInfo.y1Coord : hitTestInfo.xCoord;
|
|
567
579
|
var absoluteYCoord = _this.isVerticalChart() ? hitTestInfo.xCoord : hitTestInfo.y1Coord;
|
|
@@ -575,7 +587,7 @@ var RolloverModifier = /** @class */ (function (_super) {
|
|
|
575
587
|
var orderedTooltipArray = tooltipArray.sort(function (a, b) {
|
|
576
588
|
return a.yCoord > b.yCoord ? 1 : b.yCoord > a.yCoord ? -1 : 0;
|
|
577
589
|
});
|
|
578
|
-
var tooltipPositions =
|
|
590
|
+
var tooltipPositions = this.CalculateTooltipPositions(orderedTooltipArray, this.allowTooltipOverlapping, TOOLTIP_SPACING * DpiHelper_1.DpiHelper.PIXEL_RATIO, this.parentSurface.seriesViewRect, DpiHelper_1.DpiHelper.PIXEL_RATIO, this.isVerticalChart());
|
|
579
591
|
tooltipPositions.forEach(function (el) {
|
|
580
592
|
var rs = rsList[el.index];
|
|
581
593
|
var showTooltip = _this.showTooltip && el.seriesInfo.isHit;
|
|
@@ -661,50 +673,51 @@ exports.RolloverModifier = RolloverModifier;
|
|
|
661
673
|
var calcTooltipProps = function (index, rs, rolloverProps, seriesViewRect, xValue, yValue, absoluteXCoord, absoluteYCoord, hitTestInfo, pixelRatio, isY1, isVerticalChart) {
|
|
662
674
|
if (isY1 === void 0) { isY1 = false; }
|
|
663
675
|
if (isVerticalChart === void 0) { isVerticalChart = false; }
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
676
|
+
// This check is done in calling code
|
|
677
|
+
// const visibleRange = rs.yAxis.visibleRange;
|
|
678
|
+
// const isVisible = visibleRange.min <= yValue && yValue <= visibleRange.max);
|
|
679
|
+
// if (isVisible) {
|
|
680
|
+
var seriesInfo = rs.getSeriesInfo(hitTestInfo);
|
|
681
|
+
var width = rolloverProps.tooltip.width;
|
|
682
|
+
var scaledWidth = width * pixelRatio;
|
|
683
|
+
var height = rolloverProps.tooltip.height;
|
|
684
|
+
var scaledHeight = height * pixelRatio;
|
|
685
|
+
var distTop = absoluteYCoord;
|
|
686
|
+
var distBottom = seriesViewRect.height - absoluteYCoord;
|
|
687
|
+
var defaultVerticalShift = 5 * pixelRatio;
|
|
688
|
+
var xCoordShift = seriesViewRect.width - absoluteXCoord < scaledWidth ? -width : 5;
|
|
689
|
+
var yCoordShift = isVerticalChart ? defaultVerticalShift : -height / 2;
|
|
690
|
+
if (isVerticalChart) {
|
|
691
|
+
if (distBottom < scaledHeight + defaultVerticalShift) {
|
|
692
|
+
yCoordShift = ((scaledHeight + defaultVerticalShift) / pixelRatio) * -1;
|
|
681
693
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
if (distTop < scaledHeight / 2) {
|
|
697
|
+
yCoordShift = -distTop / pixelRatio;
|
|
698
|
+
}
|
|
699
|
+
else if (distBottom < scaledHeight / 2) {
|
|
700
|
+
yCoordShift = -(scaledHeight - distBottom) / pixelRatio;
|
|
689
701
|
}
|
|
690
|
-
var newRecord = {
|
|
691
|
-
index: index,
|
|
692
|
-
isY1: isY1,
|
|
693
|
-
xValue: xValue,
|
|
694
|
-
yValue: yValue,
|
|
695
|
-
xCoord: absoluteXCoord,
|
|
696
|
-
yCoord: absoluteYCoord,
|
|
697
|
-
hitTestPointValues: hitTestInfo.hitTestPointValues,
|
|
698
|
-
isCategoryAxis: hitTestInfo.isCategoryAxis,
|
|
699
|
-
xCoordShift: xCoordShift,
|
|
700
|
-
yCoordShift: yCoordShift,
|
|
701
|
-
height: scaledHeight,
|
|
702
|
-
width: scaledWidth,
|
|
703
|
-
seriesInfo: seriesInfo
|
|
704
|
-
};
|
|
705
|
-
return newRecord;
|
|
706
702
|
}
|
|
707
|
-
|
|
703
|
+
var newRecord = {
|
|
704
|
+
index: index,
|
|
705
|
+
isY1: isY1,
|
|
706
|
+
xValue: xValue,
|
|
707
|
+
yValue: yValue,
|
|
708
|
+
xCoord: absoluteXCoord,
|
|
709
|
+
yCoord: absoluteYCoord,
|
|
710
|
+
hitTestPointValues: hitTestInfo.hitTestPointValues,
|
|
711
|
+
isCategoryAxis: hitTestInfo.isCategoryAxis,
|
|
712
|
+
xCoordShift: xCoordShift,
|
|
713
|
+
yCoordShift: yCoordShift,
|
|
714
|
+
height: scaledHeight,
|
|
715
|
+
width: scaledWidth,
|
|
716
|
+
seriesInfo: seriesInfo
|
|
717
|
+
};
|
|
718
|
+
return newRecord;
|
|
719
|
+
// }
|
|
720
|
+
// return undefined;
|
|
708
721
|
};
|
|
709
722
|
exports.calcTooltipProps = calcTooltipProps;
|
|
710
723
|
/**
|
|
@@ -125,11 +125,11 @@ var ZoomExtentsModifier = /** @class */ (function (_super) {
|
|
|
125
125
|
activeAxes.forEach(function (axis) {
|
|
126
126
|
if (axis.isXAxis) {
|
|
127
127
|
var maxXRange = axis.getMaximumRange();
|
|
128
|
-
|
|
128
|
+
axis.animateVisibleRange(maxXRange, animationDuration, _this.easingFunction);
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
131
|
var yRange = axis.getWindowedYRange(undefined);
|
|
132
|
-
|
|
132
|
+
axis.animateVisibleRange(yRange, animationDuration, _this.easingFunction);
|
|
133
133
|
}
|
|
134
134
|
});
|
|
135
135
|
}
|
|
@@ -75,6 +75,8 @@ var ZoomPanModifier = /** @class */ (function (_super) {
|
|
|
75
75
|
}
|
|
76
76
|
/** @inheritDoc */
|
|
77
77
|
ZoomPanModifier.prototype.modifierMouseDown = function (args) {
|
|
78
|
+
// handles default browser dragging behavior when canvas was selected with Ctrl + A
|
|
79
|
+
args.nativeEvent.preventDefault();
|
|
78
80
|
_super.prototype.modifierMouseDown.call(this, args);
|
|
79
81
|
if (this.executeOn !== args.button) {
|
|
80
82
|
return;
|
|
@@ -535,10 +535,10 @@ isSorted) {
|
|
|
535
535
|
// TODO: getPositiveRange
|
|
536
536
|
var count = xValues.size();
|
|
537
537
|
// if one point
|
|
538
|
+
// We will expand zero width ranges in the axis
|
|
538
539
|
if (count === 1) {
|
|
539
|
-
var
|
|
540
|
-
|
|
541
|
-
return new NumberRange_1.NumberRange(min, max);
|
|
540
|
+
var y = yValues.get(0);
|
|
541
|
+
return new NumberRange_1.NumberRange(y, y);
|
|
542
542
|
}
|
|
543
543
|
var indicesRange = isXCategoryAxis ? xRange : (0, exports.getIndicesRange)(webAssemblyContext, xValues, xRange, isSorted);
|
|
544
544
|
var iMin = Math.max(Math.floor(indicesRange.min), 0);
|
|
@@ -552,9 +552,6 @@ isSorted) {
|
|
|
552
552
|
if (!(0, isRealNumber_1.isRealNumber)(minMax.minD) || !(0, isRealNumber_1.isRealNumber)(minMax.maxD)) {
|
|
553
553
|
return undefined;
|
|
554
554
|
}
|
|
555
|
-
if (minMax.minD === minMax.maxD) {
|
|
556
|
-
return new NumberRange_1.NumberRange(minMax.minD - 1, minMax.minD + 1);
|
|
557
|
-
}
|
|
558
555
|
return new NumberRange_1.NumberRange(minMax.minD, minMax.maxD);
|
|
559
556
|
}
|
|
560
557
|
finally {
|
|
@@ -394,13 +394,12 @@ var HlcDataSeries = /** @class */ (function (_super) {
|
|
|
394
394
|
// if one point
|
|
395
395
|
if (this.count() === 1 && !isHorizontalDirection) {
|
|
396
396
|
if (isHorizontalDirection) {
|
|
397
|
-
var
|
|
398
|
-
|
|
399
|
-
return new NumberRange_1.NumberRange(min, max);
|
|
397
|
+
var y = yValues.get(0);
|
|
398
|
+
return new NumberRange_1.NumberRange(y, y);
|
|
400
399
|
}
|
|
401
400
|
else {
|
|
402
|
-
var min = Math.min(hValues.get(0), lValues.get(0))
|
|
403
|
-
var max = Math.max(hValues.get(0), lValues.get(0))
|
|
401
|
+
var min = Math.min(hValues.get(0), lValues.get(0));
|
|
402
|
+
var max = Math.max(hValues.get(0), lValues.get(0));
|
|
404
403
|
return new NumberRange_1.NumberRange(min, max);
|
|
405
404
|
}
|
|
406
405
|
}
|
|
@@ -352,9 +352,8 @@ var OhlcDataSeries = /** @class */ (function (_super) {
|
|
|
352
352
|
if (dataSeriesValueType === void 0) { dataSeriesValueType = IDataSeries_1.EDataSeriesValueType.Default; }
|
|
353
353
|
var _a = this.getOHLCValues(dataSeriesValueType), closeValues = _a.closeValues, highValues = _a.highValues, lowValues = _a.lowValues;
|
|
354
354
|
if (this.count() === 1) {
|
|
355
|
-
var
|
|
356
|
-
|
|
357
|
-
return new NumberRange_1.NumberRange(min, max);
|
|
355
|
+
var y = closeValues.get(0);
|
|
356
|
+
return new NumberRange_1.NumberRange(y, y);
|
|
358
357
|
}
|
|
359
358
|
var indicesRange = isXCategoryAxis ? xRange : this.getIndicesRange(xRange);
|
|
360
359
|
var yMin = Number.MAX_VALUE;
|
|
@@ -288,8 +288,8 @@ var XyyDataSeries = /** @class */ (function (_super) {
|
|
|
288
288
|
// TODO: getPositiveRange
|
|
289
289
|
// if one point
|
|
290
290
|
if (this.count() === 1) {
|
|
291
|
-
var min = Math.min(yValues.get(0), y1Values.get(0))
|
|
292
|
-
var max = Math.max(yValues.get(0), y1Values.get(0))
|
|
291
|
+
var min = Math.min(yValues.get(0), y1Values.get(0));
|
|
292
|
+
var max = Math.max(yValues.get(0), y1Values.get(0));
|
|
293
293
|
return new NumberRange_1.NumberRange(min, max);
|
|
294
294
|
}
|
|
295
295
|
var indicesRange = isXCategoryAxis ? xRange : this.getIndicesRange(xRange);
|
|
@@ -26,10 +26,6 @@ export declare class ChartTitleRenderer extends TitleRendererBase<TChartTitleSty
|
|
|
26
26
|
*/
|
|
27
27
|
draw(renderContext: WebGlRenderContext2D): void;
|
|
28
28
|
protected getTitleTexture(): import("../Visuals/TextureManager/TextureManager").TTextureObject;
|
|
29
|
-
/**
|
|
30
|
-
* Calculates width and hight of the title text
|
|
31
|
-
*/
|
|
32
|
-
protected getTextSize(title: string | string[], textStyle: TChartTitleStyle, renderContext: WebGlRenderContext2D): void;
|
|
33
29
|
/**
|
|
34
30
|
* Calculates the {@link ChartTitleRenderer.titleOffset}
|
|
35
31
|
*/
|
|
@@ -29,7 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.ChartTitleRenderer = void 0;
|
|
30
30
|
var Thickness_1 = require("../../Core/Thickness");
|
|
31
31
|
var TextStyle_1 = require("../../types/TextStyle");
|
|
32
|
-
var text_1 = require("../../utils/text");
|
|
33
32
|
var SciChartSurfaceBase_1 = require("../Visuals/SciChartSurfaceBase");
|
|
34
33
|
var TitleRenderer_1 = require("./TitleRenderer");
|
|
35
34
|
/**
|
|
@@ -60,12 +59,15 @@ var ChartTitleRenderer = /** @class */ (function (_super) {
|
|
|
60
59
|
var shouldUpdateTextSize = title !== this.text ||
|
|
61
60
|
!(0, TextStyle_1.areEqualTextStyles)(originalTextStyle, this.originalTextStyle) ||
|
|
62
61
|
((_a = this.originalTextStyle) === null || _a === void 0 ? void 0 : _a.position) !== originalTextStyle.position;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (!this.useCache || !this.texture || shouldUpdateTextSize) {
|
|
62
|
+
if (title && title.length > 0) {
|
|
63
|
+
if (!this.useCache || (!this.texture && !originalTextStyle.useNativeText) || shouldUpdateTextSize) {
|
|
66
64
|
// recalculate cached text size info or texture
|
|
65
|
+
this.invalidateCache();
|
|
66
|
+
this.text = title;
|
|
67
67
|
this.originalTextStyle = __assign({}, originalTextStyle);
|
|
68
68
|
this.textStyle = (0, TextStyle_1.adjustTextStyle)(originalTextStyle);
|
|
69
|
+
this.useNativeTextProperty = originalTextStyle.useNativeText;
|
|
70
|
+
this.titlePosition = originalTextStyle.position;
|
|
69
71
|
this.getTextSize(title, this.textStyle, renderContext);
|
|
70
72
|
}
|
|
71
73
|
else {
|
|
@@ -81,7 +83,7 @@ var ChartTitleRenderer = /** @class */ (function (_super) {
|
|
|
81
83
|
* @param chartViewRect - the container area which is used as an origin for title layout calculation
|
|
82
84
|
*/
|
|
83
85
|
ChartTitleRenderer.prototype.layout = function (chartViewRect) {
|
|
84
|
-
if (!this.text) {
|
|
86
|
+
if (!this.text || this.text.length === 0) {
|
|
85
87
|
this.viewRectProperty = undefined;
|
|
86
88
|
return;
|
|
87
89
|
}
|
|
@@ -91,29 +93,21 @@ var ChartTitleRenderer = /** @class */ (function (_super) {
|
|
|
91
93
|
* Performs rendering of the title
|
|
92
94
|
*/
|
|
93
95
|
ChartTitleRenderer.prototype.draw = function (renderContext) {
|
|
94
|
-
if (!this.text) {
|
|
96
|
+
if (!this.text || this.text.length === 0) {
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
99
|
if (SciChartSurfaceBase_1.DebugForDpi) {
|
|
98
100
|
console.log("ChartTitleRenderer.draw fontSize: ".concat(this.textStyle.fontSize));
|
|
99
101
|
}
|
|
100
102
|
var _a = this.textStyle, useNativeText = _a.useNativeText, position = _a.position, lineSpacing = _a.lineSpacing;
|
|
101
|
-
this.drawInternal(renderContext, useNativeText, position
|
|
103
|
+
this.drawInternal(renderContext, useNativeText, position);
|
|
102
104
|
if (this.drawDebug) {
|
|
103
105
|
this.drawTitleDebugViewRect(renderContext);
|
|
104
106
|
}
|
|
105
107
|
};
|
|
106
108
|
ChartTitleRenderer.prototype.getTitleTexture = function () {
|
|
107
109
|
var position = this.textStyle.position;
|
|
108
|
-
var adjRotation = 0;
|
|
109
|
-
// let adjRotation = this.textStyle.rotation;
|
|
110
|
-
if (position === TextStyle_1.ETitlePosition.Left) {
|
|
111
|
-
adjRotation += -90;
|
|
112
|
-
}
|
|
113
|
-
else if (position === TextStyle_1.ETitlePosition.Right) {
|
|
114
|
-
adjRotation += 90;
|
|
115
|
-
}
|
|
116
|
-
// TODO try using rotation property here
|
|
110
|
+
var adjRotation = (0, TitleRenderer_1.getAdjustedRotation)(this.textStyle.rotation, position);
|
|
117
111
|
var titleText = Array.isArray(this.text) ? this.text : this.text.split("\n");
|
|
118
112
|
var texture = this.textureManager.createTextTexture(titleText,
|
|
119
113
|
// @ts-ignore mismatch with TTextStyle
|
|
@@ -122,39 +116,11 @@ var ChartTitleRenderer = /** @class */ (function (_super) {
|
|
|
122
116
|
adjRotation, this.textStyle.lineSpacing);
|
|
123
117
|
return texture;
|
|
124
118
|
};
|
|
125
|
-
/**
|
|
126
|
-
* Calculates width and hight of the title text
|
|
127
|
-
*/
|
|
128
|
-
ChartTitleRenderer.prototype.getTextSize = function (title, textStyle, renderContext) {
|
|
129
|
-
if (title === void 0) { title = ""; }
|
|
130
|
-
var hasHorizontalPlacement = (0, TextStyle_1.getIsHorizontalPlacement)(textStyle.position);
|
|
131
|
-
if (textStyle.useNativeText) {
|
|
132
|
-
// @ts-ignore mismatch with TTextStyle
|
|
133
|
-
var nativeFont = renderContext.getFont(textStyle, !hasHorizontalPlacement);
|
|
134
|
-
var titleString = Array.isArray(title) ? title.join("\n") : title;
|
|
135
|
-
var _a = (0, text_1.getNativeTextSize)(titleString, nativeFont, textStyle, this.webAssemblyContext), textHeight = _a.textHeight, textWidth = _a.textWidth, nativeLineSpacing = _a.nativeLineSpacing, firstLineAscent = _a.firstLineAscent;
|
|
136
|
-
this.textHeight = textHeight;
|
|
137
|
-
this.textWidth = textWidth;
|
|
138
|
-
this.nativeLineSpacing = nativeLineSpacing;
|
|
139
|
-
this.firstLineAscent = firstLineAscent;
|
|
140
|
-
this.desiredHeightProperty = hasHorizontalPlacement ? this.textHeight : this.textWidth;
|
|
141
|
-
this.desiredWidthProperty = hasHorizontalPlacement ? this.textWidth : this.textHeight;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
// current title texture doesn't include paddings, so they should be added here
|
|
145
|
-
var texture = this.getTitleTexture();
|
|
146
|
-
this.texture = texture;
|
|
147
|
-
this.desiredHeightProperty = texture.textureHeight;
|
|
148
|
-
this.desiredWidthProperty = texture.textureWidth;
|
|
149
|
-
this.textHeight = hasHorizontalPlacement ? this.desiredHeightProperty : this.desiredWidthProperty;
|
|
150
|
-
this.textWidth = hasHorizontalPlacement ? this.desiredWidthProperty : this.desiredHeightProperty;
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
119
|
/**
|
|
154
120
|
* Calculates the {@link ChartTitleRenderer.titleOffset}
|
|
155
121
|
*/
|
|
156
122
|
ChartTitleRenderer.prototype.getTitleOffset = function (title, textStyle) {
|
|
157
|
-
if (!
|
|
123
|
+
if (!this.text || this.text.length === 0 || textStyle.placeWithinChart) {
|
|
158
124
|
return Thickness_1.Thickness.fromNumber(0);
|
|
159
125
|
}
|
|
160
126
|
var height = this.textHeight;
|
|
@@ -4,7 +4,7 @@ import { Rect } from "../../Core/Rect";
|
|
|
4
4
|
import { Thickness } from "../../Core/Thickness";
|
|
5
5
|
import { ETextAlignment, ETitlePosition, TChartTitleStyle } from "../../types/TextStyle";
|
|
6
6
|
import { WebGlRenderContext2D } from "../Drawing/WebGlRenderContext2D";
|
|
7
|
-
import {
|
|
7
|
+
import { TAxisTitleStyle } from "../Visuals/Axis/AxisCore";
|
|
8
8
|
import { TSciChart } from "../Visuals/SciChartSurface";
|
|
9
9
|
import { INotifyOnDpiChanged, TDpiChangedEventArgs } from "../Visuals/TextureManager/DpiHelper";
|
|
10
10
|
import { TextureManager, TTextureObject } from "../Visuals/TextureManager/TextureManager";
|
|
@@ -18,7 +18,7 @@ export interface IChartTitleRenderer extends ITitleRenderer {
|
|
|
18
18
|
titleOffset: Thickness;
|
|
19
19
|
measure(title: string | string[], originalTextStyle: Required<TChartTitleStyle>, renderContext: WebGlRenderContext2D): void;
|
|
20
20
|
}
|
|
21
|
-
export declare class TitleRendererBase<TextStyleType extends
|
|
21
|
+
export declare class TitleRendererBase<TextStyleType extends TAxisTitleStyle | TChartTitleStyle> implements ITitleRenderer {
|
|
22
22
|
/**
|
|
23
23
|
* Defines a bounding {@link Rect} containing the title text
|
|
24
24
|
*/
|
|
@@ -28,7 +28,7 @@ export declare class TitleRendererBase<TextStyleType extends TTextStyle | TChart
|
|
|
28
28
|
/**
|
|
29
29
|
* Current title
|
|
30
30
|
*/
|
|
31
|
-
text: string | string[];
|
|
31
|
+
protected text: string | string[];
|
|
32
32
|
protected viewRectProperty: Rect;
|
|
33
33
|
protected webAssemblyContext: TSciChart;
|
|
34
34
|
protected textureManager: TextureManager;
|
|
@@ -63,8 +63,10 @@ export declare class TitleRendererBase<TextStyleType extends TTextStyle | TChart
|
|
|
63
63
|
protected texture: TTextureObject;
|
|
64
64
|
/** The line spacing for native text calculated during measure */
|
|
65
65
|
protected nativeLineSpacing: number;
|
|
66
|
-
|
|
67
|
-
protected
|
|
66
|
+
protected nativeTextShiftX: number;
|
|
67
|
+
protected nativeTextShiftY: number;
|
|
68
|
+
protected useNativeTextProperty: boolean;
|
|
69
|
+
protected titlePosition: ETitlePosition;
|
|
68
70
|
constructor(webAssemblyContext: TSciChart);
|
|
69
71
|
measure(...params: any[]): void;
|
|
70
72
|
layout(originRect: Rect): void;
|
|
@@ -76,9 +78,14 @@ export declare class TitleRendererBase<TextStyleType extends TTextStyle | TChart
|
|
|
76
78
|
/**
|
|
77
79
|
* Performs rendering of the title
|
|
78
80
|
*/
|
|
79
|
-
protected drawInternal(renderContext: WebGlRenderContext2D, useNativeText: boolean, titlePosition: ETitlePosition
|
|
81
|
+
protected drawInternal(renderContext: WebGlRenderContext2D, useNativeText: boolean, titlePosition: ETitlePosition): void;
|
|
80
82
|
protected drawWithNativeText(renderContext: WebGlRenderContext2D, position: ETitlePosition): void;
|
|
81
83
|
protected drawWithTexture(renderContext: WebGlRenderContext2D, titlePosition: ETitlePosition): void;
|
|
84
|
+
/**
|
|
85
|
+
* Calculates width and hight of the title text
|
|
86
|
+
*/
|
|
87
|
+
protected getTextSize(title: string | string[], textStyle: TChartTitleStyle, renderContext: WebGlRenderContext2D): void;
|
|
88
|
+
protected getTitleTexture(): TTextureObject;
|
|
82
89
|
/**
|
|
83
90
|
* Calculates the {@link TitleRenderer.viewRect}
|
|
84
91
|
*/
|
|
@@ -89,3 +96,4 @@ export declare class TitleRendererBase<TextStyleType extends TTextStyle | TChart
|
|
|
89
96
|
*/
|
|
90
97
|
private getAlignmentAdjustmentDelta;
|
|
91
98
|
}
|
|
99
|
+
export declare const getAdjustedRotation: (rotation: number, position: ETitlePosition) => number;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TitleRendererBase = void 0;
|
|
3
|
+
exports.getAdjustedRotation = exports.TitleRendererBase = void 0;
|
|
4
|
+
var app_1 = require("../../constants/app");
|
|
4
5
|
var Deleter_1 = require("../../Core/Deleter");
|
|
5
6
|
var Rect_1 = require("../../Core/Rect");
|
|
6
7
|
var TextPosition_1 = require("../../types/TextPosition");
|
|
7
8
|
var TextStyle_1 = require("../../types/TextStyle");
|
|
8
9
|
var parseColor_1 = require("../../utils/parseColor");
|
|
10
|
+
var text_1 = require("../../utils/text");
|
|
9
11
|
var createNativeRect_1 = require("../Visuals/Helpers/createNativeRect");
|
|
10
12
|
var NativeObject_1 = require("../Visuals/Helpers/NativeObject");
|
|
11
13
|
var DpiHelper_1 = require("../Visuals/TextureManager/DpiHelper");
|
|
@@ -31,6 +33,7 @@ var TitleRendererBase = /** @class */ (function () {
|
|
|
31
33
|
* The width taken by the text considering current orientation orientation including padding
|
|
32
34
|
*/
|
|
33
35
|
this.desiredWidthProperty = 0;
|
|
36
|
+
this.useNativeTextProperty = false;
|
|
34
37
|
this.webAssemblyContext = webAssemblyContext;
|
|
35
38
|
this.textureManager = new TextureManager_1.TextureManager(webAssemblyContext);
|
|
36
39
|
this.onDpiChanged = this.onDpiChanged.bind(this);
|
|
@@ -66,12 +69,11 @@ var TitleRendererBase = /** @class */ (function () {
|
|
|
66
69
|
};
|
|
67
70
|
TitleRendererBase.prototype.resetCache = function () {
|
|
68
71
|
this.invalidateCache();
|
|
72
|
+
this.textStyle = undefined;
|
|
73
|
+
this.originalTextStyle = undefined;
|
|
69
74
|
};
|
|
70
75
|
TitleRendererBase.prototype.invalidateCache = function () {
|
|
71
76
|
var _a;
|
|
72
|
-
this.text = undefined;
|
|
73
|
-
this.textStyle = undefined;
|
|
74
|
-
this.originalTextStyle = undefined;
|
|
75
77
|
(0, Deleter_1.deleteSafe)((_a = this.texture) === null || _a === void 0 ? void 0 : _a.bitmapTexture);
|
|
76
78
|
this.texture = undefined;
|
|
77
79
|
};
|
|
@@ -81,8 +83,8 @@ var TitleRendererBase = /** @class */ (function () {
|
|
|
81
83
|
/**
|
|
82
84
|
* Performs rendering of the title
|
|
83
85
|
*/
|
|
84
|
-
TitleRendererBase.prototype.drawInternal = function (renderContext, useNativeText, titlePosition
|
|
85
|
-
if (!this.text) {
|
|
86
|
+
TitleRendererBase.prototype.drawInternal = function (renderContext, useNativeText, titlePosition) {
|
|
87
|
+
if (!this.text || this.text.length === 0) {
|
|
86
88
|
return;
|
|
87
89
|
}
|
|
88
90
|
if (useNativeText) {
|
|
@@ -101,20 +103,9 @@ var TitleRendererBase = /** @class */ (function () {
|
|
|
101
103
|
var nativeFont = renderContext.getFont(this.textStyle, true);
|
|
102
104
|
// calculate start coordinates for native text drawing;
|
|
103
105
|
// the start point is the beginning of alphabetic text baseline
|
|
104
|
-
var tx = this.viewRect.left + this.
|
|
105
|
-
var ty = this.viewRect.top + this.
|
|
106
|
-
var adjRotation = 0;
|
|
107
|
-
// let adjRotation = this.textStyle.rotation;
|
|
108
|
-
if (position === TextStyle_1.ETitlePosition.Left) {
|
|
109
|
-
adjRotation += -90;
|
|
110
|
-
tx = this.viewRect.left + this.textStyle.padding.top + this.firstLineAscent;
|
|
111
|
-
ty = this.viewRect.bottom - this.textStyle.padding.left;
|
|
112
|
-
}
|
|
113
|
-
else if (position === TextStyle_1.ETitlePosition.Right) {
|
|
114
|
-
adjRotation += 90;
|
|
115
|
-
tx = this.viewRect.right - this.textStyle.padding.top - this.firstLineAscent;
|
|
116
|
-
ty = this.viewRect.top + this.textStyle.padding.left;
|
|
117
|
-
}
|
|
106
|
+
var tx = this.viewRect.left + this.nativeTextShiftX;
|
|
107
|
+
var ty = this.viewRect.top + this.nativeTextShiftY;
|
|
108
|
+
var adjRotation = (0, exports.getAdjustedRotation)(this.textStyle.rotation, position);
|
|
118
109
|
var rotationRad = -(adjRotation * Math.PI) / 180;
|
|
119
110
|
var nativeMultilineAlignment = (0, TextPosition_1.convertMultiLineAlignment)(this.textStyle.multilineAlignment, this.webAssemblyContext);
|
|
120
111
|
var textColor = (0, parseColor_1.parseColorToUIntArgb)(this.textStyle.color);
|
|
@@ -138,12 +129,71 @@ var TitleRendererBase = /** @class */ (function () {
|
|
|
138
129
|
}
|
|
139
130
|
}
|
|
140
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* Calculates width and hight of the title text
|
|
134
|
+
*/
|
|
135
|
+
TitleRendererBase.prototype.getTextSize = function (title, textStyle, renderContext) {
|
|
136
|
+
if (title === void 0) { title = ""; }
|
|
137
|
+
if (!title || title.length === 0) {
|
|
138
|
+
this.desiredHeightProperty = 0;
|
|
139
|
+
this.desiredWidthProperty = 0;
|
|
140
|
+
this.textHeight = 0;
|
|
141
|
+
this.textWidth = 0;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
var hasHorizontalPlacement = (0, TextStyle_1.getIsHorizontalPlacement)(this.titlePosition);
|
|
145
|
+
if (this.useNativeTextProperty) {
|
|
146
|
+
// @ts-ignore mismatch with TTextStyle
|
|
147
|
+
var nativeFont = renderContext.getFont(textStyle, !hasHorizontalPlacement);
|
|
148
|
+
var titleString = Array.isArray(title) ? title.join("\n") : title;
|
|
149
|
+
var adjRotation = (0, exports.getAdjustedRotation)(textStyle.rotation, this.titlePosition);
|
|
150
|
+
var _a = (0, text_1.getNativeTextSize)(titleString, nativeFont, textStyle, this.webAssemblyContext, adjRotation), textHeight = _a.textHeight, textWidth = _a.textWidth, nativeLineSpacing = _a.nativeLineSpacing, deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
151
|
+
this.textHeight = hasHorizontalPlacement ? textHeight : textWidth;
|
|
152
|
+
this.textWidth = hasHorizontalPlacement ? textWidth : textHeight;
|
|
153
|
+
this.nativeLineSpacing = nativeLineSpacing;
|
|
154
|
+
this.nativeTextShiftX = deltaX;
|
|
155
|
+
this.nativeTextShiftY = deltaY;
|
|
156
|
+
this.desiredHeightProperty = hasHorizontalPlacement ? this.textHeight : this.textWidth;
|
|
157
|
+
this.desiredWidthProperty = hasHorizontalPlacement ? this.textWidth : this.textHeight;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// current title texture doesn't include paddings, so they should be added here
|
|
161
|
+
var texture = this.getTitleTexture();
|
|
162
|
+
this.texture = texture;
|
|
163
|
+
this.desiredHeightProperty = texture.textureHeight;
|
|
164
|
+
this.desiredWidthProperty = texture.textureWidth;
|
|
165
|
+
this.textHeight = hasHorizontalPlacement ? this.desiredHeightProperty : this.desiredWidthProperty;
|
|
166
|
+
this.textWidth = hasHorizontalPlacement ? this.desiredWidthProperty : this.desiredHeightProperty;
|
|
167
|
+
}
|
|
168
|
+
if (app_1.IS_TEST_ENV) {
|
|
169
|
+
if (hasHorizontalPlacement) {
|
|
170
|
+
this.desiredHeightProperty =
|
|
171
|
+
(0, TextureManager_1.measureTextHeight)(textStyle.fontSize) + this.textStyle.padding.top + this.textStyle.padding.bottom;
|
|
172
|
+
this.desiredWidthProperty = 0;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
this.desiredHeightProperty = 0;
|
|
176
|
+
this.desiredWidthProperty =
|
|
177
|
+
(0, TextureManager_1.measureTextHeight)(textStyle.fontSize) + this.textStyle.padding.top + this.textStyle.padding.bottom;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
TitleRendererBase.prototype.getTitleTexture = function () {
|
|
182
|
+
// TODO this is not used at the moment; consider unifying logic for Chart Title Renderer and Axis Title Renderer
|
|
183
|
+
var titleText = Array.isArray(this.text) ? this.text : this.text.split("\n");
|
|
184
|
+
var texture = this.textureManager.createTextTexture(titleText,
|
|
185
|
+
// @ts-ignore mismatch with TTextStyle
|
|
186
|
+
this.textStyle
|
|
187
|
+
// { ...this.textStyle, padding: new Thickness(0, 0, 0, 0) },
|
|
188
|
+
);
|
|
189
|
+
return texture;
|
|
190
|
+
};
|
|
141
191
|
/**
|
|
142
192
|
* Calculates the {@link TitleRenderer.viewRect}
|
|
143
193
|
*/
|
|
144
194
|
TitleRendererBase.prototype.getViewRect = function (title, originRect, titlePosition, alignment) {
|
|
145
195
|
if (title === void 0) { title = ""; }
|
|
146
|
-
if (!title) {
|
|
196
|
+
if (!title || title.length === 0) {
|
|
147
197
|
return Rect_1.Rect.createZero();
|
|
148
198
|
}
|
|
149
199
|
var hasHorizontalPlacement = (0, TextStyle_1.getIsHorizontalPlacement)(titlePosition);
|
|
@@ -188,3 +238,17 @@ var TitleRendererBase = /** @class */ (function () {
|
|
|
188
238
|
return TitleRendererBase;
|
|
189
239
|
}());
|
|
190
240
|
exports.TitleRendererBase = TitleRendererBase;
|
|
241
|
+
var getAdjustedRotation = function (rotation, position) {
|
|
242
|
+
if (rotation !== undefined) {
|
|
243
|
+
return (rotation + 360) % 360;
|
|
244
|
+
}
|
|
245
|
+
var adjustedRotation = 0;
|
|
246
|
+
if (position === TextStyle_1.ETitlePosition.Left) {
|
|
247
|
+
adjustedRotation += -90;
|
|
248
|
+
}
|
|
249
|
+
else if (position === TextStyle_1.ETitlePosition.Right) {
|
|
250
|
+
adjustedRotation += 90;
|
|
251
|
+
}
|
|
252
|
+
return (adjustedRotation + 360) % 360;
|
|
253
|
+
};
|
|
254
|
+
exports.getAdjustedRotation = getAdjustedRotation;
|
|
@@ -175,6 +175,8 @@ var OverviewCustomResizableAnnotation = /** @class */ (function (_super) {
|
|
|
175
175
|
*/
|
|
176
176
|
OverviewCustomResizableAnnotation.prototype.onDragStarted = function (args) {
|
|
177
177
|
var _a;
|
|
178
|
+
// handles default browser dragging behavior when canvas was selected with Ctrl + A
|
|
179
|
+
args.nativeEvent.preventDefault();
|
|
178
180
|
(_a = this.dragStarted) === null || _a === void 0 ? void 0 : _a.raiseEvent();
|
|
179
181
|
var _b = this.getAnnotationBorders(true), x1 = _b.x1, x2 = _b.x2, y1 = _b.y1, y2 = _b.y2;
|
|
180
182
|
var xyMousePoint = (0, translate_1.translateFromCanvasToSeriesViewRect)(new Point_1.Point(args.mousePoint.x, args.mousePoint.y), this.parentSurface.seriesViewRect, true);
|