File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -152,8 +152,6 @@ export class Chart extends EventEmitter.EventEmitter {
152152 */
153153 private linkedGraphs : Array < Chart >
154154 private line : Line < [ number , number ] >
155- // Keep the rendered mode separately because callers can mutate and reuse options.
156- private wasPolarCoordinateSystem = false
157155
158156 /**
159157 * `svg` element that holds the graph (canvas + title + axes)
@@ -639,7 +637,7 @@ export class Chart extends EventEmitter.EventEmitter {
639637 } )
640638 }
641639
642- if ( this . isPolarCoordinateSystem ( ) || this . getEmitInstance ( ) . wasPolarCoordinateSystem ) {
640+ if ( this . isPolarCoordinateSystem ( ) || this . getEmitInstance ( ) . options . lastCoordinateSystem === 'polar' ) {
643641 // Rebase polar rebuilds and transitions out of the zero-margin polar canvas.
644642 // Undo the current transform so its next application reproduces the rebuilt domains,
645643 // preserving zoom and pan even when another Chart instance reuses the SVG.
@@ -684,7 +682,7 @@ export class Chart extends EventEmitter.EventEmitter {
684682 } )
685683 . attr ( 'width' , this . meta . width )
686684 . attr ( 'height' , this . meta . height )
687- this . wasPolarCoordinateSystem = this . isPolarCoordinateSystem ( )
685+ this . options . lastCoordinateSystem = this . options . coordinateSystem
688686 }
689687
690688 setUpPlugins ( ) {
Original file line number Diff line number Diff line change @@ -343,6 +343,12 @@ export interface FunctionPlotOptions {
343343 */
344344 id ?: string
345345
346+ /**
347+ * @private
348+ * Last rendered coordinate system, preserved when callers mutate options.
349+ */
350+ lastCoordinateSystem ?: 'cartesian' | 'polar'
351+
346352 /**
347353 * A css selector or DOM node of the parent element that will contain the graph
348354 */
Original file line number Diff line number Diff line change @@ -259,7 +259,18 @@ describe('Polar coordinate system', () => {
259259 const previous = await scaleState ( )
260260 await page . evaluate (
261261 ( mode , reuseOptions ) => {
262- const options = reuseOptions ? window . polarOptions : Object . assign ( { } , window . polarOptions , { id : undefined } )
262+ const previous = window . polarOptions
263+ // New options omit internal metadata while reusing the previous SVG.
264+ const options = reuseOptions
265+ ? previous
266+ : {
267+ target : previous . target ,
268+ width : previous . width ,
269+ height : previous . height ,
270+ xAxis : previous . xAxis ,
271+ yAxis : previous . yAxis ,
272+ data : previous . data
273+ }
263274 options . coordinateSystem = mode
264275 window . polarOptions = options
265276 window . polarChart = functionPlot ( options )
You can’t perform that action at this time.
0 commit comments