LegalZhang opened a new issue, #21878:
URL: https://github.com/apache/echarts/issues/21878

   ### Version
   
   6.1.0 (also reproduced on `master` at `34f4d927` and on 5.6.0)
   
   ### Link to Minimal Reproduction
   
   
https://echarts.apache.org/examples/en/editor.html?code=dZNPa9tAEMXv-hQPQ5EFQnGctgQZU0qgp5Yeasgh-DCWttZiaVfsnzgi-Lt3dqXIzSEXa62dN_vm7U83N3gU4tQOcNpRa2EbfVbQCoRet2RQNWQcztI1MNqrWtQ4kLH5-Iqw-EmD9m4Byy-qpky45cJIdbQL9N5ZuEagpsGGpmFtqJbegl6kxTK0wlGDYu8sH9Vc_YGY1LHl36u211I5sIEzmdpmRfLMnqNii6f0l1ZpjnTnRXg8ijr-a3x4_DAy3W9i_TQ7K-6KdY51cZvjc7EKq_scd8VXrkv-elU5yT46OonffVgu2zh7htcEmA7-Hrxt8Qo39KJEWpETR20GPrImR-Vo7rKZFM_UejFrOnop8WXcNcJ5o2JrjHdRcsWYXomnNdtL71ef0j0ueayJ2YRWJUZf2G63SEOaKb7N3srrmaNubPmx8Goxmr8KrTBSBC_zsHwlPGeltaml4sH_DNaJjjeif96K1_xAfQlnvHiLZMr_sue2PPslSXTMlzP5L-w0UpVmfBdMyY5p8Oxg4k4wK3pCp4ibEY-TEH0AR5qZ3ggn49pQH3iqmT1mzBBjTzZ0PrT6YDfQvVBcGbHr6Sgg1RuaU0rhW7FQ2nTUchiV08YWiRVuJzvBBcsZmeWISDc8hK-p4JJppnfjhbyzPCbDQ15y3K5Wq2zzDw&enc=deflate
   
   ### Steps to Reproduce
   
   A polar bar chart with `roundCap: true` and a "Layout" switch: "rings" puts 
the days on `radiusAxis` (bars go around, with round
   caps), "rays" puts them on `angleAxis` (bars point outwards). Switching from 
rings to rays draws the bars as large, overlapping rounded blobs:
   
   ```js
   // Weekly totals shown on a polar chart with rounded bars, with a "Layout" 
switch:
   // "rings" puts the days on the radius axis (bars go around),
   // "rays" puts the days on the angle axis (bars point outwards).
   var days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
   var totals = [3.2, 2.1, 4.0, 2.8, 3.6];
   
   function makeOption(layout) {
     var dayAxis = { type: 'category', data: days };
     var valueAxis = { max: 5 };
     return {
       polar: { radius: [20, '80%'] },
       angleAxis: layout === 'rays' ? dayAxis : valueAxis,
       radiusAxis: layout === 'rays' ? valueAxis : dayAxis,
       series: [{ type: 'bar', coordinateSystem: 'polar', roundCap: true, data: 
totals }]
     };
   }
   
   option = makeOption('rings');
   
   // The user switches to "rays". The bars keep their rounded "ring" shape and 
are drawn as
   // blobs; opening the page in "rays" layout shows normal sectors.
   setTimeout(function () {
     myChart.setOption(makeOption('rays'), true);
   }, 1000);
   ```
   
   <!-- screenshot: browser-canvas-master.png (left: after switching to rays, 
right: rays in a new chart) -->
   
   Reduced version:
   
   ```js
   var categoryAxis = { type: 'category', data: ['a', 'b', 'c'] };
   var valueAxis = { max: 4 };
   function makeOption(categoryOnAngle) {
     return {
       polar: { radius: [30, '80%'] },
       angleAxis: categoryOnAngle ? categoryAxis : valueAxis,
       radiusAxis: categoryOnAngle ? valueAxis : categoryAxis,
       series: [{ type: 'bar', coordinateSystem: 'polar', roundCap: true, 
barWidth: '60%', data: [2, 1.2, 2.4] }]
     };
   }
   
   // Category on the radius axis: bars go around, with round caps.
   option = makeOption(false);
   
   // One second later, move the category to the angle axis. Bars now point 
outwards.
   // They keep the round caps; a chart created directly with makeOption(true) 
draws plain sectors.
   setTimeout(function () {
     myChart.setOption(makeOption(true), { notMerge: true });
   }, 1000);
   ```
   
   
   ### Current Behavior
   
   The bars keep the round-cap shape and are drawn as rounded blobs. Opening 
the page in the final layout draws plain sectors, because round caps are only 
used when the categories are on `radiusAxis`. The same happens with a normal 
merge that swaps the axis types, not only with `notMerge`. On 6.1.0 the other 
direction (`angleAxis` to `radiusAxis`) is fine. On 5.6.0, which does not have 
the #20567 fix yet, that direction keeps the old shape too.
   
   <img width="810" height="300" alt="browser-canvas-master" 
src="https://github.com/user-attachments/assets/a7604e41-d185-47f1-a454-9162114b6e5b";
 />
   
   
   ### Expected Behavior
   
   After switching to rays the bars are plain sectors, like when the page opens 
in rays layout.
   
   
   ### Environment
   
   ```markdown
   - OS: macOS 26.6.2 (arm64)
   - Browser: Microsoft Edge 158.0.4370.45 (6.1.0, Canvas renderer)
   - The `master` build was also checked with the SVG renderer in 
JavaScriptCore.
   - Framework: none
   ```
   
   ### Any additional comments?
   
   `BarView._renderNormal` replaces a reused element when `roundCap` changed 
(`roundCapChanged`, added for #20567), but it only compares the element type 
with `roundCap`. `elementCreator.polar` creates a `sausage` only when 
`roundCap` is set **and** the bars run along the angle axis, so after the 
orientation changes the old `sausage` is kept. Comparing the element type with 
the type a new chart would create fixes it; I can send a PR.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to