Skip to content

EchartsLayer (ECharts Layer)

Create and manage an ECharts layer on a 3D map.

Constructor

ts
new ge3d.object.EchartsLayer(options?: {}): EchartsLayer

Parameters (Options)

ParameterTypeDefaultDescription
optionObject-ECharts configuration object (see ECharts Option below)
pointerEventsBoolean-Whether to enable pointer events
depthTestBooleantrueEnable depth testing
autoHeightBooleanfalseEnable automatic height calculation
fixedHeightNumber0Fixed height value
zIndexNumber9Z-index of the layer
ge3dMapObject-ge3dMap coordinate system configuration

ECharts Option

The option parameter accepts a standard ECharts configuration object with support for ge3dMap coordinate system.

Basic Options

ParameterTypeDefaultDescription
animationBooleantrueWhether to enable animation
visualMapObject-Visual mapping component configuration (see VisualMap Options below)

VisualMap Options

ParameterTypeDefaultDescription
minNumber-Minimum value for visual mapping
maxNumber-Maximum value for visual mapping
bottomString-Distance from bottom (e.g., "5%")
rightString-Distance from right (e.g., "5%")
itemHeightNumber-Height of visual map items
showBooleantrueWhether to show visual map

Series Options

The series parameter is an array of series configurations. Each series can use ge3dMap coordinate system.

EffectScatter Series
ParameterTypeDefaultDescription
typeString-Series type, set to "effectScatter"
coordinateSystemString-Coordinate system, use "ge3dMap" for 3D map
showEffectOnString-When to show effect ("render" or "emphasis")
colorByString-Color mapping method ("data" or "series")
effectTypeString-Effect type (e.g., "ripple")
zlevelNumber0Z-level for rendering
rippleEffectObject-Ripple effect configuration (see RippleEffect Options below)
labelObject-Label configuration (see Label Options below)
symbolString-Symbol type ("circle", "pin", "diamond", etc.)
itemStyleObject-Item style configuration (see ItemStyle Options below)
dataArray-Data array (see Data Format below)
markLineObject-Mark line configuration
RippleEffect Options
ParameterTypeDefaultDescription
periodNumber-Animation period
scaleNumber-Scale factor
brushTypeString-Brush type ("fill" or "stroke")
Label Options
ParameterTypeDefaultDescription
normalObject-Normal state label configuration
normal.showBoolean-Whether to show label
normal.formatterString-Label formatter (e.g., "{b}")
normal.positionString-Label position (e.g., "top")
normal.offsetArray-Label offset [x, y]
normal.colorString-Label color
emphasisObject-Emphasis state label configuration
emphasis.showBoolean-Whether to show label on emphasis
ItemStyle Options
ParameterTypeDefaultDescription
normalObject-Normal state style configuration
normal.showBoolean-Whether to show item
normal.shadowBlurNumber-Shadow blur radius
normal.shadowColorString-Shadow color
Lines Series
ParameterTypeDefaultDescription
typeString-Series type, set to "lines"
coordinateSystemString-Coordinate system, use "ge3dMap" for 3D map
zlevelNumber0Z-level for rendering
effectObject-Line effect configuration (see LineEffect Options below)
lineStyleObject-Line style configuration (see LineStyle Options below)
dataArray-Line data array (see LineData Format below)
LineEffect Options
ParameterTypeDefaultDescription
showBoolean-Whether to show effect
periodNumber-Animation period
trailLengthNumber-Trail length
symbolString-Symbol type (e.g., "arrow")
symbolSizeNumber-Symbol size
shadowBlurNumber-Shadow blur radius
shadowColorString-Shadow color
LineStyle Options
ParameterTypeDefaultDescription
typeString-Line type ("solid", "dashed", "dotted", or array [5, 10] for custom)
widthNumber-Line width
opacityNumber-Line opacity (0-1)
curvenessNumber-Line curveness (0-1)
colorString/Object-Line color (string or gradient object)
shadowBlurNumber-Shadow blur radius
shadowColorString-Shadow color
LineStyle Color Gradient

When color is an object, it can be a gradient configuration:

ParameterTypeDefaultDescription
typeString-Gradient type ("linear" or "radial")
xNumber-Start x coordinate (0-1)
yNumber-Start y coordinate (0-1)
x2Number-End x coordinate (0-1)
y2Number-End y coordinate (0-1)
colorStopsArray-Color stops array
colorStops[].offsetNumber-Color stop offset (0-1)
colorStops[].colorString-Color at this stop
globalBooleanfalseWhether gradient is global
Data Format

For EffectScatter series, data items can be objects with the following structure:

