Guilherme Silberfarb Costa commited on
Commit
949bf68
·
1 Parent(s): 0a8b8ba

correcao dos eixos dos graficos comparados com residuos

Browse files
frontend/src/components/ElaboracaoTab.jsx CHANGED
@@ -244,19 +244,58 @@ function matchesShapeAxisRef(ref, token) {
244
  return text === token || text === `${token} domain`
245
  }
246
 
 
 
 
 
 
 
 
 
247
  function filterShapesForPanel(layoutShapes, xToken, yToken) {
248
  if (!Array.isArray(layoutShapes)) return []
249
- return layoutShapes.filter((shape) => {
250
  const xref = String(shape?.xref || '').trim().toLowerCase()
251
  const yref = String(shape?.yref || '').trim().toLowerCase()
252
  const hasX = matchesShapeAxisRef(xref, xToken)
253
  const hasY = matchesShapeAxisRef(yref, yToken)
254
 
255
- if (hasX && hasY) return true
256
- if (hasX && !yref) return true
257
- if (hasY && !xref) return true
258
- return false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  })
 
260
  }
261
 
262
  function stylePanelTrace(trace) {
@@ -339,7 +378,7 @@ function buildScatterPanels(figure, options = {}) {
339
  const panelFigure = {
340
  data: panelTraces,
341
  layout: {
342
- ...layout,
343
  showlegend: false,
344
  autosize: true,
345
  height: options.height || 360,
 
244
  return text === token || text === `${token} domain`
245
  }
246
 
247
+ function remapShapeAxisRef(ref, token, axisType) {
248
+ const text = String(ref || '').trim().toLowerCase()
249
+ if (!text) return text
250
+ if (text === token) return axisType
251
+ if (text === `${token} domain`) return `${axisType} domain`
252
+ return text
253
+ }
254
+
255
  function filterShapesForPanel(layoutShapes, xToken, yToken) {
256
  if (!Array.isArray(layoutShapes)) return []
257
+ return layoutShapes.flatMap((shape) => {
258
  const xref = String(shape?.xref || '').trim().toLowerCase()
259
  const yref = String(shape?.yref || '').trim().toLowerCase()
260
  const hasX = matchesShapeAxisRef(xref, xToken)
261
  const hasY = matchesShapeAxisRef(yref, yToken)
262
 
263
+ if (hasX && hasY) {
264
+ return [{
265
+ ...shape,
266
+ xref: remapShapeAxisRef(xref, xToken, 'x'),
267
+ yref: remapShapeAxisRef(yref, yToken, 'y'),
268
+ }]
269
+ }
270
+ if (hasX && (!yref || yref === 'paper')) {
271
+ return [{
272
+ ...shape,
273
+ xref: remapShapeAxisRef(xref, xToken, 'x'),
274
+ yref: yref || undefined,
275
+ }]
276
+ }
277
+ if (hasY && (!xref || xref === 'paper')) {
278
+ return [{
279
+ ...shape,
280
+ xref: xref || undefined,
281
+ yref: remapShapeAxisRef(yref, yToken, 'y'),
282
+ }]
283
+ }
284
+ return []
285
+ })
286
+ }
287
+
288
+ function stripPanelLayoutAxes(layout) {
289
+ const out = {}
290
+ Object.entries(layout || {}).forEach(([key, value]) => {
291
+ const lower = String(key || '').toLowerCase()
292
+ if (lower === 'xaxis' || lower === 'yaxis') return
293
+ if (/^xaxis\d+$/.test(lower) || /^yaxis\d+$/.test(lower)) return
294
+ if (lower === 'grid') return
295
+ if (lower === 'annotations' || lower === 'shapes' || lower === 'title') return
296
+ out[key] = value
297
  })
298
+ return out
299
  }
300
 
301
  function stylePanelTrace(trace) {
 
378
  const panelFigure = {
379
  data: panelTraces,
380
  layout: {
381
+ ...stripPanelLayoutAxes(layout),
382
  showlegend: false,
383
  autosize: true,
384
  height: options.height || 360,