Skip to content

Commit ac58c07

Browse files
Adapt Heatmap layer for an easier use with a ColormapControl.
1 parent 79e7d94 commit ac58c07

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ipyleaflet/leaflet.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import copy
66
import asyncio
77
import json
8-
from folium import LinearColormap
98
import xyzservices
109
from datetime import date, timedelta
1110
from math import isnan
12-
from branca.colormap import linear, ColorMap
11+
from branca.colormap import linear, LinearColormap, ColorMap
1312
from IPython.display import display
1413
import warnings
1514

@@ -800,8 +799,16 @@ class Heatmap(RasterLayer):
800799
Radius of the data points.
801800
blur: float, default 15.
802801
Blurring intensity.
803-
gradient: dict, default {0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'}
802+
values : list, default [0.4, 0.6, 0.7, 0.8, 1.0]
803+
list of values to define the gradient
804+
colors : list, default ['blue', 'cyan', 'lime', 'yellow', 'red']
805+
list of colors to define the gradient
806+
dict: dict, default built from values (keys) and colors lists (values)
807+
dictionnary mapping value to colors.
808+
gradient : Dict, default built from dict
804809
Colors used for the color-mapping from low to high heatmap intensity.
810+
colormap: branca.colormap.LinearColorMap instance
811+
The colormap used for displaying the HeatMap data, defined with the same min and max values and colors than the gradient.
805812
"""
806813

807814
_view_name = Unicode('LeafletHeatmapView').tag(sync=True)
@@ -823,8 +830,7 @@ class Heatmap(RasterLayer):
823830
vmin = values[0]
824831
vmax = values[len(values)-1]
825832
gradient = Dict(dict).tag(sync=True, o=True)
826-
colormap = LinearColormap([colors], vmin=vmin, vmax=vmax)
827-
833+
colormap = LinearColormap(colors, vmin=vmin, vmax=vmax)
828834

829835

830836
class VectorTileLayer(Layer):

0 commit comments

Comments
 (0)