0.0.19 • Published 2 months ago

@geoblocks/elevation-profile v0.0.19

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
2 months ago

<elevation-profile>

A web component to display an elevation profile of a MultiLineString.

Installation

npm i --save @geoblocks/elevation-profile

Usage

 <elevation-profile .lines="${lines}"></elevation-profile>

API

Properties/Attributes

NameTypeDefaultDescription
linesnumber[][][]MultiLineString coordinates
pointsnumber[][]Points to be displayed on the profile
marginObject{top: 20, right: 20, bottom: 20, left: 40}Margin in pixels around the elevation profile
pointerEventsBooleantrueWhether to emit pointer events
tickSizeObject{x: 100, y: 40}Size of the ticks in pixels
localestringnavigator.languageLocale for the axis labels
tolerancenumber1Tolerance for the line simplification. Set to 0 to disable simplification

Ticks formating

The value of the tick in the axis can be changed by overriding the tickFormat method.

profile.tickFormat = (value, axis) => {
  return Math.round(value);
};

Where value is the value of the tick and axis is the axis where the tick is located (x or y).

Tick values

Ticks can be set manually using the tickValues method, passing an array of values and the desired axis (x of y). If values is null or the axis is not specified, ticks will be generated automatically.

profile.tickValues([100, 150, 200, 250], 'y');

Adding points

Points can be added to the profile by setting the points property. By default, the points will be displayed as circles on the profile. This can be changed by overriding the pointSvg method.

profile.pointSvg = (x, y, index) => {
  return `<circle cx="${x}" cy="${y}" r="5" fill="red" />`;
};

Where x and y are the position in pixels and index is the index of the point in the points array.

Events

If pointerEvents is true, the component will emit the following custom events on pointer interaction:

NameWhenDetail typeDescription
overThe pointer is over the profile{coordinate: number[], position: {x: number, y: number}}coordinate is the coordinate of the point on the MultiLineString and position is the position of the pointer relative to the component
outThe pointer leaves the profile

Styling

TODO: describe CSS selectors

0.0.19

2 months ago

0.0.18

2 months ago

0.0.15

2 months ago

0.0.16

2 months ago

0.0.17

2 months ago

0.0.14

3 months ago

0.0.12

3 months ago

0.0.13

3 months ago

0.0.11

5 months ago

0.0.10

5 months ago

0.0.9

5 months ago

0.0.8

5 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago