Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pane primitives #1660

Merged
merged 15 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default [
brotli: true,
},
{
name: 'Standalone-ESM',
name: 'ESM Standalone',
path: 'dist/lightweight-charts.standalone.production.mjs',
limit: '50.00 KB',
import: '*',
Expand All @@ -42,4 +42,20 @@ export default [
limit: '50.00 KB',
brotli: true,
},
{
name: 'Plugin: Text Watermark',
path: 'dist/lightweight-charts.production.mjs',
import: '{ TextWatermark }',
ignore: ['fancy-canvas'],
limit: '2.00 KB',
brotli: true,
},
{
name: 'Plugin: Image Watermark',
path: 'dist/lightweight-charts.production.mjs',
import: '{ ImageWatermark }',
ignore: ['fancy-canvas'],
limit: '2.00 KB',
brotli: true,
},
];
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@
"lint": "npm-run-all -p lint:**",
"lint:eslint": "eslint --format=unix ./",
"lint:md": "markdownlint -i \"**/node_modules/**\" -i \"**/website/docs/api/**\" -i \"**/website/versioned_docs/**/api/**\" -i \"**/*.mdx\" \"**/*.md\"",
"check-dts-docs": "eslint --format=unix ./dist/typings.d.ts --no-ignore",
"check-dts-docs": "npm-run-all -p check-dts-docs-duplicates check-dts-docs-eslint",
"check-dts-docs-duplicates": "node ./scripts/check-typings-for-duplicates.js ./dist/typings.d.ts",
"check-dts-docs-eslint": "eslint --format=unix ./dist/typings.d.ts --no-ignore",
"check-markdown-links": "node scripts/check-markdown-links.js",
"rollup": "rollup -c rollup.config.js",
"rollup-watch": "npm run rollup -- --watch",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CanvasRenderingTarget2D } from 'fancy-canvas';
import { ISeriesPrimitivePaneRenderer } from 'lightweight-charts';
import { IPrimitivePaneRenderer } from 'lightweight-charts';
import { positionsBox } from './helpers/dimensions/positions';

