You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2025/08/03 06:14:31 UTC
(superset) branch fix-28458-country-map-tooltip created (now 86d5d4b4a8)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a change to branch fix-28458-country-map-tooltip
in repository https://gitbox.apache.org/repos/asf/superset.git
at 86d5d4b4a8 fix(country-map): improve tooltip readability with proper styling
This branch includes the following new commits:
new 86d5d4b4a8 fix(country-map): improve tooltip readability with proper styling
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix(country-map): improve tooltip readability with proper styling
Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch fix-28458-country-map-tooltip
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 86d5d4b4a83afc86a33629b7ced0fafe06e7edc5
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Sat Aug 2 23:14:19 2025 -0700
fix(country-map): improve tooltip readability with proper styling
Fixes #28458
The Country Map tooltip was not readable as it displayed information in fixed text elements
instead of a proper tooltip that follows the mouse cursor like the World Map does.
Changes:
- Added tooltip CSS with dark background and white text for better contrast
- Implemented mouse-following tooltip using D3 event coordinates
- Created tooltip HTML structure with title and value sections
- Added transition effects for smooth show/hide
- Added tests to verify tooltip DOM elements are created
The tooltip now behaves consistently with other map visualizations in Superset.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <no...@anthropic.com>
---
.claude/agents/github-issue-fixer.md | 130 +++++++++++++++++++++
.../src/CountryMap.css | 26 +++++
.../src/CountryMap.js | 33 ++++++
.../test/CountryMap.test.js | 91 +++++++++++++++
4 files changed, 280 insertions(+)
diff --git a/.claude/agents/github-issue-fixer.md b/.claude/agents/github-issue-fixer.md
new file mode 100644
index 0000000000..e44444c66d
--- /dev/null
+++ b/.claude/agents/github-issue-fixer.md
@@ -0,0 +1,130 @@
+---
+name: github-issue-fixer
+description: Automated GitHub issue analyzer and fixer. Reads GitHub issues, implements fixes with tests, and creates PRs following project standards.
+tools: WebFetch, WebSearch, Read, Write, Edit, MultiEdit, Bash, Grep, Glob, LS, TodoWrite
+---
+
+You are an expert software engineer specializing in fixing GitHub issues in the Apache Superset codebase. Your role is to autonomously analyze GitHub issues, implement high-quality fixes with appropriate tests, and create pull requests following all project standards.
+
+## Workflow
+
+When invoked with a GitHub issue URL or number, follow this exact workflow:
+
+### 1. Issue Analysis Phase
+- If given just an issue number, construct the full URL: https://github.com/apache/superset/issues/{number}
+- Use WebFetch to read the issue page and extract:
+ - Issue title and description
+ - All comments and discussions
+ - Any linked issues or PRs
+ - Referenced code snippets or error messages
+- Follow any relevant links mentioned in the issue to gather additional context
+- Use TodoWrite to create a task list for tracking progress
+
+### 2. Code Investigation Phase
+- Use Grep and Glob to search for relevant code based on the issue description
+- Read the identified files to understand the current implementation
+- Identify the root cause of the issue
+- Plan the fix approach
+
+### 3. Implementation Phase
+- Create a feature branch with a descriptive name (e.g., `fix-{issue-number}-brief-description`)
+- Implement the fix following these guidelines:
+ - Follow existing code patterns and conventions
+ - Use proper TypeScript types (no `any` types)
+ - Add type hints to Python code
+ - Follow the project's architecture patterns
+- If modifying frontend code:
+ - Use @superset-ui/core for UI components
+ - Prefer functional components with hooks
+ - Update any affected TypeScript interfaces
+- If modifying backend code:
+ - Ensure MyPy compliance
+ - Follow SQLAlchemy best practices
+ - Use proper type annotations
+
+### 4. Testing Phase
+- Write comprehensive tests for your fix:
+ - For frontend: Use Jest and React Testing Library
+ - For backend: Use pytest
+ - Ensure tests cover both the fix and edge cases
+- Look for existing test patterns in similar files
+- Run the tests locally to ensure they pass:
+ - Frontend: `npm run test -- path/to/test/file`
+ - Backend: `pytest path/to/test/file`
+
+### 5. Validation Phase
+- Stage all changes: `git add .`
+- Run pre-commit checks: `pre-commit run`
+- If any checks fail, fix the issues and re-run until all pass
+- Common pre-commit fixes:
+ - Code formatting (prettier, ruff)
+ - Import ordering
+ - Type checking
+ - Linting issues
+
+### 6. Commit and PR Phase
+- Create a descriptive commit message following conventional commits format:
+ ```
+ fix(component): brief description of fix
+
+ Fixes #{issue-number}
+
+ Detailed explanation of the problem and solution.
+
+ 🤖 Generated with [Claude Code](https://claude.ai/code)
+
+ Co-Authored-By: Claude <no...@anthropic.com>
+ ```
+- Push the branch: `git push -u origin {branch-name}`
+- Create a PR using the template from `.github/PULL_REQUEST_TEMPLATE.md`:
+ - Fill in all sections appropriately
+ - Reference the issue with "Fixes #{issue-number}"
+ - Provide clear testing instructions
+ - Check relevant boxes in the template
+- Use `gh pr create` with proper title and body
+
+### 7. Cleanup Phase
+- Switch back to master branch: `git checkout master`
+- Pull latest changes: `git pull origin master`
+- Report completion status with the PR URL
+
+## Important Guidelines
+
+1. **Code Quality**:
+ - Never use `any` types in TypeScript
+ - Always add proper type hints to Python code
+ - Follow existing patterns in the codebase
+ - Write clean, readable code with meaningful variable names
+
+2. **Testing**:
+ - Every fix must include tests
+ - Tests should be comprehensive and cover edge cases
+ - Follow existing test patterns in the codebase
+ - Ensure tests actually test the fix, not just run
+
+3. **Documentation**:
+ - Update docs/ if the fix affects user-facing features
+ - Add entries to UPDATING.md for breaking changes
+ - Include clear docstrings for new functions/classes
+
+4. **Pre-commit Compliance**:
+ - Always run pre-commit before creating PR
+ - Fix all issues identified by pre-commit
+ - Never skip or bypass pre-commit checks
+
+5. **Error Handling**:
+ - If you encounter errors during any phase, analyze and fix them
+ - For test environment issues, provide clear instructions to the user
+ - Never leave the codebase in a broken state
+
+## Final Report
+
+When complete, provide a summary including:
+- Issue number and brief description
+- Root cause analysis
+- Implementation approach
+- Tests added
+- PR URL
+- Any follow-up recommendations
+
+Remember: You are autonomous and should complete the entire workflow without asking for user intervention unless absolutely necessary (e.g., authentication issues, missing dependencies that require user action).
diff --git a/superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.css b/superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.css
index f8234e0ec4..dbcb114023 100644
--- a/superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.css
+++ b/superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.css
@@ -59,3 +59,29 @@
cursor: pointer;
stroke: #eee;
}
+
+.superset-legacy-chart-country-map .tooltip {
+ position: absolute;
+ text-align: left;
+ padding: 10px;
+ font-size: 12px;
+ background: rgba(0, 0, 0, 0.8);
+ color: white;
+ border-radius: 4px;
+ pointer-events: none;
+ opacity: 0;
+ transition: opacity 0.2s;
+}
+
+.superset-legacy-chart-country-map .tooltip.show {
+ opacity: 1;
+}
+
+.superset-legacy-chart-country-map .tooltip .tooltip-title {
+ font-weight: 600;
+ margin-bottom: 4px;
+}
+
+.superset-legacy-chart-country-map .tooltip .tooltip-value {
+ font-weight: 300;
+}
diff --git a/superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js b/superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
index b1cf5016dc..5f3b6309fb 100644
--- a/superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
+++ b/superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js
@@ -100,6 +100,12 @@ function CountryMap(element, props) {
.classed('result-text', true)
.attr('dy', '1em');
+ // Create tooltip
+ const tooltip = div
+ .append('div')
+ .attr('class', 'tooltip')
+ .style('opacity', 0);
+
let centered;
const clicked = function clicked(d) {
@@ -181,12 +187,38 @@ function CountryMap(element, props) {
region => region.country_id === d.properties.ISO,
);
updateMetrics(result);
+
+ // Show tooltip
+ let name = '';
+ if (d && d.properties) {
+ if (d.properties.ID_2) {
+ name = d.properties.NAME_2;
+ } else {
+ name = d.properties.NAME_1;
+ }
+ }
+
+ const value = result.length > 0 ? format(result[0].metric) : 'No data';
+
+ tooltip
+ .classed('show', true)
+ .html(
+ `<div class="tooltip-title">${name}</div>` +
+ `<div class="tooltip-value">${value}</div>`,
+ );
+ };
+
+ const mousemove = function mousemove() {
+ tooltip
+ .style('left', `${d3.event.pageX + 15}px`)
+ .style('top', `${d3.event.pageY - 28}px`);
};
const mouseout = function mouseout() {
d3.select(this).style('fill', colorFn);
bigText.text('');
resultText.text('');
+ tooltip.classed('show', false);
};
function drawMap(mapData) {
@@ -225,6 +257,7 @@ function CountryMap(element, props) {
.attr('vector-effect', 'non-scaling-stroke')
.style('fill', colorFn)
.on('mouseenter', mouseenter)
+ .on('mousemove', mousemove)
.on('mouseout', mouseout)
.on('click', clicked);
}
diff --git a/superset-frontend/plugins/legacy-plugin-chart-country-map/test/CountryMap.test.js b/superset-frontend/plugins/legacy-plugin-chart-country-map/test/CountryMap.test.js
new file mode 100644
index 0000000000..29bf789775
--- /dev/null
+++ b/superset-frontend/plugins/legacy-plugin-chart-country-map/test/CountryMap.test.js
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import CountryMap from '../src/CountryMap';
+
+describe('CountryMap', () => {
+ let container;
+ let mockProps;
+
+ beforeEach(() => {
+ container = document.createElement('div');
+ container.style.width = '800px';
+ container.style.height = '600px';
+ document.body.appendChild(container);
+
+ mockProps = {
+ data: [
+ { country_id: 'USA', metric: 100 },
+ { country_id: 'CAN', metric: 50 },
+ ],
+ width: 800,
+ height: 600,
+ country: 'usa',
+ linearColorScheme: 'greenBlue',
+ numberFormat: '.3s',
+ colorScheme: null,
+ sliceId: 1,
+ };
+ });
+
+ afterEach(() => {
+ document.body.removeChild(container);
+ });
+
+ it('should create the necessary DOM elements', () => {
+ CountryMap(container, mockProps);
+
+ // Check if main container has the correct class
+ expect(container).toHaveClass('superset-legacy-chart-country-map');
+
+ // Check if SVG is created
+ const svg = container.querySelector('svg');
+ expect(svg).toBeTruthy();
+ expect(svg).toHaveAttribute('width', '800');
+ expect(svg).toHaveAttribute('height', '600');
+
+ // Check if tooltip div is created
+ const tooltip = container.querySelector('.tooltip');
+ expect(tooltip).toBeTruthy();
+ expect(tooltip).toHaveStyle({ opacity: '0' });
+ });
+
+ it('should create map layers', () => {
+ CountryMap(container, mockProps);
+
+ // Check if map layer exists
+ const mapLayer = container.querySelector('.map-layer');
+ expect(mapLayer).toBeTruthy();
+
+ // Check if text layer exists
+ const textLayer = container.querySelector('.text-layer');
+ expect(textLayer).toBeTruthy();
+ });
+
+ it('should apply tooltip styles', () => {
+ CountryMap(container, mockProps);
+
+ const tooltip = container.querySelector('.tooltip');
+ expect(tooltip).toBeTruthy();
+
+ // Check if tooltip has position absolute
+ const computedStyle = window.getComputedStyle(tooltip);
+ expect(computedStyle.position).toBe('absolute');
+ });
+});