Skip to content
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

feat: support maidr object handling with an attribute to svg or img tag #634

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

dakshpokar
Copy link
Collaborator

@dakshpokar dakshpokar commented Feb 19, 2025

Pull Request

Description

This PR adds the ability to configure MAIDR through HTML attributes, while maintaining backward compatibility with the existing script-based configuration method. Now users can initialize MAIDR in two ways:

Traditional script-based method (existing):

var maidr = {
    id: "chart1",
    type: "bar",
    // ... other configuration
};

New attribute-based method:

<svg id="chart1" maidr='{"type": "bar", "data": {...}}'>...</svg>

Changes Made

  1. Added support for parsing maidr configuration from HTML elements with maidr attribute
  2. Maintained backward compatibility with existing script-based configuration
  3. Added a bar chart example with attribute based initialization of maidr object.

Screenshots (if applicable)

Checklist

  • I have read the Contributor Guidelines.
  • I have performed a self-review of my own code and ensured it follows the project's coding standards.
  • I have tested the changes locally following ManualTestingProcess.md, and all tests related to this pull request pass.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation, if applicable.
  • I have added appropriate unit tests, if applicable.

Additional Notes

@dakshpokar
Copy link
Collaborator Author

Greetings Professor @jooyoungseo,

This PR implements HTML attribute-based configuration for MAIDR, allowing users to define chart configurations directly in their HTML markup. This enhancement provides a more flexible and maintainable way to initialize MAIDR without requiring separate script tags.

Key Implementation Details:

  • Added support for maidr attribute in HTML elements (SVG/IMG) that accepts stringified JSON configuration
  • Maintains full backward compatibility with existing script-based configuration
  • Added a bar chart example with attribute based initialization of maidr object.

Example Usage:

<!-- New attribute-based configuration -->
<svg id="chart1" maidr='{"type": "bar", "title": "Sales Data", "data": [...]}'>
  <!-- chart content -->
</svg>
<!-- Traditional script-based configuration still works -->
<script>
var maidr = { id: "chart2", type: "scatter", ... };
</script>

Thanks,
Daksh Pokar
cc: @ellvix @SaaiVenkat

@jooyoungseo jooyoungseo changed the title feat: maidr object handling with an attribute to svg or img tag feat: support maidr object handling with an attribute to svg or img tag Feb 19, 2025
Copy link
Member

@jooyoungseo jooyoungseo left a comment

Choose a reason for hiding this comment

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

LGTM! Go go!

@jooyoungseo jooyoungseo merged commit 9c4071f into main Feb 19, 2025
1 check passed
@jooyoungseo jooyoungseo deleted the feat/maidr-data-svg-img branch February 19, 2025 01:09
github-actions bot pushed a commit that referenced this pull request Feb 20, 2025
# [2.29.0](v2.28.2...v2.29.0) (2025-02-20)

### Features

* support maidr object handling with an attribute to svg or img tag ([#634](#634)) ([9c4071f](9c4071f))
Copy link
Contributor

🎉 This PR is included in version 2.29.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants