Skip to content

Conversation

@lxfu1
Copy link
Member

@lxfu1 lxfu1 commented Nov 25, 2025

Checklist
  • npm test passes
  • benchmarks are included
  • commit message follows commit guidelines
  • documents are updated
Description of change

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lxfu1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the beeSwarm visualization by adjusting its layout algorithm to remove the x-axis attraction force, which will alter how elements cluster horizontally. It also standardizes the data used in examples and tests by introducing a static JSON dataset, and simplifies the visual encoding by removing the size channel, leading to a cleaner and more predictable beeswarm layout.

Highlights

  • Beeswarm X-axis Force Adjustment: The forceX strength in the beeswarm mark's simulation was set to 0, effectively removing the horizontal attraction force and allowing for a different distribution along the x-axis.
  • Static Data Integration: Random data generation was replaced with a new static bee.json dataset for both tests and examples, ensuring consistent and reproducible visualization outcomes.
  • Visual Encoding and Legend Refinements: The size encoding and its associated scale were removed from the beeswarm configurations, and the color legend was updated to disable shape and position it at the top center for improved presentation.
  • Test Activation: The alphabetBeeswarm test is now active, indicating it's ready for execution and part of the regular test suite.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adjusts the strength of the x-force in the beeswarm simulation and updates the test and demo data to use a static dataset instead of random data. The change to the force simulation seems correct for achieving the desired beeswarm effect. However, I've noticed some areas for improvement in the data handling within the test and demo files, specifically regarding data duplication and inefficient data transformation logic. My comments provide suggestions to refactor this for better maintainability and performance.

