Skip to content

Commit

Permalink
feat: try to avoid removing github workflows during copybara sync pro…
Browse files Browse the repository at this point in the history
…cess

GitOrigin-RevId: 117526e30f34afa42222a951358aad21f6dc5611
  • Loading branch information
dxpm authored and dxcity committed Feb 5, 2025
1 parent 1dd8198 commit a1d52c7
Show file tree
Hide file tree
Showing 41 changed files with 233 additions and 767 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devexperts/dxcharts-lite",
"version": "2.7.0",
"version": "2.5.8",
"description": "DXCharts Lite",
"author": "Devexperts Solutions IE Limited",
"license": "MPL 2.0",
Expand Down
2 changes: 0 additions & 2 deletions src/chart/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ export default class ChartBootstrap {
this.canvasBoundsContainer,
this.paneManager,
timeZoneModel,
chartPanComponent.mainCanvasTouchHandler,
formatterFactory,
);
this.chartComponents.push(this.hoverProducer);
Expand All @@ -519,7 +518,6 @@ export default class ChartBootstrap {
paneManager,
this.crossEventProducer,
this.hoverProducer,
this.chartComponent.baselineModel,
);

this.chartComponents.push(this.crossToolComponent);
Expand Down
22 changes: 7 additions & 15 deletions src/chart/canvas/canvas-bounds-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ const N_MAP_BUTTON_W = 15;
const KNOTS_W_MOBILE_MULTIPLIER = 1.5;
const N_MAP_KNOT_W = isMobile() ? 8 * KNOTS_W_MOBILE_MULTIPLIER : 8;

// additional x axis height padding for mobiles, used for better usability on mobile devices
export const X_AXIS_MOBILE_PADDING = isMobile() ? 5 : 0;

/**
* we need to check that: heightRatios - 1 < 0.000001 after calculations between decimals
*/
Expand Down Expand Up @@ -469,8 +466,7 @@ export class CanvasBoundsContainer {
this.xAxisHeight =
fontHeight +
(this.config.components.xAxis.padding.top ?? 0) +
(this.config.components.xAxis.padding.bottom ?? 0) +
X_AXIS_MOBILE_PADDING;
(this.config.components.xAxis.padding.bottom ?? 0);
}
return this.xAxisHeight;
}
Expand Down Expand Up @@ -555,11 +551,11 @@ export class CanvasBoundsContainer {
}

