Skip to content

Commit

Permalink
remove primitive constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
illetid committed Aug 29, 2024
1 parent 71bec3e commit 1b6392b
Show file tree
Hide file tree
Showing 26 changed files with 6 additions and 43 deletions.
23 changes: 6 additions & 17 deletions src/plugins/series-markers/primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@ class SeriesMarkersPrimitive<HorzScaleItem> implements ISeriesPrimitive<HorzScal
private _autoScaleMargins: AutoScaleMargins | null = null;
private _markersPositions: MarkerPositions | null = null;

public constructor(chart: IChartApiBase<HorzScaleItem>, series: ISeriesApi<SeriesType, HorzScaleItem>) {
this._chart = chart;
this._series = series;
}

public attached(param: SeriesAttachedParameter<HorzScaleItem>): void {
this._attached = param;
const series = param.series;
this._recalculateMarkers();
this._paneView = new SeriesMarkersPaneView(series, ensureNotNull(this._chart));
this._chart = param.chart;
this._series = param.series;
this._paneView = new SeriesMarkersPaneView(this._series, ensureNotNull(this._chart));
this._requestUpdate = param.requestUpdate;
series.subscribeDataChanged((scope: DataChangedScope) => this._onDataChanged(scope));
this._series.subscribeDataChanged((scope: DataChangedScope) => this._onDataChanged(scope));
this.requestUpdate();
}