export class _CLASSNAME_AxisPaneRenderer implements ISeriesPrimitivePaneRenderer {
export class _CLASSNAME_AxisPaneRenderer implements IPrimitivePaneRenderer {
_p1: number | null;
_p2: number | null;
_fillColor: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
Coordinate,
ISeriesPrimitivePaneView,
SeriesPrimitivePaneViewZOrder,
IPrimitivePaneView,
PrimitivePaneViewZOrder,
} from 'lightweight-charts';
import { _CLASSNAME_AxisPaneRenderer } from './axis-pane-renderer';
import { _CLASSNAME_DataSource } from './data-source';

abstract class _CLASSNAME_AxisPaneView implements ISeriesPrimitivePaneView {
abstract class _CLASSNAME_AxisPaneView implements IPrimitivePaneView {
_source: _CLASSNAME_DataSource;
_p1: number | null = null;
_p2: number | null = null;
Expand All @@ -31,7 +31,7 @@ abstract class _CLASSNAME_AxisPaneView implements ISeriesPrimitivePaneView {
this._vertical
);
}
zOrder(): SeriesPrimitivePaneViewZOrder {
zOrder(): PrimitivePaneViewZOrder {
return 'bottom';
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CanvasRenderingTarget2D } from 'fancy-canvas';
import { ISeriesPrimitivePaneRenderer } from 'lightweight-charts';
import { IPrimitivePaneRenderer } from 'lightweight-charts';
import { ViewPoint } from './pane-view';
import { positionsBox } from './helpers/dimensions/positions';

export class _CLASSNAME_PaneRenderer implements ISeriesPrimitivePaneRenderer {
export class _CLASSNAME_PaneRenderer implements IPrimitivePaneRenderer {
_p1: ViewPoint;
_p2: ViewPoint;
_fillColor: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Coordinate, ISeriesPrimitivePaneView } from 'lightweight-charts';
import { Coordinate, IPrimitivePaneView } from 'lightweight-charts';
import { _CLASSNAME_PaneRenderer } from './pane-renderer';
import { _CLASSNAME_DataSource } from './data-source';

Expand All @@ -7,7 +7,7 @@ export interface ViewPoint {
y: Coordinate | null;
}

export class _CLASSNAME_PaneView implements ISeriesPrimitivePaneView {
export class _CLASSNAME_PaneView implements IPrimitivePaneView {
_source: _CLASSNAME_DataSource;
_p1: ViewPoint = { x: null, y: null };
_p2: ViewPoint = { x: null, y: null };
Expand Down
8 changes: 4 additions & 4 deletions plugin-examples/src/plugins/anchored-text/anchored-text.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CanvasRenderingTarget2D } from 'fancy-canvas';
import {
ISeriesPrimitive,
ISeriesPrimitivePaneRenderer,
ISeriesPrimitivePaneView,
IPrimitivePaneRenderer,
IPrimitivePaneView,
SeriesAttachedParameter,
Time,
} from 'lightweight-charts';
Expand All @@ -16,7 +16,7 @@ interface AnchoredTextOptions {
color: string;
}

class AnchoredTextRenderer implements ISeriesPrimitivePaneRenderer {
class AnchoredTextRenderer implements IPrimitivePaneRenderer {
_data: AnchoredTextOptions;

constructor(options: AnchoredTextOptions) {
Expand Down Expand Up @@ -61,7 +61,7 @@ class AnchoredTextRenderer implements ISeriesPrimitivePaneRenderer {
}
}

class AnchoredTextPaneView implements ISeriesPrimitivePaneView {
class AnchoredTextPaneView implements IPrimitivePaneView {
private _source: AnchoredText;
constructor(source: AnchoredText) {
this._source = source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
Coordinate,
DataChangedScope,
ISeriesPrimitive,
ISeriesPrimitivePaneRenderer,
ISeriesPrimitivePaneView,
IPrimitivePaneRenderer,
IPrimitivePaneView,
LineData,
Logical,
SeriesAttachedParameter,
Expand All @@ -25,7 +25,7 @@ interface BandRendererData {
lower: Coordinate | number;
}

class BandsIndicatorPaneRenderer implements ISeriesPrimitivePaneRenderer {
class BandsIndicatorPaneRenderer implements IPrimitivePaneRenderer {
_viewData: BandViewData;
constructor(data: BandViewData) {
this._viewData = data;
Expand Down Expand Up @@ -69,7 +69,7 @@ interface BandViewData {
options: Required<BandsIndicatorOptions>;
}

class BandsIndicatorPaneView implements ISeriesPrimitivePaneView {
class BandsIndicatorPaneView implements IPrimitivePaneView {
_source: BandsIndicator;
_data: BandViewData;

Expand Down
14 changes: 7 additions & 7 deletions plugin-examples/src/plugins/delta-tooltip/crosshair-line-pane.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CanvasRenderingTarget2D } from 'fancy-canvas';
import {
ISeriesPrimitivePaneRenderer,
ISeriesPrimitivePaneView,
SeriesPrimitivePaneViewZOrder,
IPrimitivePaneRenderer,
IPrimitivePaneView,
PrimitivePaneViewZOrder,
} from 'lightweight-charts';
import { positionsLine } from '../../helpers/dimensions/positions';

class TooltipCrosshairLinePaneRenderer implements ISeriesPrimitivePaneRenderer {
class TooltipCrosshairLinePaneRenderer implements IPrimitivePaneRenderer {
_data: TooltipCrosshairLineData[];

constructor(data: TooltipCrosshairLineData[]) {
Expand Down Expand Up @@ -61,7 +61,7 @@ class TooltipCrosshairLinePaneRenderer implements ISeriesPrimitivePaneRenderer {
}
}

export class MultiTouchCrosshairPaneView implements ISeriesPrimitivePaneView {
export class MultiTouchCrosshairPaneView implements IPrimitivePaneView {
_data: TooltipCrosshairLineData[];
constructor(data: TooltipCrosshairLineData[]) {
this._data = data;
Expand All @@ -71,11 +71,11 @@ export class MultiTouchCrosshairPaneView implements ISeriesPrimitivePaneView {
this._data = data;
}

renderer(): ISeriesPrimitivePaneRenderer | null {
renderer(): IPrimitivePaneRenderer | null {
return new TooltipCrosshairLinePaneRenderer(this._data);
}

zOrder(): SeriesPrimitivePaneViewZOrder {
zOrder(): PrimitivePaneViewZOrder {
return 'top';
}
}
Expand Down
14 changes: 7 additions & 7 deletions plugin-examples/src/plugins/delta-tooltip/delta-tooltip-pane.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CanvasRenderingTarget2D, Size } from 'fancy-canvas';
import {
ISeriesPrimitivePaneRenderer,
ISeriesPrimitivePaneView,
SeriesPrimitivePaneViewZOrder,
IPrimitivePaneRenderer,
IPrimitivePaneView,
PrimitivePaneViewZOrder,
} from 'lightweight-charts';

const styles = {
Expand Down Expand Up @@ -233,7 +233,7 @@ function calculateDrawingPositions(
};
}

class DeltaTooltipPaneRenderer implements ISeriesPrimitivePaneRenderer {
class DeltaTooltipPaneRenderer implements IPrimitivePaneRenderer {
_data: DeltaTooltipData;

constructor(data: DeltaTooltipData) {
Expand Down Expand Up @@ -347,7 +347,7 @@ class DeltaTooltipPaneRenderer implements ISeriesPrimitivePaneRenderer {
}
}

export class DeltaTooltipPaneView implements ISeriesPrimitivePaneView {
export class DeltaTooltipPaneView implements IPrimitivePaneView {
_data: DeltaTooltipData;
constructor(data: Partial<DeltaTooltipData>) {
this._data = {
Expand All @@ -363,11 +363,11 @@ export class DeltaTooltipPaneView implements ISeriesPrimitivePaneView {
};
}

renderer(): ISeriesPrimitivePaneRenderer | null {
renderer(): IPrimitivePaneRenderer | null {
return new DeltaTooltipPaneRenderer(this._data);
}

zOrder(): SeriesPrimitivePaneViewZOrder {
zOrder(): PrimitivePaneViewZOrder {
return 'top';
}
}
Expand Down
4 changes: 2 additions & 2 deletions plugin-examples/src/plugins/delta-tooltip/delta-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ColorType,
LineStyleOptions,
AreaStyleOptions,
ISeriesPrimitivePaneView,
IPrimitivePaneView,
Time,
} from 'lightweight-charts';
import { Delegate, ISubscription } from '../../helpers/delegate';
Expand Down Expand Up @@ -58,7 +58,7 @@ export class DeltaTooltipPrimitive implements ISeriesPrimitive<Time> {
private _options: TooltipPrimitiveOptions;
_crosshairPaneView: MultiTouchCrosshairPaneView;
_deltaTooltipPaneView: DeltaTooltipPaneView;
_paneViews: ISeriesPrimitivePaneView[];
_paneViews: IPrimitivePaneView[];
_crosshairData: TooltipCrosshairLineData[] = [];
_tooltipData: Partial<DeltaTooltipData>;
_attachedParams: SeriesAttachedParameter<Time> | undefined;
Expand Down
10 changes: 5 additions & 5 deletions plugin-examples/src/plugins/expiring-price-alerts/primitive.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
ISeriesPrimitivePaneView,
ISeriesPrimitivePaneRenderer,
IPrimitivePaneView,
IPrimitivePaneRenderer,
Time,
AutoscaleInfo,
} from 'lightweight-charts';
Expand All @@ -9,7 +9,7 @@ import { ExpiringPriceAlerts } from './expiring-price-alerts';
import { upArrowIcon, tickIcon, cancelIcon, downArrowIcon } from './icons';
import { ExpiringPriceAlertsPaneRenderer, RendererDataItem } from './renderer';

class ExpiringPriceAlertsPaneView implements ISeriesPrimitivePaneView {
class ExpiringPriceAlertsPaneView implements IPrimitivePaneView {
_source: ExpiringPriceAlerts;
_renderer: ExpiringPriceAlertsPaneRenderer;

Expand All @@ -18,7 +18,7 @@ class ExpiringPriceAlertsPaneView implements ISeriesPrimitivePaneView {
this._renderer = new ExpiringPriceAlertsPaneRenderer();
}

renderer(): ISeriesPrimitivePaneRenderer {
renderer(): IPrimitivePaneRenderer {
return this._renderer;
}

Expand Down Expand Up @@ -96,7 +96,7 @@ export class ExpiringAlertPrimitive extends PluginBase {
this._views.forEach(view => view.update());
}

paneViews(): readonly ISeriesPrimitivePaneView[] {
paneViews(): readonly IPrimitivePaneView[] {
return this._views;
}

Expand Down
4 changes: 2 additions & 2 deletions plugin-examples/src/plugins/expiring-price-alerts/renderer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CanvasRenderingTarget2D } from "fancy-canvas";
import { ISeriesPrimitivePaneRenderer } from 'lightweight-charts';
import { IPrimitivePaneRenderer } from 'lightweight-charts';
import { iconDimensions } from "./icons";
import { positionsLine } from "../../helpers/dimensions/positions";

Expand All @@ -13,7 +13,7 @@ export interface RendererDataItem {
fade: boolean;
}

export class ExpiringPriceAlertsPaneRenderer implements ISeriesPrimitivePaneRenderer {
export class ExpiringPriceAlertsPaneRenderer implements IPrimitivePaneRenderer {
_data: RendererDataItem[] = [];

draw(target: CanvasRenderingTarget2D) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { CanvasRenderingTarget2D } from 'fancy-canvas';
import {
CrosshairMode,
ISeriesPrimitivePaneRenderer,
ISeriesPrimitivePaneView,
IPrimitivePaneRenderer,
IPrimitivePaneView,
MouseEventParams,
SeriesPrimitivePaneViewZOrder,
PrimitivePaneViewZOrder,
ISeriesPrimitive,
SeriesAttachedParameter,
Time,
} from 'lightweight-charts';
import { positionsLine } from '../../helpers/dimensions/positions';

class CrosshairHighlightPaneRenderer implements ISeriesPrimitivePaneRenderer {
class CrosshairHighlightPaneRenderer implements IPrimitivePaneRenderer {
_data: CrosshairHighlightData;

constructor(data: CrosshairHighlightData) {
Expand All @@ -38,7 +38,7 @@ class CrosshairHighlightPaneRenderer implements ISeriesPrimitivePaneRenderer {
}
}

class CrosshairHighlightPaneView implements ISeriesPrimitivePaneView {
class CrosshairHighlightPaneView implements IPrimitivePaneView {
_data: CrosshairHighlightData;
constructor(data: CrosshairHighlightData) {
this._data = data;
Expand All @@ -48,11 +48,11 @@ class CrosshairHighlightPaneView implements ISeriesPrimitivePaneView {
this._data = data;
}

renderer(): ISeriesPrimitivePaneRenderer | null {
renderer(): IPrimitivePaneRenderer | null {
return new CrosshairHighlightPaneRenderer(this._data);
}

zOrder(): SeriesPrimitivePaneViewZOrder {
zOrder(): PrimitivePaneViewZOrder {
return 'bottom';
}
}
Expand Down
Loading
Loading