Skip to content

Adds Chart plugin#94

Open
BhattaraiSijan wants to merge 8 commits into
feat/draw-aoi-pluginfrom
feat/chart-plugin
Open

Adds Chart plugin#94
BhattaraiSijan wants to merge 8 commits into
feat/draw-aoi-pluginfrom
feat/chart-plugin

Conversation

@BhattaraiSijan
Copy link
Copy Markdown
Collaborator

Purpose

Adds the Chart plugin — receiver-only consumer of plugin:aoi:analysisReady. Renders the AOI plugin's per-layer statistics payload as cards with a histogram and stat grid. No fetching, no per-layer config; purely a display surface for what AOI publishes.

Proposed Changes

  • [ADD] src/essence/Tools/Chart/ — new plugin
    • ChartTool.js — MMGIS wrapper. Module-level subscription to plugin:aoi:analysisReady (so the event reaches Chart even when AOI is the active tool), stashes the latest payload, auto-opens the Chart panel via toolButtonChart, mounts React.
    • ChartComponent.tsx — presentational panel. Header + one card per (layer, asset):
      • headline mean + "X% valid · N pixels"
      • histogram bar chart via chart.js (tooltip shows the bin's lo–hi range and pixel count)
      • 6-stat grid: min / max / median / std / 2nd %ile / 98th %ile
    • chartHelpers.ts — pure helpers
    • ChartComponent.css

Bus surface

  • Listens (module scope): plugin:aoi:analysisReady { analysisData: { [layerName]: <stats | null> } }
  • No emits, no provides, no requests.

Issues

Testing

Manually tested on a DeckGL mission with two analysis-supported layers:

  • AOI → draw → Analyze area → Chart panel auto-opens with cards (Chart was not the active tool at click time)
  • Multi-band layer (colorir, bidx 1/2/3) → three cards, one per band; single-band layer (dnbr) → one card
  • Layer whose /statistics POST returns non-2xx (or its entry is null in the payload) → the layer's card shows "Could not fetch statistics for this"; other layers still render
  • 200 with valid_pixels === 0 → card shows "No usable pixels in this area"
  • Tested on macOS, Chrome

Known follow-ups (not blocking)

  • Card titles show the layer UUID instead of the display name — owned on the AOI side (analysisData payload is keyed by layer.name, which MMGIS internally rewrites to the UUID). Fix is display_name || name on the emit, to land on a future AOI iteration.
  • Module-level subscription uses a setInterval retry while window.mmgisAPI finishes binding — should become mmgisAPI.whenReady() once the bus exposes a ready contract.

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.

1 participant