Expand Down Expand Up @@ -196,8 +192,6 @@ class SeriesMarkersPrimitive<HorzScaleItem> implements ISeriesPrimitive<HorzScal
*
* @param series - The series to which the primitive will be attached.
*
* @param chart - The chart instance.
*
* @param markers - An array of markers to be displayed on the series.
*
* @example
Expand All @@ -206,7 +200,6 @@ class SeriesMarkersPrimitive<HorzScaleItem> implements ISeriesPrimitive<HorzScal
*
* const seriesMarkersPrimitive = createSeriesMarkersPrimitive(
* series,
* chart,
* [
* {
* color: 'green',
Expand All @@ -220,21 +213,17 @@ class SeriesMarkersPrimitive<HorzScaleItem> implements ISeriesPrimitive<HorzScal
* // set it to empty array to remove all markers
* seriesMarkersPrimitive.setMarkers([]);
*
* // or you can call `seriesMarkersPrimitive.markers()` to get the current markers
* // `seriesMarkersPrimitive.markers()` returns current markers
* ```
*/
export function createSeriesMarkersPrimitive<HorzScaleItem>(
series: ISeriesApi<SeriesType, HorzScaleItem>,
chart: IChartApiBase<HorzScaleItem>,
markers?: SeriesMarker<HorzScaleItem>[]
): SeriesMarkersPrimitive<HorzScaleItem> {
const primitive = new SeriesMarkersPrimitive<HorzScaleItem>(chart, series);

const primitive = new SeriesMarkersPrimitive<HorzScaleItem>();
if (markers) {
primitive.setMarkers(markers);
}

series.attachPrimitive(primitive);

return primitive;
}
1 change: 0 additions & 1 deletion tests/e2e/coverage/test-cases/series/markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function beforeInteractions(container) {
mainSeries.setData(data);
seriesMarkerPrimitives = LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[data.length - 7].time, position: 'belowBar', color: 'rgb(255, 0, 0)', shape: 'arrowUp', text: 'test' },
{ time: data[data.length - 5].time, position: 'aboveBar', color: 'rgba(255, 255, 0, 1)', shape: 'arrowDown', text: 'test' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ function runTestCase(container) {
}
LightweightCharts.createSeriesMarkersPrimitive(
series,
chart,
markers
);
}
1 change: 0 additions & 1 deletion tests/e2e/graphics/test-cases/api/series-markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function runTestCase(container) {

const markersPrimitive = LightweightCharts.createSeriesMarkersPrimitive(
series,
chart,
markers
);
const seriesApiMarkers = markersPrimitive.markers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function runTestCase(container) {
lineSeries.setData(data);
LightweightCharts.createSeriesMarkersPrimitive(
lineSeries,
chart,
[
{ time: data[data.length - 30].time, position: 'belowBar', color: 'orange', shape: 'arrowUp' },
{ time: data[data.length - 30].time, position: 'belowBar', color: 'yellow', shape: 'arrowUp' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function runTestCase(container) {
lineSeries.setData(data);
LightweightCharts.createSeriesMarkersPrimitive(
lineSeries,
chart,
[
{ time: data[data.length - 30].time, position: 'belowBar', color: 'orange', shape: 'arrowUp' },
{ time: data[data.length - 30].time, position: 'belowBar', color: 'yellow', shape: 'arrowUp' },
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/graphics/test-cases/data-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function runTestCase(container) {
try {
LightweightCharts.createSeriesMarkersPrimitive(
lineSeries,
chart,
[
{ time: 1 },
{ time: 0, value: 0 },
Expand Down Expand Up @@ -99,7 +98,6 @@ function runTestCase(container) {
// should pass - several markers could be on the same bar
LightweightCharts.createSeriesMarkersPrimitive(
lineSeries,
chart,
[
{
color: 'green',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function runTestCase(container) {
]);
LightweightCharts.createSeriesMarkersPrimitive(
lineSeries,
chart,
[
{
color: 'green',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
lineSeries,
chart,
[
{
color: 'green',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[data.length - 30].time, position: 'belowBar', color: 'orange', shape: 'arrowUp' },
{ time: data[data.length - 30].time, position: 'belowBar', color: 'yellow', shape: 'arrowUp' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function runTestCase(container) {
mainSeries.setData(data);
LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[data.length - 30].time, position: 'belowBar', color: 'orange', shape: 'circle' },
{ time: data[data.length - 30].time, position: 'belowBar', color: 'yellow', shape: 'circle' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
line,
chart,
[
{ time: '2017-04-10', position: 'inBar', color: 'orange', shape: 'circle' },
{ time: '2017-04-16', position: 'inBar', color: 'orange', shape: 'circle' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[0].time, position: 'aboveBar', color: 'red', shape: 'arrowUp' },
{ time: data[1].time, position: 'aboveBar', color: 'red', shape: 'arrowUp' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[data.length - 3].time, position: 'belowBar', color: 'red', shape: 'arrowUp' },
{ time: data[data.length - 2].time, position: 'belowBar', color: 'red', shape: 'arrowUp' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ function runTestCase(container) {
mainSeries.setData(data);
LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[data.length - 3].time, position: 'inBar', color: 'red', shape: 'arrowUp' },
{ time: data[data.length - 2].time, position: 'inBar', color: 'red', shape: 'arrowUp' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[data.length - 4].time, position: 'inBar', color: 'red', shape: 'square' },
{ time: data[data.length - 3].time, position: 'inBar', color: 'red', shape: 'circle' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
markers
);
chart.applyOptions({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
line,
chart,
[
{ time: { year: 2017, month: 4, day: 11 }, position: 'inBar', color: 'orange', shape: 'circle' },
{ time: { year: 2017, month: 4, day: 14 }, position: 'inBar', color: 'orange', shape: 'circle' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[0].time, position: 'belowBar', color: 'red', shape: 'arrowUp' },
{ time: data[data.length - 4].time, position: 'belowBar', color: 'red', shape: 'arrowUp' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
line,
chart,
[
{ time: '2017-04-10', position: 'inBar', color: 'orange', shape: 'circle' },
{ time: '2017-04-16', position: 'inBar', color: 'orange', shape: 'circle' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function runTestCase(container) {
];
const markerPrimitive = LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
markers
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function runTestCase(container) {
mainSeries.setData(data);
LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[data.length - 50].time, position: 'belowBar', color: 'red', shape: 'arrowUp', text: 'test' },
{ time: data[data.length - 50].time, position: 'belowBar', color: 'red', shape: 'arrowDown', text: 'test' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function runTestCase(container) {
mainSeries.setData(data);
LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{ time: data[data.length - 30].time, position: 'belowBar', color: 'orange', shape: 'square' },
{ time: data[data.length - 30].time, position: 'belowBar', color: 'yellow', shape: 'square' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ function runTestCase(container) {

LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{
time: '2019-04-09',
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/graphics/test-cases/series/series-visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function runTestCase(container) {
lineSeries.setData(data);
LightweightCharts.createSeriesMarkersPrimitive(
lineSeries,
chart,
[
{ time: data[data.length - 30].time, position: 'belowBar', color: 'orange', shape: 'arrowUp' },
{ time: data[data.length - 30].time, position: 'belowBar', color: 'yellow', shape: 'arrowUp' },
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/interactions/test-cases/markers/text-hit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function beforeInteractions(container) {
mainSeries.setData(mainSeriesData);
LightweightCharts.createSeriesMarkersPrimitive(
mainSeries,
chart,
[
{
time: markerTime,
Expand Down

0 comments on commit 1b6392b

Please sign in to comment.