Skip to content

Commit

Permalink
fix: id generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Estasie committed Dec 27, 2024
1 parent a26c10f commit 0bfe4d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/YagrCore/plugins/plotLines/plotLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {DrawOrderKey} from '../../utils/types';
import {PBandConfig} from 'src/types';
import {deepIsEqual} from '../../utils/common';
import {calculateFromTo} from './utils';
import {nanoid} from 'nanoid';

const MAX_X_SCALE_LINE_OFFSET = 0;
const DRAW_MAP = {
Expand Down Expand Up @@ -49,13 +48,14 @@ export default function plotLinesPlugin(options: PlotLineOptions): PlotLinesPlug
const drawIndicies = (drawOrder ? drawOrder.map((key) => DRAW_MAP[key]) : [0, 1, 2]).join('');

const hook = HOOKS_MAP[drawIndicies] || 'drawClear';
let lineCounter = 0;

function getLineId(line: PlotLineConfig): string {
if (line.id) {
return line.id;
}
const lineWithoutId = Array.from(plotLines.entries()).find(([_, l]) => deepIsEqual(l, line))?.[0];
return lineWithoutId || `${nanoid()}`;
return lineWithoutId || `plot-line-${++lineCounter}`;
}

function renderPlotLines(u: UPlot) {
Expand Down

0 comments on commit 0bfe4d0

Please sign in to comment.