Skip to content

Series-name with parenthesis causes exception on toggleSeries() #355

@paaaz

Description

@paaaz

Codepen

https://codepen.io/anon/pen/LaVRVY

Explanation

  • What is the behavior you expect?
    That the name of a series is unconstrained and toggling works with chart.toggleSeries(name)

  • What is happening instead?
    Exception raises:

  • What error message are you getting?
    Uncaught DOMException: Failed to execute 'querySelector' on 'Element': '.apexcharts-series.(250)-Errorous-Name' is not a valid selector. at t.value (https://cdn.jsdelivr.net/npm/apexcharts:6:162051) at i.value (https://cdn.jsdelivr.net/npm/apexcharts:6:408022) at toggleError (pen.js:62:11) at HTMLButtonElement.onclick (https://s.codepen.io/boomerang/iFrameKey-d5b12e0e-22b3-e6b3-f495-289f92142d77/index.html:13:55)

Temporary Fix

I think the name should be generally escaped somehow, I could fix the bug temporary for my case with parenthesis with adding replace functions.

(Line 11364 in v3.3.0)
key: "getSeriesByName", value: function getSeriesByName(seriesName) { return this.w.globals.dom.baseEl.querySelector(".apexcharts-series.".concat(seriesName.toString().replace(/ /g, '-').replace(/\(/g, '\\(').replace(/\)/g, '\\)'))); }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions