# From npm (for use in your projects)
npm install screengrid
npm install maplibre-gl
# Or clone for development
git clone https://github.com/danylaksono/screengrid.git
cd screengrid
npm install
npm run build
# Start a local HTTP server
npx http-server -p 8000
# or
npm start
screengrid/
├── src/ # Source code (modular architecture)
│ ├── index.js # Main entry point
│ ├── ScreenGridLayerGL.js # Main orchestrator
│ ├── core/ # Core business logic
│ ├── canvas/ # Canvas rendering
│ ├── events/ # Event system
│ ├── glyphs/ # Glyph utilities & plugins
│ ├── aggregation/ # Aggregation modes & functions
│ ├── normalization/ # Normalization functions
│ ├── utils/ # Utilities (Logger, DataUtilities)
│ └── legend/ # Legend system
├── dist/ # Built distribution files
├── docs/ # Documentation
├── examples/ # Example HTML files
├── package.json # NPM package configuration
└── README.md # Main documentation
hex-mode.html: Complete hexagonal aggregation with controlshex-mode-simple.html: Simple hex mode demonstrationgrouped-bar plugin)timeseries.html: Single-variable temporal visualizationmultivariate-timeseries.html: Multi-attribute temporal dataus-states.html: Polygon features with centroid anchorssource, placement, and renderMode optionsgroupBy, extractAttributes, computeStats, groupByTimenpm run build
# Outputs to dist/ folder:
# - screengrid.mjs (ESM)
# - screengrid.cjs (CJS)
# - screengrid.umd.js (UMD)
# - screengrid.umd.min.js (UMD minified)
core/, canvas/, etc.)src/index.jsdocs/examples/When you switch to glyph-based rendering (enableGlyphs: true with either onDrawCell or a glyph plugin), the default behaviour is to turn off the colored cell background so the glyphs stand out. If you want to keep the heatmap-style background behind your glyphs, set:
const gridLayer = new ScreenGridLayerGL({
// ...other options
enableGlyphs: true,
onDrawCell: myGlyphFn,
aggregationModeConfig: {
showBackground: true // explicitly opt-in to background when using glyphs
}
});
cellSizePixels for performance vs detail tradeoffenableGlyphs: true and glyph callback/plugin is providedsource and placement are correctly configuredEnable verbose debug logging via the debugLogs option:
const gridLayer = new ScreenGridLayerGL({
// ... other options
debugLogs: true // Enable verbose debug logging
});
Or programmatically:
import { setDebug } from 'screengrid';
setDebug(true); // Enable debug logging globally
The library provides detailed logging for:
Note: Debug logs are disabled by default for performance. Enable only when troubleshooting.
npm install screengrid maplibre-gl
const gridLayer = new ScreenGridLayerGL({ data: yourData, getPosition: (d) => d.coordinates, getWeight: (d) => d.weight, cellSizePixels: 60 });
map.addLayer(gridLayer);
### With Build Tools
The library is ES module compatible and works with:
- Webpack
- Vite
- Rollup
- Parcel
- Native ES modules
### CDN Usage
```html
<script src="https://unpkg.com/screengrid/dist/screengrid.umd.min.js"></script>
<script src="https://unpkg.com/maplibre-gl@^4/dist/maplibre-gl.js"></script>
<script>
const { ScreenGridLayerGL } = ScreenGrid;
// use ScreenGridLayerGL here
</script>
Run tests (if test framework is configured):
npm test