-
Notifications
You must be signed in to change notification settings - Fork 711
fix: series list issue for color override config on pie chart #8540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR fixes a data extraction issue in the ColorBySeries.vue component that was preventing users from configuring color overrides for pie and donut charts. The change addresses a fundamental difference in how chart data is structured between pie/donut charts versus other chart types.
In the existing codebase, the color override functionality works by extracting series names from the chart options to populate a dropdown for users to select which series to customize. However, pie and donut charts store their series information differently - instead of having multiple series objects, they have a single series with data points stored in series[0].data[].name, where each data point represents a segment of the pie/donut.
The fix adds conditional logic in the seriesOptions computed property that detects when the chart type is pie or donut, then extracts series names from the appropriate data structure (chartOptions.series[0].data.name). For all other chart types, it maintains the existing logic to ensure backward compatibility. The implementation includes proper validation by filtering out invalid items before mapping the data.
This change integrates seamlessly with the dashboard's existing color customization system, allowing users to override colors for individual pie/donut segments just like they can for other chart types, providing a consistent user experience across all chart types in the dashboard builder.
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it only affects the ColorBySeries component's data extraction logic
- Score reflects a focused fix with proper conditional logic and backward compatibility maintained
- Pay close attention to the conditional logic in ColorBySeries.vue to ensure pie/donut detection works correctly
1 file reviewed, 1 comment
| .map((item: any) => ({ | ||
| name: item.name, | ||
| })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Trailing spaces after the opening brace on line 118. Clean up whitespace for consistency.
| .map((item: any) => ({ | |
| name: item.name, | |
| })); | |
| .map((item: any) => ({ | |
| name: item.name, | |
| })); |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
### **PR Type**
Bug fix, Enhancement
___
### **Description**
- Correct series extraction for pie/donut
- Fallback to existing options logic
- Prevent invalid items via filtering
___
### Diagram Walkthrough
```mermaid
flowchart LR
A["panelType check"] -- "pie/donut" --> B["extract from data[].name"]
A -- "other types" --> C["use existing options"]
B -- "build series list" --> D["return { series: names }"]
C -- "fallback" --> E["return options or empty series"]
```
<details> <summary><h3> File Walkthrough</h3></summary>
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Bug
fix</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>ColorBySeries.vue</strong><dd><code>Properly derive
series for pie/donut charts</code>
</dd></summary>
<hr>
web/src/components/dashboards/addPanel/ColorBySeries.vue
<ul><li>Add panel type detection for pie/donut.<br> <li> Extract series
names from data[].name.<br> <li> Filter out invalid data items.<br> <li>
Preserve fallback to existing options.</ul>
</details>
</td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8540/files#diff-2783259507b45f0b3664d9be68ca236690bbbf151472da3fa8b552d230af5b3f">+16/-0</a>
</td>
</tr>
</table></td></tr></tr></tbody></table>
</details>
___
PR Type
Bug fix, Enhancement
Description
Correct series extraction for pie/donut
Fallback to existing options logic
Prevent invalid items via filtering
Diagram Walkthrough
flowchart LR A["panelType check"] -- "pie/donut" --> B["extract from data[].name"] A -- "other types" --> C["use existing options"] B -- "build series list" --> D["return { series: names }"] C -- "fallback" --> E["return options or empty series"]File Walkthrough
ColorBySeries.vue
Properly derive series for pie/donut chartsweb/src/components/dashboards/addPanel/ColorBySeries.vue