Fill between multi_line

I wrote a routine to do this on the JS side for my XS tool (Aqua Insight Inc. - Hydrographs) by stitching together a series of patch geometries based on the coords of each array of line coords and the array of line coords below it (so iterating through the length of the multiline source - 1). You just have to ensure your multiline source is ordered the way you want beforehand.

Pythony pseudo code wise, it’s along the lines of:

patch_geoms = {'xs':[],'ys':[]}

for i in range(len(multiline_src.data['xs'])-1):
    #get the upper line coords
    upperX = multiline_src.data['xs'][i]
    upperY = multiline_src.data['xs'][i]
    #get the lower line coords
    lowerX = multiline_src.data['xs'][i+1]
    lowerY = multiline_src.data['xs'][i+1]
    #x geom for the patch will be the upperX + the lowerX reversed (kinda stitching together "clockwise)
    geomX = upperX+lower[X][::-1]
    #same idea for y geom
    geomY = upperY+lower[Y][::-1]
    #add this to patch geoms
    patch_geoms['xs'].append(geomX)
    patch_geoms['ys'].append(geomY)

Then pass those patch geoms to a Patches glyph.

1 Like