//#region chart height ratio logic
if (!this.graphsHeightRatio[CHART_UUID] || this.graphsHeightRatio[CHART_UUID] === 0) {
if (this.graphsHeightRatio[CHART_UUID] === 0) {
chartRatio = 0;
}

if (this.graphsHeightRatio[CHART_UUID] && this.graphsHeightRatio[CHART_UUID] !== 0) {
if (this.graphsHeightRatio[CHART_UUID] !== 0) {
if (paneIsAdded) {
chartRatio = 1 * ratioForOldPec;
} else {
Expand Down Expand Up @@ -764,10 +760,10 @@ export class CanvasBoundsContainer {
/**
* Gets hit-test fn for canvas element.
* @param {string} el - CanvasElement.ELEMENT_NAME
* @param {Object} options - An object containing options for the hit test.
* @param {number} [options.extensionX=0] - The amount of extension in the x-axis.
* @param {number} [options.extensionY=0] - The amount of extension in the y-axis.
* @param {boolean} [options.wholePage=false] - Whether to test against the whole page or just the bounds object.
* @param {boolean} reverse - reverses the hit test condition
* @param {number} extensionX - extended hitBoundsTest in horizontal direction
* @param {number} extensionY - extended hitBoundsTest in vertical direction
* @param wholePage
* @return {HitBoundsTest} hit-test fn
*/
getBoundsHitTest(el: string, options: AtLeastOne<HitBoundsTestOptions> = DEFAULT_HIT_TEST_OPTIONS): HitBoundsTest {
Expand Down Expand Up @@ -838,10 +834,6 @@ export class CanvasBoundsContainer {
return canvasBounds.width > 0 && canvasBounds.height > 0;
}

public isAllBoundsAvailable() {
return Object.values(this.bounds).every(el => el.width >= 0 && el.height >= 0);
}

/**
* Resizes a pane vertically.
* @param {string} uuid - The unique identifier of the pane.
Expand Down
83 changes: 20 additions & 63 deletions src/chart/chart.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { DateTimeFormatter, TimeFormatterConfig } from './model/date-time.format
import { DEFAULT_MERGE_OPTIONS, merge, MergeOptions } from './utils/merge.utils';
import { DeepPartial } from './utils/object.utils';
import { Candle, defaultSortCandles } from './model/candle.model';
import { CustomIcon } from './components/events/events-custom-icons';

export const MAIN_FONT = 'Open Sans Semibold, sans-serif';

Expand Down Expand Up @@ -111,7 +110,6 @@ export const getDefaultConfig = (): FullChartConfig => ({
histogram: {
barCapSize: 1,
},
maxYAxisScalesAmount: 10,
sortCandles: defaultSortCandles,
},
yAxis: {
Expand Down Expand Up @@ -233,7 +231,7 @@ export const getDefaultConfig = (): FullChartConfig => ({
logoWidth: 20,
logoHeight: 20,
},
highLow: { visible: false, font: '12px sans-serif', prefix: { high: 'H: ', low: 'L: ' } },
highLow: { visible: false, font: '12px sans-serif' },
highlights: {
visible: false,
fontFamily: 'Open Sans',
Expand Down Expand Up @@ -427,35 +425,15 @@ export const getDefaultConfig = (): FullChartConfig => ({
highLowTheme: { highColor: 'rgba(223,222,223,1)', lowColor: 'rgba(223,222,223,1)' },
instrumentInfo: { textColor: '#aeb1b3' },
paneResizer: {
lineColor: 'rgba(61,61,61,1)',
lineColor: 'rgba(55,55,54,1)',
bgColor: 'rgba(20,20,19,1)',
bgHoverColor: 'rgba(55,55,54,0.6)',
},
events: {
earnings: {
color: 'rgba(217,44,64,1)',
normal: 'rgba(217,44,64,1)',
hover: 'rgba(217,44,64,1)',
line: 'rgba(217,44,64,1)',
},
dividends: {
color: 'rgba(169,38,251,1)',
normal: 'rgba(169,38,251,1)',
hover: 'rgba(169,38,251,1)',
line: 'rgba(169,38,251,1)',
},
splits: {
color: 'rgba(244,187,63,1)',
normal: 'rgba(244,187,63,1)',
hover: 'rgba(244,187,63,1)',
line: 'rgba(244,187,63,1)',
},
'conference-calls': {
color: 'rgba(48,194,97,1)',
normal: 'rgba(48,194,97,1)',
hover: 'rgba(48,194,97,1)',
line: 'rgba(48,194,97,1)',
},
earnings: { color: 'rgba(217,44,64,1)' },
dividends: { color: 'rgba(169,38,251,1)' },
splits: { color: 'rgba(244,187,63,1)' },
'conference-calls': { color: 'rgba(48,194,97,1)' },
},
secondaryChartTheme: [
{
Expand Down Expand Up @@ -793,7 +771,12 @@ export interface FullChartColors {
labelBoxColor: string;
labelTextColor: string;
};
events: ChartConfigComponentsEventsColors;
events: {
earnings: EventColors;
dividends: EventColors;
splits: EventColors;
'conference-calls': EventColors;
};
navigationMap: {
buttonColor: string;
knotColor: string;
Expand Down Expand Up @@ -996,10 +979,6 @@ export interface ChartConfigComponentsChart {
selectedWidth: number;
minCandlesOffset: number;
histogram: ChartConfigComponentsHistogram;
/**
* The maximum amount of Y axis scales on a single chart
*/
maxYAxisScalesAmount: number;
// optional because backward compability
sortCandles?: (candles: Candle[]) => Candle[];
}
Expand Down Expand Up @@ -1032,17 +1011,6 @@ export interface ChartConfigComponentsEvents {
* </svg>'
*/
icons?: ChartConfigComponentsEventsIcons;
/**
* Configure the event type vertical line appearance
*/
line?: ChartConfigComponentsEventsLine;
}

export interface ChartConfigComponentsEventsColors {
earnings: EventColors;
dividends: EventColors;
splits: EventColors;
'conference-calls': EventColors;
}

export interface DateTimeFormatConfig {
Expand Down Expand Up @@ -1180,7 +1148,6 @@ export interface ChartConfigComponentsHighLow {
* Font config of high/low labels.
*/
font: string;
prefix: { high: string; low: string };
}
export interface ChartConfigComponentsCrossTool {
/**
Expand Down Expand Up @@ -1370,19 +1337,10 @@ export interface HighlightsColors {
label: string;
}

/**
* @deprecated use {normal}, {hover} instead, will be removed in v6
*/
export interface EventColorsOld {
export interface EventColors {
color: string;
}

export interface EventColors extends EventColorsOld {
line?: string;
normal?: string;
hover?: string;
}

export interface HistogramColors {
upCap: string;
upBottom: string;
Expand Down Expand Up @@ -1511,19 +1469,18 @@ export interface YAxisLabelsColors extends Record<YAxisLabelType, Record<string,
prePostMarket: YAxisPrePostMarketLabelColorConfig;
prevDayClose: YAxisLabelColorConfig;
}
//#endregion

export interface CustomIcon {
normal: string;
hover: string;
}

export interface ChartConfigComponentsEventsIcons {
earnings?: CustomIcon;
dividends?: CustomIcon;
splits?: CustomIcon;
'conference-calls'?: CustomIcon;
}

export interface ChartConfigComponentsEventsLine {
earnings?: { width: number; dash: Array<number> };
dividends?: { width: number; dash: Array<number> };
splits?: { width: number; dash: Array<number> };
'conference-calls'?: { width: number; dash: Array<number> };
conferenceCalls?: CustomIcon;
}

export type CursorType = string;
Expand Down
3 changes: 0 additions & 3 deletions src/chart/components/chart/candle.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const prepareCandle = (candle: PartialCandle): Candle | undefined => {
const preparedCandleLo = finite(candle.lo, Math.min(candle.open, candle.close), settlementPrice);
const preparedCandleOpen = finite(candle.open, candle.lo, settlementPrice);
const preparedCandleClose = finite(candle.close, candle.hi, settlementPrice);
const preparedVwap = Number.isNaN(candle.vwap) ? undefined : candle.vwap;
return {
id: candle.id,
hi: preparedCandleHi,
Expand All @@ -36,7 +35,6 @@ export const prepareCandle = (candle: PartialCandle): Candle | undefined => {
expansion: candle.expansion,
idx: candle.idx,
impVolatility: candle.impVolatility,
vwap: preparedVwap,
};
} catch (e) {
console.warn(e);
Expand All @@ -47,7 +45,6 @@ export const prepareCandle = (candle: PartialCandle): Candle | undefined => {
/**
* Adds index to candles according to their array index.
* @param candles
* @param startIdx {number}
*/
export const reindexCandles = (candles: Array<Candle>, startIdx: number = 0) => {
for (let i = startIdx; i < candles.length; ++i) {
Expand Down
15 changes: 5 additions & 10 deletions src/chart/components/chart/chart-area-pan.handler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/*
* Copyright (C) 2019 - 2024 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
Expand Down Expand Up @@ -52,7 +47,8 @@ interface ChartPanningOptions {
* @param {CanvasBoundsContainer} canvasBoundsContainer - An instance of the CanvasBoundsContainer class.
* @param {CanvasAnimation} canvasAnimation - An instance of the CanvasAnimation class.
* @param {ChartPanComponent} chartPanComponent - An instance of the ChartPanComponent class.
*/
*/
export class ChartAreaPanHandler extends ChartBaseElement {
private currentPoint: Point = { x: 0, y: 0 };
// number of candles delta changed during X dragging: 1, 5 or -3 for ex.
Expand Down Expand Up @@ -102,7 +98,6 @@ export class ChartAreaPanHandler extends ChartBaseElement {
* If the zoomToCursor configuration is set to false, it calls the zoomXToEnd method of the scaleModel to zoom in or out based on the zoomIn parameter.
* Finally, it fires the draw event of the bus to redraw the canvas.
* @param {WheelEvent} e - Wheel event
* @param {number} zoomSensitivity - zoom sensitivity
* @returns {void}
*/
private zoomXHandler = (e: WheelEvent, zoomSensitivity: number) => {
Expand Down Expand Up @@ -142,9 +137,9 @@ export class ChartAreaPanHandler extends ChartBaseElement {
)
.subscribe(e => {
const device = deviceDetector();
const direction = device === 'apple' || device === 'mobile' ? -1 : 1;
const direction = device === 'apple' || device === 'mobile' ? 1 : -1;
const deltaX = 0 + e.deltaX * direction;
const deltaY = 0 + e.deltaY * direction;
const deltaY = 0 + e.deltaY * -direction;

if (e.ctrlKey) {
const zoomSensitivity = this.calculateDynamicSesitivity(
Expand Down Expand Up @@ -197,7 +192,7 @@ export class ChartAreaPanHandler extends ChartBaseElement {

/**
* Registers a handler for panning the chart along the Y-axis.
* @param {ScaleModel} scale - The scale model of the extent.
* @param {ScaleModel} scaleModel - The scale model of the extent.
* @param {HitBoundsTest} hitTest - The hit test of the pane.
* @returns {DragNDropYComponent} - The drag and drop component for panning the chart along the Y-axis.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/chart/components/chart/chart.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export class ChartModel extends ChartBaseElement {
const nextChartWidth = this.canvasBoundsContainer.getEffectiveChartWidth();
const nextYAxisWidth = this.canvasBoundsContainer.getEffectiveYAxisWidth();

if (this.prevChartWidth === 0 && this.scale) {
this.scale.isViewportValid(false) && this.scale.recalculateZoom();
if (this.prevChartWidth === 0) {
this.scale.isViewportValid() ? this.scale.recalculateZoom() : this.doBasicScale();
this.prevChartWidth = nextChartWidth;
this.prevYWidth = nextYAxisWidth;
return;
Expand Down
19 changes: 5 additions & 14 deletions src/chart/components/cross_tool/cross-tool.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { CompositeDrawer } from '../../drawers/composite.drawer';
import { DrawingManager } from '../../drawers/drawing-manager';
import { CrossEventProducerComponent } from '../../inputhandlers/cross-event-producer.component';
import { HoverProducerComponent } from '../../inputhandlers/hover-producer.component';
import { BaselineModel } from '../../model/baseline.model';
import { CanvasModel } from '../../model/canvas.model';
import { ChartBaseElement } from '../../model/chart-base-element';
import { PaneManager } from '../pane/pane-manager.component';
Expand All @@ -33,28 +32,20 @@ export class CrossToolComponent extends ChartBaseElement {
private canvasBoundsContainer: CanvasBoundsContainer,
private drawingManager: DrawingManager,
private paneManager: PaneManager,
private crossEventProducer: CrossEventProducerComponent,
private hoverProducer: HoverProducerComponent,
private baselineModel: BaselineModel,
crossEventProducer: CrossEventProducerComponent,
hoverProducer: HoverProducerComponent,
) {
super();
this.model = new CrossToolModel(
config.components.crossTool,
this.crossToolCanvasModel,
this.crossEventProducer,
this.hoverProducer,
this.canvasBoundsContainer,
this.baselineModel,
crossEventProducer,
hoverProducer,
);
this.addChildEntity(this.model);
const clearCanvasDrawer = new ClearCanvasDrawer(this.crossToolCanvasModel);
this.registerDefaultDrawerTypes();
const crossToolDrawer = new CrossToolDrawer(
this.model,
this.config,
this.crossToolCanvasModel,
this.crossToolTypeDrawers,
);
const crossToolDrawer = new CrossToolDrawer(this.model, this.crossToolCanvasModel, this.crossToolTypeDrawers);
const compositeDrawer = new CompositeDrawer();
compositeDrawer.addDrawer(clearCanvasDrawer, 'CLEAR_CANVAS');
compositeDrawer.addDrawer(crossToolDrawer, 'CROSS_TOOL_DRAWER');
Expand Down
Loading

0 comments on commit a1d52c7

Please sign in to comment.