Comment on lines +8 to +209
const DATA = [
{ A: 7.2911611863, B: 7.2911611863, C: 7.2911611863, D: 7.2911611863 },
{ A: 8.8978012844, B: 8.8978012844, C: 8.8978012844, D: 8.8978012844 },
{ A: 5.5551149595, B: 5.5551149595, C: 5.5551149595, D: 5.5551149595 },
{ A: 6.2139408759, B: 6.2139408759, C: 6.2139408759, D: 6.2139408759 },
{ A: 2.7495268283, B: 2.7495268283, C: 2.7495268283, D: 2.7495268283 },
{ A: 4.6707656583, B: 4.6707656583, C: 4.6707656583, D: 4.6707656583 },
{ A: 5.1356047649, B: 5.1356047649, C: 5.1356047649, D: 5.1356047649 },
{ A: 5.4487476363, B: 5.4487476363, C: 5.4487476363, D: 5.4487476363 },
{ A: 8.4670698044, B: 8.4670698044, C: 8.4670698044, D: 8.4670698044 },
{ A: 6.7042028831, B: 6.7042028831, C: 6.7042028831, D: 6.7042028831 },
{ A: 5.4348566098, B: 5.4348566098, C: 5.4348566098, D: 5.4348566098 },
{ A: 3.5757789012, B: 3.5757789012, C: 3.5757789012, D: 3.5757789012 },
{ A: 5.1781042298, B: 5.1781042298, C: 5.1781042298, D: 5.1781042298 },
{ A: 6.7602088874, B: 6.7602088874, C: 6.7602088874, D: 6.7602088874 },
{ A: 5.2733306979, B: 5.2733306979, C: 5.2733306979, D: 5.2733306979 },
{ A: 4.8627920231, B: 4.8627920231, C: 4.8627920231, D: 4.8627920231 },
{ A: 6.7383431378, B: 6.7383431378, C: 6.7383431378, D: 6.7383431378 },
{ A: 2.860024228, B: 2.860024228, C: 2.860024228, D: 2.860024228 },
{ A: 5.5304133211, B: 5.5304133211, C: 5.5304133211, D: 5.5304133211 },
{ A: 0.711422972, B: 0.711422972, C: 0.711422972, D: 0.711422972 },
{ A: 4.5546289522, B: 4.5546289522, C: 4.5546289522, D: 4.5546289522 },
{ A: 4.4135940353, B: 4.4135940353, C: 4.4135940353, D: 4.4135940353 },
{ A: 4.2123561292, B: 4.2123561292, C: 4.2123561292, D: 4.2123561292 },
{ A: 5.2822099033, B: 5.2822099033, C: 5.2822099033, D: 5.2822099033 },
{ A: 3.7264619495, B: 3.7264619495, C: 3.7264619495, D: 3.7264619495 },
{ A: 4.4487286148, B: 4.4487286148, C: 4.4487286148, D: 4.4487286148 },
{ A: 5.7611914221, B: 5.7611914221, C: 5.7611914221, D: 5.7611914221 },
{ A: 3.6691519848, B: 3.6691519848, C: 3.6691519848, D: 3.6691519848 },
{ A: 4.520151569, B: 4.520151569, C: 4.520151569, D: 4.520151569 },
{ A: 8.3632854707, B: 8.3632854707, C: 8.3632854707, D: 8.3632854707 },
{ A: 7.6680948595, B: 7.6680948595, C: 7.6680948595, D: 7.6680948595 },
{ A: 4.6598246492, B: 4.6598246492, C: 4.6598246492, D: 4.6598246492 },
{ A: 6.7171280171, B: 6.7171280171, C: 6.7171280171, D: 6.7171280171 },
{ A: 2.7886122836, B: 2.7886122836, C: 2.7886122836, D: 2.7886122836 },
{ A: 5.7157466168, B: 5.7157466168, C: 5.7157466168, D: 5.7157466168 },
{ A: 5.4280486537, B: 5.4280486537, C: 5.4280486537, D: 5.4280486537 },
{ A: 3.8833854682, B: 3.8833854682, C: 3.8833854682, D: 3.8833854682 },
{ A: 3.3526734553, B: 3.3526734553, C: 3.3526734553, D: 3.3526734553 },
{ A: 5.6738918792, B: 5.6738918792, C: 5.6738918792, D: 5.6738918792 },
{ A: 3.8334172456, B: 3.8334172456, C: 3.8334172456, D: 3.8334172456 },
{ A: 6.5206129752, B: 6.5206129752, C: 6.5206129752, D: 6.5206129752 },
{ A: 9.1798774293, B: 9.1798774293, C: 9.1798774293, D: 9.1798774293 },
{ A: 4.7293794576, B: 4.7293794576, C: 4.7293794576, D: 4.7293794576 },
{ A: 4.8465613153, B: 4.8465613153, C: 4.8465613153, D: 4.8465613153 },
{ A: 3.5567592869, B: 3.5567592869, C: 3.5567592869, D: 3.5567592869 },
{ A: 4.0956597875, B: 4.0956597875, C: 4.0956597875, D: 4.0956597875 },
{ A: 4.2163127532, B: 4.2163127532, C: 4.2163127532, D: 4.2163127532 },
{ A: 3.4912075374, B: 3.4912075374, C: 3.4912075374, D: 3.4912075374 },
{ A: 0.8406937267, B: 0.8406937267, C: 0.8406937267, D: 0.8406937267 },
{ A: 4.6369707245, B: 4.6369707245, C: 4.6369707245, D: 4.6369707245 },
{ A: 5.2757661035, B: 5.2757661035, C: 5.2757661035, D: 5.2757661035 },
{ A: 4.241616454, B: 4.241616454, C: 4.241616454, D: 4.241616454 },
{ A: 5.1378322734, B: 5.1378322734, C: 5.1378322734, D: 5.1378322734 },
{ A: 9.3208608354, B: 9.3208608354, C: 9.3208608354, D: 9.3208608354 },
{ A: 2.8998983895, B: 2.8998983895, C: 2.8998983895, D: 2.8998983895 },
{ A: 5.4276672287, B: 5.4276672287, C: 5.4276672287, D: 5.4276672287 },
{ A: 2.6533910144, B: 2.6533910144, C: 2.6533910144, D: 2.6533910144 },
{ A: 5.0179970443, B: 5.0179970443, C: 5.0179970443, D: 5.0179970443 },
{ A: 3.7646128805, B: 3.7646128805, C: 3.7646128805, D: 3.7646128805 },
{ A: 10.3476719356, B: 10.3476719356, C: 10.3476719356, D: 10.3476719356 },
{ A: 3.2127171309, B: 3.2127171309, C: 3.2127171309, D: 3.2127171309 },
{ A: 1.2254114168, B: 1.2254114168, C: 1.2254114168, D: 1.2254114168 },
{ A: 0.714722994, B: 0.714722994, C: 0.714722994, D: 0.714722994 },
{ A: 2.0744349325, B: 2.0744349325, C: 2.0744349325, D: 2.0744349325 },
{ A: 3.3968366109, B: 3.3968366109, C: 3.3968366109, D: 3.3968366109 },
{ A: 4.9600652904, B: 4.9600652904, C: 4.9600652904, D: 4.9600652904 },
{ A: 4.6617177071, B: 4.6617177071, C: 4.6617177071, D: 4.6617177071 },
{ A: 4.6600529984, B: 4.6600529984, C: 4.6600529984, D: 4.6600529984 },
{ A: 2.4021392, B: 2.4021392, C: 2.4021392, D: 2.4021392 },
{ A: 5.3414168958, B: 5.3414168958, C: 5.3414168958, D: 5.3414168958 },
{ A: 8.6701182152, B: 8.6701182152, C: 8.6701182152, D: 8.6701182152 },
{ A: 4.3991096329, B: 4.3991096329, C: 4.3991096329, D: 4.3991096329 },
{ A: 2.2839244883, B: 2.2839244883, C: 2.2839244883, D: 2.2839244883 },
{ A: 6.348781742, B: 6.348781742, C: 6.348781742, D: 6.348781742 },
{ A: 1.8264745418, B: 1.8264745418, C: 1.8264745418, D: 1.8264745418 },
{ A: 3.6811453395, B: 3.6811453395, C: 3.6811453395, D: 3.6811453395 },
{ A: 5.5313634472, B: 5.5313634472, C: 5.5313634472, D: 5.5313634472 },
{ A: 6.385385985, B: 6.385385985, C: 6.385385985, D: 6.385385985 },
{ A: 4.1253275373, B: 4.1253275373, C: 4.1253275373, D: 4.1253275373 },
{ A: 3.665764021, B: 3.665764021, C: 3.665764021, D: 3.665764021 },
{ A: 2.8716031392, B: 2.8716031392, C: 2.8716031392, D: 2.8716031392 },
{ A: 6.7682806659, B: 6.7682806659, C: 6.7682806659, D: 6.7682806659 },
{ A: 7.2173982124, B: 7.2173982124, C: 7.2173982124, D: 7.2173982124 },
{ A: 7.3053585394, B: 7.3053585394, C: 7.3053585394, D: 7.3053585394 },
{ A: 4.9634379431, B: 4.9634379431, C: 4.9634379431, D: 4.9634379431 },
{ A: 4.9808652987, B: 4.9808652987, C: 4.9808652987, D: 4.9808652987 },
{ A: 6.9165425425, B: 6.9165425425, C: 6.9165425425, D: 6.9165425425 },
{ A: 6.7044929299, B: 6.7044929299, C: 6.7044929299, D: 6.7044929299 },
{ A: 3.8871378261, B: 3.8871378261, C: 3.8871378261, D: 3.8871378261 },
{ A: 4.1723846264, B: 4.1723846264, C: 4.1723846264, D: 4.1723846264 },
{ A: 6.0056575479, B: 6.0056575479, C: 6.0056575479, D: 6.0056575479 },
{ A: 3.290760503, B: 3.290760503, C: 3.290760503, D: 3.290760503 },
{ A: 0.9015306397, B: 0.9015306397, C: 0.9015306397, D: 0.9015306397 },
{ A: 7.7895249065, B: 7.7895249065, C: 7.7895249065, D: 7.7895249065 },
{ A: 2.8845393723, B: 2.8845393723, C: 2.8845393723, D: 2.8845393723 },
{ A: 4.9530964277, B: 4.9530964277, C: 4.9530964277, D: 4.9530964277 },
{ A: 7.3759294903, B: 7.3759294903, C: 7.3759294903, D: 7.3759294903 },
{ A: 2.9632812446, B: 2.9632812446, C: 2.9632812446, D: 2.9632812446 },
{ A: -0.801533813, B: -0.801533813, C: -0.801533813, D: -0.801533813 },
{ A: 2.5486066739, B: 2.5486066739, C: 2.5486066739, D: 2.5486066739 },
{ A: 3.7497213835, B: 3.7497213835, C: 3.7497213835, D: 3.7497213835 },
{ A: 4.9466732798, B: 4.9466732798, C: 4.9466732798, D: 4.9466732798 },
{ A: 3.7638233353, B: 3.7638233353, C: 3.7638233353, D: 3.7638233353 },
{ A: 6.8042177994, B: 6.8042177994, C: 6.8042177994, D: 6.8042177994 },
{ A: 4.3848536708, B: 4.3848536708, C: 4.3848536708, D: 4.3848536708 },
{ A: 4.9075697463, B: 4.9075697463, C: 4.9075697463, D: 4.9075697463 },
{ A: 6.08090501, B: 6.08090501, C: 6.08090501, D: 6.08090501 },
{ A: 6.2314658187, B: 6.2314658187, C: 6.2314658187, D: 6.2314658187 },
{ A: 3.5696625451, B: 3.5696625451, C: 3.5696625451, D: 3.5696625451 },
{ A: 3.010775249, B: 3.010775249, C: 3.010775249, D: 3.010775249 },
{ A: 2.2782393135, B: 2.2782393135, C: 2.2782393135, D: 2.2782393135 },
{ A: 2.9323084636, B: 2.9323084636, C: 2.9323084636, D: 2.9323084636 },
{ A: 5.2308979877, B: 5.2308979877, C: 5.2308979877, D: 5.2308979877 },
{ A: 4.9566579832, B: 4.9566579832, C: 4.9566579832, D: 4.9566579832 },
{ A: 3.7174070047, B: 3.7174070047, C: 3.7174070047, D: 3.7174070047 },
{ A: 5.5002130405, B: 5.5002130405, C: 5.5002130405, D: 5.5002130405 },
{ A: 3.4953182611, B: 3.4953182611, C: 3.4953182611, D: 3.4953182611 },
{ A: 4.8822684306, B: 4.8822684306, C: 4.8822684306, D: 4.8822684306 },
{ A: 3.9083374178, B: 3.9083374178, C: 3.9083374178, D: 3.9083374178 },
{ A: 3.6518050246, B: 3.6518050246, C: 3.6518050246, D: 3.6518050246 },
{ A: 6.2240918107, B: 6.2240918107, C: 6.2240918107, D: 6.2240918107 },
{ A: 5.3242663786, B: 5.3242663786, C: 5.3242663786, D: 5.3242663786 },
{ A: 6.2437528865, B: 6.2437528865, C: 6.2437528865, D: 6.2437528865 },
{ A: 6.0693642247, B: 6.0693642247, C: 6.0693642247, D: 6.0693642247 },
{ A: 5.8791320278, B: 5.8791320278, C: 5.8791320278, D: 5.8791320278 },
{ A: 4.4324520719, B: 4.4324520719, C: 4.4324520719, D: 4.4324520719 },
{ A: 6.3299044346, B: 6.3299044346, C: 6.3299044346, D: 6.3299044346 },
{ A: 8.343232463, B: 8.343232463, C: 8.343232463, D: 8.343232463 },
{ A: 6.188953175, B: 6.188953175, C: 6.188953175, D: 6.188953175 },
{ A: 3.1888313429, B: 3.1888313429, C: 3.1888313429, D: 3.1888313429 },
{ A: 4.1619814893, B: 4.1619814893, C: 4.1619814893, D: 4.1619814893 },
{ A: 4.6221520545, B: 4.6221520545, C: 4.6221520545, D: 4.6221520545 },
{ A: 5.6842015598, B: 5.6842015598, C: 5.6842015598, D: 5.6842015598 },
{ A: 4.0342862914, B: 4.0342862914, C: 4.0342862914, D: 4.0342862914 },
{ A: 3.4340249135, B: 3.4340249135, C: 3.4340249135, D: 3.4340249135 },
{ A: 7.1885440081, B: 7.1885440081, C: 7.1885440081, D: 7.1885440081 },
{ A: 6.6900788238, B: 6.6900788238, C: 6.6900788238, D: 6.6900788238 },
{ A: 3.9403839701, B: 3.9403839701, C: 3.9403839701, D: 3.9403839701 },
{ A: 2.4912562378, B: 2.4912562378, C: 2.4912562378, D: 2.4912562378 },
{ A: 3.1773432982, B: 3.1773432982, C: 3.1773432982, D: 3.1773432982 },
{ A: 2.4120831078, B: 2.4120831078, C: 2.4120831078, D: 2.4120831078 },
{ A: 2.8402938681, B: 2.8402938681, C: 2.8402938681, D: 2.8402938681 },
{ A: 5.8246138121, B: 5.8246138121, C: 5.8246138121, D: 5.8246138121 },
{ A: 3.6849281169, B: 3.6849281169, C: 3.6849281169, D: 3.6849281169 },
{ A: 5.0609677718, B: 5.0609677718, C: 5.0609677718, D: 5.0609677718 },
{ A: 6.1267462494, B: 6.1267462494, C: 6.1267462494, D: 6.1267462494 },
{ A: 5.0746750856, B: 5.0746750856, C: 5.0746750856, D: 5.0746750856 },
{ A: 1.9153067946, B: 1.9153067946, C: 1.9153067946, D: 1.9153067946 },
{ A: 2.8685451063, B: 2.8685451063, C: 2.8685451063, D: 2.8685451063 },
{ A: 1.4089714463, B: 1.4089714463, C: 1.4089714463, D: 1.4089714463 },
{ A: 6.9550977029, B: 6.9550977029, C: 6.9550977029, D: 6.9550977029 },
{ A: 2.9755431685, B: 2.9755431685, C: 2.9755431685, D: 2.9755431685 },
{ A: 3.8840878703, B: 3.8840878703, C: 3.8840878703, D: 3.8840878703 },
{ A: 8.4930347911, B: 8.4930347911, C: 8.4930347911, D: 8.4930347911 },
{ A: 3.7043375708, B: 3.7043375708, C: 3.7043375708, D: 3.7043375708 },
{ A: 4.2985221887, B: 4.2985221887, C: 4.2985221887, D: 4.2985221887 },
{ A: 3.0898211535, B: 3.0898211535, C: 3.0898211535, D: 3.0898211535 },
{ A: 6.0489082117, B: 6.0489082117, C: 6.0489082117, D: 6.0489082117 },
{ A: 5.2083020938, B: 5.2083020938, C: 5.2083020938, D: 5.2083020938 },
{ A: 4.1996048795, B: 4.1996048795, C: 4.1996048795, D: 4.1996048795 },
{ A: 5.9622118222, B: 5.9622118222, C: 5.9622118222, D: 5.9622118222 },
{ A: 4.6031558097, B: 4.6031558097, C: 4.6031558097, D: 4.6031558097 },
{ A: 5.0796681319, B: 5.0796681319, C: 5.0796681319, D: 5.0796681319 },
{ A: 4.8849619161, B: 4.8849619161, C: 4.8849619161, D: 4.8849619161 },
{ A: 3.2494345567, B: 3.2494345567, C: 3.2494345567, D: 3.2494345567 },
{ A: 2.9796247967, B: 2.9796247967, C: 2.9796247967, D: 2.9796247967 },
{ A: 8.7705163483, B: 8.7705163483, C: 8.7705163483, D: 8.7705163483 },
{ A: 5.0190374083, B: 5.0190374083, C: 5.0190374083, D: 5.0190374083 },
{ A: 3.3393284767, B: 3.3393284767, C: 3.3393284767, D: 3.3393284767 },
{ A: 0.8203366337, B: 0.8203366337, C: 0.8203366337, D: 0.8203366337 },
{ A: 8.5327653207, B: 8.5327653207, C: 8.5327653207, D: 8.5327653207 },
{ A: 3.4697443099, B: 3.4697443099, C: 3.4697443099, D: 3.4697443099 },
{ A: 5.8111416222, B: 5.8111416222, C: 5.8111416222, D: 5.8111416222 },
{ A: 6.9831168755, B: 6.9831168755, C: 6.9831168755, D: 6.9831168755 },
{ A: 7.7740768941, B: 7.7740768941, C: 7.7740768941, D: 7.7740768941 },
{ A: 1.8289323679, B: 1.8289323679, C: 1.8289323679, D: 1.8289323679 },
{ A: 4.6572493636, B: 4.6572493636, C: 4.6572493636, D: 4.6572493636 },
{ A: 3.9538496589, B: 3.9538496589, C: 3.9538496589, D: 3.9538496589 },
{ A: 5.3656233294, B: 5.3656233294, C: 5.3656233294, D: 5.3656233294 },
{ A: 9.6451115564, B: 9.6451115564, C: 9.6451115564, D: 9.6451115564 },
{ A: 4.8884081451, B: 4.8884081451, C: 4.8884081451, D: 4.8884081451 },
{ A: 9.0947397704, B: 9.0947397704, C: 9.0947397704, D: 9.0947397704 },
{ A: 3.7564903423, B: 3.7564903423, C: 3.7564903423, D: 3.7564903423 },
{ A: 4.3942631265, B: 4.3942631265, C: 4.3942631265, D: 4.3942631265 },
{ A: 6.1988258074, B: 6.1988258074, C: 6.1988258074, D: 6.1988258074 },
{ A: 7.1185393668, B: 7.1185393668, C: 7.1185393668, D: 7.1185393668 },
{ A: 5.8015235281, B: 5.8015235281, C: 5.8015235281, D: 5.8015235281 },
{ A: 5.1727270794, B: 5.1727270794, C: 5.1727270794, D: 5.1727270794 },
{ A: 5.9136072277, B: 5.9136072277, C: 5.9136072277, D: 5.9136072277 },
{ A: 6.7641434326, B: 6.7641434326, C: 6.7641434326, D: 6.7641434326 },
{ A: 5.947609068, B: 5.947609068, C: 5.947609068, D: 5.947609068 },
{ A: 6.2604865757, B: 6.2604865757, C: 6.2604865757, D: 6.2604865757 },
{ A: 1.2468121613, B: 1.2468121613, C: 1.2468121613, D: 1.2468121613 },
{ A: 4.5040258655, B: 4.5040258655, C: 4.5040258655, D: 4.5040258655 },
{ A: 4.1135618392, B: 4.1135618392, C: 4.1135618392, D: 4.1135618392 },
{ A: 2.4105655692, B: 2.4105655692, C: 2.4105655692, D: 2.4105655692 },
{ A: 6.8878363848, B: 6.8878363848, C: 6.8878363848, D: 6.8878363848 },
{ A: 3.6167681655, B: 3.6167681655, C: 3.6167681655, D: 3.6167681655 },
{ A: 7.5497438852, B: 7.5497438852, C: 7.5497438852, D: 7.5497438852 },
{ A: 5.363539828, B: 5.363539828, C: 5.363539828, D: 5.363539828 },
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This file duplicates a large amount of data (200+ lines) that is also present in __tests__/data/bee.json. To improve maintainability and avoid inconsistencies, this data should not be duplicated. Instead, you should import it from a shared location. For example, you could move __tests__/data/bee.json to a shared data directory and import it in both the test and this demo file.

Comment on lines +5 to 13
const data: any[] = [];
Data.map((item: Record<string, number>, i) => {
Object.keys(item).map((key) => {
data.push({
x: key,
y: item[key],
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The data transformation logic can be simplified and made more efficient. Using Array.prototype.map for side effects (pushing into an external array) is an anti-pattern, and using any[] for data is not type-safe.

A more idiomatic and safer approach is to use flatMap to produce the new array directly. This improves readability, performance, and type safety.

Suggested change
const data: any[] = [];
Data.map((item: Record<string, number>, i) => {
Object.keys(item).map((key) => {
data.push({
x: key,
y: item[key],
});
});
});
const data = Data.flatMap((item) => Object.entries(item).map(([key, value]) => ({ x: key, y: value })));

Comment on lines +211 to 219
const data = [];
DATA.map((item) => {
Object.keys(item).map((key) => {
data.push({
x: key,
y: item[key],
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the test file, this data transformation logic can be simplified. Using Array.prototype.map for side effects is an anti-pattern. Using flatMap would be more idiomatic and efficient.

Suggested change
const data = [];
DATA.map((item) => {
Object.keys(item).map((key) => {
data.push({
x: key,
y: item[key],
});
});
});
const data = DATA.flatMap((item) => Object.entries(item).map(([key, value]) => ({ x: key, y: value })));

@lxfu1 lxfu1 force-pushed the chore/beeswarm-options branch from f60cc3b to 1401fac Compare December 18, 2025 07:37
@lxfu1 lxfu1 merged commit 9f6cdc1 into v5 Dec 23, 2025
5 checks passed
@lxfu1 lxfu1 deleted the chore/beeswarm-options branch December 23, 2025 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants