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: 27eb53740385097c3b73ffde653b90710a6aa078
  • Loading branch information
dxpm authored and dxcity committed Jan 13, 2025
1 parent fbb42aa commit 4e21d6f
Show file tree
Hide file tree
Showing 27 changed files with 180 additions and 626 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.6.2",
"version": "2.5.8",
"description": "DXCharts Lite",
"author": "Devexperts Solutions IE Limited",
"license": "MPL 2.0",
Expand Down
1 change: 0 additions & 1 deletion 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 Down
14 changes: 5 additions & 9 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 @@ -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
93 changes: 20 additions & 73 deletions src/chart/chart.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
/*
* 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.
* 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.
* 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 All @@ -25,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 @@ -121,7 +110,6 @@ export const getDefaultConfig = (): FullChartConfig => ({
histogram: {
barCapSize: 1,
},
maxYAxisScalesAmount: 10,
sortCandles: defaultSortCandles,
},
yAxis: {
Expand Down Expand Up @@ -243,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 @@ -437,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 @@ -803,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 @@ -1006,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 @@ -1042,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 @@ -1190,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 @@ -1380,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 @@ -1521,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
9 changes: 4 additions & 5 deletions src/chart/components/chart/chart-area-pan.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ 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 };
Expand Down Expand Up @@ -98,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 @@ -138,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 @@ -193,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
8 changes: 1 addition & 7 deletions src/chart/components/cross_tool/cross-tool.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,11 @@ export class CrossToolComponent extends ChartBaseElement {
this.crossToolCanvasModel,
crossEventProducer,
hoverProducer,
this.canvasBoundsContainer,
);
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
8 changes: 2 additions & 6 deletions src/chart/components/cross_tool/cross-tool.drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { CanvasModel } from '../../model/canvas.model';
import { Drawer } from '../../drawers/drawing-manager';
import { CrossToolHover, CrossToolModel, CrossToolType } from './cross-tool.model';
import { FullChartConfig } from '../../chart.config';

export interface CrossToolTypeDrawer {
draw: (ctx: CanvasRenderingContext2D, hover: CrossToolHover) => void;
Expand All @@ -15,7 +14,6 @@ export interface CrossToolTypeDrawer {
export class CrossToolDrawer implements Drawer {
constructor(
private model: CrossToolModel,
private config: FullChartConfig,
private crossToolCanvasModel: CanvasModel,
private readonly crossToolTypeDrawers: Record<CrossToolType, CrossToolTypeDrawer>,
) {}
Expand All @@ -29,13 +27,11 @@ export class CrossToolDrawer implements Drawer {
* @returns {void}
*/
draw() {
const drawer = this.crossToolTypeDrawers[this.config.components.crossTool.type];
const drawer = this.crossToolTypeDrawers[this.model.type];
if (drawer) {
this.model.currentHover && drawer.draw(this.crossToolCanvasModel.ctx, this.model.currentHover);
} else {
console.error(
`No cross tool drawer type registered for drawer type ${this.config.components.crossTool.type}`,
);
console.error(`No cross tool drawer type registered for drawer type ${this.model.type}`);
}
}

Expand Down
Loading

0 comments on commit 4e21d6f

Please sign in to comment.