ParameterTypeDescription
keyStringUnique key identifier
nameStringDisplay name
latitudeAndLongitudeStringLatitude and longitude string (e.g., "46.6753,24.7136")
countsNumberCount value
valueArrayValue array [lng, lat, value]
LineData Format

For Lines series, data items should be objects with the following structure:

ParameterTypeDescription
coordsArrayArray of coordinate pairs [[lng1, lat1], [lng2, lat2]]
valueNumberLine value

Properties

PropertyTypeDescription
echartsInstanceecharts.EChartsTypeECharts instance
pointerEventsBooleanWhether pointer events are enabled

Methods

setEchartsOption

Set ECharts configuration option

ts
setEchartsOption(option: Object, notMerge?: Boolean, lazyUpdate?: Boolean): void

Parameters:

  • option: ECharts configuration object
  • notMerge: Whether to not merge with previous option (optional)
  • lazyUpdate: Whether to lazy update (optional)

resize

Resize the ECharts layer

ts
resize(): void

setVisible

Set layer visibility

ts
setVisible(visible: Boolean): void

Parameters:

  • visible: Whether to show the layer

getBounds

Get the bounds of the layer data

ts
getBounds(returnObject?: { returnObject: Boolean }): Cesium.Rectangle | Object | null

Parameters:

  • returnObject: If provided with returnObject: true, returns an object with {xmin, xmax, ymin, ymax}. Otherwise returns a Cesium.Rectangle.

Returns:

  • Cesium.Rectangle or Object with bounds, or null if no data

addEventListener

Add event listener

ts
addEventListener(eventName: String, handler: Function, context?: Object): void

Parameters:

  • eventName: Event name (ECharts event name)
  • handler: Event handler function
  • context: Context object (optional)

onByQuery

Add event listener by query

ts
onByQuery(eventName: String, query: String | Object, handler: Function, context?: Object): EchartsLayer

Parameters:

  • eventName: Event name
  • query: Query string or object to filter events
  • handler: Event handler function
  • context: Context object (optional)

Returns:

  • Returns EchartsLayer instance for chaining

removeEventListener

Remove event listener

ts
removeEventListener(eventName: String, handler: Function): EchartsLayer

Parameters:

  • eventName: Event name
  • handler: Event handler function

Returns:

  • Returns EchartsLayer instance for chaining

Coordinate System

The EchartsLayer supports the ge3dMap coordinate system, which allows ECharts to render on the 3D map. When using ge3dMap coordinate system:

  • Data coordinates should be in [longitude, latitude] format
  • The coordinate system automatically handles 3D projection
  • Supports depth testing and automatic height calculation

Example

ts
const options = {
  animation: false,
  visualMap: { 
    min: 0, 
    max: 15, 
    bottom: "5%", 
    right: "5%", 
    itemHeight: 30, 
    show: true 
  },
  series: [
    {
      type: "effectScatter",
      coordinateSystem: "ge3dMap",
      showEffectOn: "render",
      colorBy: 'data',
      effectType: 'ripple',
      zlevel: 0,
      rippleEffect: { 
        period: 15, 
        scale: 12, 
        brushType: "fill" 
      },
      label: { 
        normal: { 
          show: true, 
          formatter: "{b}", 
          position: "top", 
          offset: [5, 0], 
          color: "#ff00B6" 
        }, 
        emphasis: { show: true } 
      },
      symbol: "pin",
      itemStyle: { 
        normal: { 
          show: true, 
          shadowBlur: 10, 
          shadowColor: "#3300ff" 
        } 
      },
      data: [
        { 
          key: "Riyadh", 
          name: "Riyadh", 
          latitudeAndLongitude: "46.6753,24.7136", 
          counts: 15, 
          value: [46.6753, 24.7136, 15] 
        }
      ]
    },
    {
      type: "lines",
      coordinateSystem: "ge3dMap",
      zlevel: 0,
      effect: { 
        shadowBlur: 10,
        shadowColor: 'rgba(0, 0, 0, 1.0)',
        show: true, 
        period: 4, 
        trailLength: 20, 
        symbol: "arrow", 
        symbolSize: 24 
      },
      lineStyle: { 
        type: "dashed",
        width: 2, 
        opacity: 1, 
        curveness: 0.3, 
        color: {
          type: 'linear',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [{
            offset: 0, 
            color: 'yellow'
          }, {
            offset: 1, 
            color: 'red'
          }],
          global: false
        }
      },
      data: [
        {
          coords: [
            [46.6753, 24.7136],
            [39.192, 21.4858]
          ],
          value: 1
        }
      ]
    }
  ]
};

const echartsLayer = new ge3d.object.EchartsLayer(options);
core.addObject(echartsLayer);

window.addEventListener("resize", function () {
  echartsLayer.resize();
});