-
-
Notifications
You must be signed in to change notification settings - Fork 825
Open
Description
Version
10.0.0-alpha8
Steps to Reproduce
- Initialize the chart without providing a layout configuration
const chart = init("chart”);- Clone the original pane options before modification (this will become the default pane options)
const defaultPaneOptions = utils.clone(chart.getPaneOptions()[0]);- Modify a pane option field that does not exist in the clone
chart.setPaneOption({
id: "candle_pane",
axis: {
reverse: true,
},
});- Compare the active pane options before and after reset
console.log(chart.getPaneOptions()[0]);
chart.setPaneOptions(defaultPaneOptions);
console.log(chart.getPaneOptions()[0]);- Verify that the
axis.reverseoption still exists and is set totruefor “candle_pane” instead of being removed or set tofalse.
Current Behavior
The setPaneOptions function will merge the input object with the existing pane options. This means you cannot rely on a cloned version of chart's pane options when resetting to a default or setting variations of a chart's pane options. This can make it more difficult to implement certain features, for example, switching between different themes of a chart. To get around this you either have to set default pane options in the init() layout field or create a global pane options object with every pane option field defined:
/* init() approach */
const chart = init("chart", {
layout: [
{
type: "candle",
options: {
id: "candle_pane",
axis: {
name: "normal",
reverse: false, // <— must include reverse in order to reset it to a default
...
},
...
},
},
],
});
/* object reference approach */
const defaultPaneOptions = {
id: "candle_pane",
axis: {
name: "normal",
reverse: false,
...
},
...
}
chart.setPaneOptions(defaultPaneOptions);Expected Behavior
I expected to be able to reset any modifications made to the chart's pane options by creating a clone of the initial pane options and passing the clone into setPaneOptions.
const chart = init("chart”);
const defaultPaneOptions= utils.clone(
chart.getPaneOptions().find(
(option) => option.id === "candle_pane"
)
);
chart.setPaneOption({
id: "candle_pane",
axis: {
reverse: true,
},
});
chart.setPaneOption(defaultPaneOptions);Environment
- OS: Sequoia v15.6.1 (Mac)
- Browser: Brave 1.81.135 (arm64) (Chromium: 139.0.7258.127)
- Framework: Next.js 15.4.5Any additional comments?
No response
Metadata
Metadata
Assignees
Labels
No labels