import type { DataItem } from "../../core/render/Component"; import type { IGraphics } from "../../core/render/backend/Renderer"; import type { GeoProjection } from "d3-geo"; import type { IPoint } from "../../core/util/IPoint"; import type { ISpritePointerEvent } from "../../core/render/Sprite"; import { MapPolygonSeries, IMapPolygonSeriesSettings, IMapPolygonSeriesDataItem, IMapPolygonSeriesPrivate } from "./MapPolygonSeries"; import { Graphics } from "../../core/render/Graphics"; import { MapPolygon } from "./MapPolygon"; interface IPixelShape { points: Array; across: number; between: number; stagger: boolean; } declare type PolygonEvent = "click" | "dblclick" | "rightclick" | "middleclick" | "pointerdown" | "pointerup" | "pointerover" | "pointerout"; interface IGridRows { rowCount: number; rowStep: number; rowLat: Array; rowLonStep: Array; rowStart: Array; counts: Array; } export interface IPixelMapSeriesPrivate extends IMapPolygonSeriesPrivate { } export interface IPixelMapSeriesDataItem extends IMapPolygonSeriesDataItem { } export interface IPixelMapSeriesSettings extends IMapPolygonSeriesSettings { /** * Distance between the centers of neighbouring pixels, in degrees. With * `uniform`, in degrees as measured at the center of the map. * * Small maps can take a fine step, e.g. `0.01` for a small country. A step * that would make more than 500,000 pixels is coarsened to stay under that, * with a warning in the console. * * @default 2 * @since 5.21.0 */ step?: number; /** * Size of a pixel relative to `step`. At `1` neighbouring pixels touch. * * @default 0.8 * @since 5.21.0 */ pixelSize?: number; /** * Shape of a pixel. At a `pixelSize` of `1` pixels fit edge to edge; * `stagger` sets how rows line up. * * @default "square" * @since 5.21.0 */ pixelType?: "square" | "circle" | "diamond" | "hexagon"; /** * Shifts every other row by half a pixel, like bricks in a wall. * * Squares line up in columns unless this is `true`; circles are staggered * unless this is `false`. Hexagons and diamonds are always staggered, as * that is the only way they fit together. * * Not set by default, so each shape packs its own way. * * @since 5.21.0 */ stagger?: boolean; /** * Spreads pixels evenly over the globe, with fewer per row towards the * poles. The count changes in bands of rows: within a band pixels line up * exactly, and the pattern shifts where one band meets the next. * * Set to `false` for the same number of pixels in every row, which lines up * across the whole map; on a globe pixels then crowd towards the poles. * * @default true * @since 5.21.0 */ equalArea?: boolean; /** * Draws every pixel as wide as a pixel on the equator, with straight sides, * whatever its latitude. Pixels no longer narrow towards the poles, so * they overlap there (most with `equalArea: false`). * * Does not apply with `uniform`. * * @default false * @since 5.21.0 */ equalWidth?: boolean; /** * Lays pixels out on a grid that is even on screen, all the same size and * upright, like a pixel image of the map. The grid scales with zoom; * rotating the map samples it again, so the grid stays level. * * `equalArea` does not apply. * * @default false * @since 5.21.0 */ uniform?: boolean; /** * Raises pixels into 3D columns. The tallest column is this share of the * globe's radius; on flat maps columns rise up the screen by the same * measure. * * `0` keeps pixels flat. Does not apply with `uniform`. * * A column just behind a globe's edge shows where it rises past the edge. * * @default 0 * @since 5.21.0 */ columnHeight?: number; /** * A function that returns the height of each pixel's column, from `0` to * `1` of `columnHeight`. * * Without it, columns take their polygon's `pixelHeight` setting, which * heat rules can set: * * ```TypeScript * series.set("heatRules", [{ * target: series.mapPolygons.template, * dataField: "value", * min: 0.1, * max: 1, * key: "pixelHeight" * }]); * ``` * ```JavaScript * series.set("heatRules", [{ * target: series.mapPolygons.template, * dataField: "value", * min: 0.1, * max: 1, * key: "pixelHeight" * }]); * ``` * * Polygons without that setting follow their value, from the series' * lowest to its highest (set `calculateAggregates: true`); those with no * value stay flat. Without any values every column is full height. * * NOTE: a function is not saved when the chart is serialized to JSON. Heights * set with heat rules are. * * @since 5.21.0 */ pixelHeightFunction?: (dataItem: DataItem, longitude: number, latitude: number) => number; } /** * Shows the polygons of a map as a grid of pixels. * * Each pixel takes the fill of the polygon it falls in, so heat rules, * `templateField` and states work as in [[MapPolygonSeries]]. The polygons * stay, invisible, to handle tooltips, hover and clicks. * * Pixels have no outline by default. Set `strokeWidth` (and `stroke`) on * `mapPolygons.template` to outline each pixel in its polygon's stroke. * * In SVG export ([[renderToSVG]]) each polygon's flat pixels are a group * with the polygon's `id` and `data-name`. Export just the pixels with * `am5.renderToSVG(series.pixels)`. * * Pixels lie on the surface of the map, so on a globe they turn and shrink * towards the edge. With `uniform: true` they sit on an even grid on screen * instead. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/pixel-map-series/} for more information * @important * @since 5.21.0 */ export declare class PixelMapSeries extends MapPolygonSeries { static className: string; static classNames: Array; _settings: IPixelMapSeriesSettings; _privateSettings: IPixelMapSeriesPrivate; _dataItemSettings: IPixelMapSeriesDataItem; /** * The element that draws all pixels. */ readonly pixels: Graphics; protected _hitArea: Graphics; protected _gridDirty: boolean; protected _positionsDirty: boolean; protected _lon: Float64Array; protected _lat: Float64Array; protected _halfLon: Float64Array; protected _halfLat: number; protected _unit: Float64Array; protected _owners: Array>; protected _ownerStart: Uint32Array; protected _vx: Float64Array; protected _vy: Float64Array; protected _shown: Uint8Array; protected _height: Float32Array; protected _heightsDirty: boolean; protected _pixelOwner: Uint32Array; protected _depth: Float64Array; protected _hovered?: MapPolygon; protected _step: number; protected _warnedStep?: number; protected _interactionDirty: boolean; protected _projectionStale: boolean; protected _x: Float64Array; protected _y: Float64Array; protected _spacing: number; protected _view?: { projection: GeoProjection; scale: number; x: number; y: number; clip: string; geo: Array>; probes: Array; }; protected _afterNew(): void; protected _takesPointer(mapPolygon: MapPolygon): boolean; protected _pointerPolygon(event: ISpritePointerEvent): MapPolygon | undefined; /** * The hit area takes part in hit testing only when some polygon would have, * by its own settings or its template's. */ protected _updateInteraction(): void; protected _markInteractionDirty(): void; protected _setHovered(mapPolygon: MapPolygon | undefined, event?: ISpritePointerEvent): void; protected _dispatch(mapPolygon: MapPolygon, type: PolygonEvent, event?: ISpritePointerEvent): void; protected _newMapPolygon(): MapPolygon; /** * @ignore */ makeMapPolygon(dataItem: DataItem): MapPolygon; /** * @ignore */ markDirtyProjection(): void; _prepareChildren(): void; protected processDataItem(dataItem: DataItem): void; /** * @ignore */ disposeDataItem(dataItem: DataItem): void; /** * Redraws the pixels of `dataItem`, laying them out again if its geometry * changed. * * @param dataItem Data item whose pixels to redraw */ markDirtyValues(dataItem: DataItem): void; protected _isLeftOut(dataItem: DataItem): boolean; protected _markGridDirty(): void; protected _markPixelsDirty(): void; protected _markShapesDirty(): void; /** * Lays pixels out again if the projection changed in more than scale and * translation. */ protected _prepareLayout(projection: GeoProjection): void; protected _visibleOwners(): Array; /** * A closed copy of a ring whose longitudes do not jump across the * antimeridian (they may run past 180). A ring that goes round a pole is * closed along that pole. */ protected _unwrapRing(ring: Array>): Array>; /** * Puts a pixel on every grid point that falls inside a polygon, by * scanning each grid row across the polygon's edges. * * Only the cells inside polygons are kept, so a fine step costs memory in * proportion to the pixels, not to the whole globe. */ protected _buildGrid(): void; protected _warnCoarse(requested: number, step: number): void; /** * Grid rows for a step: each row's latitude, spacing, first longitude and * number of cells. */ protected _gridRows(step: number, shape: IPixelShape, equalArea: boolean): IGridRows; /** * The runs of cells inside each owner's polygons, as `row, first cell, last * cell` triples (cells may run past a row's end, and wrap), and how many * cells they cover in all. */ protected _gridSpans(sources: Array>>>>, rows: IGridRows): { spans: Array>; count: number; }; /** * Works out each pixel's column height, from 0 to 1. */ protected _computeHeights(): void; protected _shape(): IPixelShape; /** * Puts a pixel on every point of an even screen grid that falls inside a * polygon as the map draws it (projected, clipped and cut). */ protected _buildScreenGrid(projection: GeoProjection): void; protected _setView(projection: GeoProjection, geo: Array>): void; /** * Projects the outline points of every pixel at their own latitude and * longitude, and marks the pixels a clipped projection (a globe) hides * behind its horizon. */ protected _projectPixels(projection: GeoProjection): void; protected _clipKey(projection: GeoProjection): string; protected _probe(projection: GeoProjection, geo: Array>): Array; /** * Whether the pixels still hold after the projection's scale and * translation changed. Any other change (rotation, center, clipping, a * different projection) needs them laid out again. */ protected _viewHolds(projection: GeoProjection): boolean; protected _drawPixels(display: IGraphics): void; /** * Draws pixels as prisms, far to near: the sides that face the viewer, * shaded by a light from the upper left, then the top. */ protected _drawColumns(display: IGraphics, projection: GeoProjection, k: number, dx: number, dy: number, minX: number, minY: number, maxX: number, maxY: number): void; /** * A surface pixel's outline on screen; a circle as 12 points along its curves. */ protected _screenOutline(i: number, corners: number, circle: boolean, k: number, dx: number, dy: number, xs: Float64Array, ys: Float64Array): void; /** * Weights that turn a surface pixel's outline points into its center and * its east and north half-cell vectors. */ protected _cellWeights(): { east: Array; north: Array; }; /** * A surface pixel's whole cell on screen, as four corners. Cells fit edge to * edge, so together they cover the polygon without gaps. */ protected _cellOutline(i: number, corners: number, weights: { east: Array; north: Array; }, k: number, dx: number, dy: number, xs: Float64Array, ys: Float64Array): void; /** * A column's top on screen, raised from its base. A column behind a * globe's edge (`far`) is cut to the part that rises past the edge, so its * base moves there. Returns `false` when nothing of it shows. */ protected _raise(globe: boolean, far: boolean, lift: number, scale: number, centerX: number, centerY: number, bx: Float64Array, by: Float64Array, tx: Float64Array, ty: Float64Array, count: number): boolean; /** * Draws every pixel's whole cell (or column) in one invisible path, for * hit testing. */ protected _drawHitArea(display: IGraphics): void; /** * Returns the polygon whose pixel cell, or column, is at a point. * * @param point Point in pixels, relative to the root * @return Polygon */ getPolygonByPoint(point: IPoint): MapPolygon | undefined; /** * Returns the number of pixels in the grid. */ pixelCount(): number; protected _layOut(projection: GeoProjection): void; } export {}; //# sourceMappingURL=PixelMapSeries.d.ts.map