{ "cells": [ { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Fundamentals of Accelerated Data Science # " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 03 - cuGraph Single Source Shortest Path ##\n", "\n", "**Table of Contents**\n", "
\n", "This notebook GPU-accelerated graph analytics with cuGraph to identify the shortest path from node on the road network to every other node, both by distance, which we will demo, and by time, which you will implement. You will also visualize the results of your findings. This notebook covers the below sections:\n", "1. [Environment](#Environment)\n", "2. [Loading Data](#Loading-Data)\n", "3. [Construct Graph with cuGraph](#Construct-Graph-with-cuGraph)\n", "4. [Analyzing the Graph](#Analyzing-the-Graph)\n", "5. [Single Source Shortest Path](#Single-Source-Shortest-Path)\n", "6. [Analyze a Graph with Time Weights](#Analyze-a-Graph-with-Time-Weights)\n", " * [Exercise #1 - Step 1: Construct the Graph](#Exercise-#1---Step-1:-Construct-the-Graph)\n", " * [Exercise #2 - Step 2: Get Travel Times From a Node to All Others](#Exercise-#2---Step-2:-Get-Travel-Times-From-a-Node-to-All-Others)\n", " * [Visualize the Node Travel Times](#Visualize-the-Node-Travel-Times)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Environment ##" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import warnings\n", "warnings.filterwarnings('ignore')\n", "\n", "import cudf\n", "import cugraph as cg\n", "\n", "import cuxfilter as cxf\n", "from bokeh.palettes import Magma, Turbo256, Plasma256, Viridis256" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading Data ##" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We start by loading the road graph data you prepared for constructing a graph with cuGraph, with the long unique `nodeid` replaced with simple (and memory-efficient) integers we call the `graph_id`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
srcdstlength
0012916544.0
11167832370.0
21237261018.0
31248305740.0
42255.0
\n", "
" ], "text/plain": [ " src dst length\n", "0 0 129165 44.0\n", "1 1 1678323 70.0\n", "2 1 2372610 18.0\n", "3 1 2483057 40.0\n", "4 2 2 55.0" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "road_graph = cudf.read_csv('./data/road_graph.csv', dtype=['int32', 'int32', 'float32'])\n", "road_graph.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next we load the graph-ready data you prepared that uses amount of time traveled as edge weight." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
srcdstlength_s
001291653.280848
1116783235.219531
2123726101.342165
3124830572.982589
4224.101060
\n", "
" ], "text/plain": [ " src dst length_s\n", "0 0 129165 3.280848\n", "1 1 1678323 5.219531\n", "2 1 2372610 1.342165\n", "3 1 2483057 2.982589\n", "4 2 2 4.101060" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "speed_graph = cudf.read_csv('./data/road_graph_speed.csv', dtype=['int32', 'int32', 'float32'])\n", "speed_graph.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally we import the full `road_nodes` data set, which we will use below for visualizations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
node_ideastnorthtype
0id02FE73D4-E88D-4119-8DC2-6E80DE6F6594320608.09375870994.0000junction
1id634D65C1-C38B-4868-9080-2E1E47F0935C320628.50000871103.8125road end
2idDC14D4D1-774E-487D-8EDE-60B129E5482C320635.46875870983.8750junction
3id51555819-1A39-4B41-B0C9-C6D2086D9921320648.68750871083.5625junction
4id9E362428-79D7-4EE3-B015-0CE3F6A78A69320658.18750871162.3750junction
\n", "
" ], "text/plain": [ " node_id east north type\n", "0 id02FE73D4-E88D-4119-8DC2-6E80DE6F6594 320608.09375 870994.0000 junction\n", "1 id634D65C1-C38B-4868-9080-2E1E47F0935C 320628.50000 871103.8125 road end\n", "2 idDC14D4D1-774E-487D-8EDE-60B129E5482C 320635.46875 870983.8750 junction\n", "3 id51555819-1A39-4B41-B0C9-C6D2086D9921 320648.68750 871083.5625 junction\n", "4 id9E362428-79D7-4EE3-B015-0CE3F6A78A69 320658.18750 871162.3750 junction" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "road_nodes = cudf.read_csv('./data/road_nodes.csv', dtype=['str', 'float32', 'float32', 'str'])\n", "road_nodes = road_nodes.drop_duplicates() # again, some road nodes appeared on multiple map tiles in the original source\n", "road_nodes.head()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(3078117, 4)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "road_nodes.shape" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3078116" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "speed_graph.src.max()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Construct Graph with cuGraph ##" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we have the well-prepped `road_graph` data, we pass it to cuGraph to create our graph data structure, which we can then use for accelerated analysis. In order to do so, we first use cuGraph to instantiate a `Graph` instance, and then pass the instance edge sources, edge destinations, and edge weights, currently the length of the roads." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 154 ms, sys: 36.8 ms, total: 191 ms\n", "Wall time: 189 ms\n" ] } ], "source": [ "G = cg.Graph()\n", "%time G.from_cudf_edgelist(road_graph, source='src', destination='dst', edge_attr='length')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Analyzing the Graph ##" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, we check the number of nodes and edges in our graph:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3078117" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "G.number_of_nodes()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3620793" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "G.number_of_edges()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also analyze the degrees of our graph nodes. We would expect, as before, that every node would have a degree of 2 or higher, since undirected edges count as two edges (one in, one out) for each of their nodes." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "mean 4.689990\n", "std 1.913452\n", "min 2.000000\n", "25% 2.000000\n", "50% 6.000000\n", "75% 6.000000\n", "max 16.000000\n", "Name: degree, dtype: float64" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "deg_df = G.degree()\n", "deg_df['degree'].describe()[1:]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We would also expect that every degree would be a multiple of 2, for the same reason. We check that there are no nodes with odd degrees (that is, degrees with a value of 1 modulo 2):" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
degreevertex
\n", "
" ], "text/plain": [ "Empty DataFrame\n", "Columns: [degree, vertex]\n", "Index: []" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "deg_df[deg_df['degree'].mod(2) == 1]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Observe for reference that some roads loop from a node back to itself:" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
srcdstlength
42255.0
1456262108.0
29312412467.0
47119619626.0
57124024044.0
............
72166023077469307746978.0
721673530775193077519111.0
72168493077567307756769.0
72170913077670307767030.0
72172943077756307775645.0
\n", "

23417 rows × 3 columns

\n", "
" ], "text/plain": [ " src dst length\n", "4 2 2 55.0\n", "145 62 62 108.0\n", "293 124 124 67.0\n", "471 196 196 26.0\n", "571 240 240 44.0\n", "... ... ... ...\n", "7216602 3077469 3077469 78.0\n", "7216735 3077519 3077519 111.0\n", "7216849 3077567 3077567 69.0\n", "7217091 3077670 3077670 30.0\n", "7217294 3077756 3077756 45.0\n", "\n", "[23417 rows x 3 columns]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "road_graph.loc[road_graph.src == road_graph.dst]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Single Source Shortest Path ##" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To demo the Single Source Shortest Path (SSSP) algorithm, we will start with the node with the highest degree. First we obtain its `graph_id`, reported by the `degree` method as `vertex`:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "652907" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "demo_node = deg_df.nlargest(1, 'degree')\n", "demo_node_graph_id = demo_node['vertex'].iloc[0]\n", "demo_node_graph_id" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can now call `cg.sssp`, passing it the entire graph `G`, and the `graph_id` for our selected vertex. Doing so will calculate the shortest path, using the road length weights we have provided, to *every* other node in the graph - millions of paths, in seconds:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 7.47 s, sys: 35.7 ms, total: 7.5 s\n", "Wall time: 7.45 s\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
distancevertexpredecessor
00.0652907-1
1110322.012527921378560
2213691.016063751375709
3106434.018267812377706
4253196.019901101652530
\n", "
" ], "text/plain": [ " distance vertex predecessor\n", "0 0.0 652907 -1\n", "1 110322.0 1252792 1378560\n", "2 213691.0 1606375 1375709\n", "3 106434.0 1826781 2377706\n", "4 253196.0 1990110 1652530" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%time shortest_distances_from_demo_node = cg.sssp(G, demo_node_graph_id)\n", "shortest_distances_from_demo_node.head()" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "mean 210086.107365\n", "std 137145.769283\n", "min 0.000000\n", "25% 125054.500000\n", "50% 181815.500000\n", "75% 252472.250000\n", "max 868870.500000\n", "Name: distance, dtype: float64" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Limiting to those nodes that were connected (within ~4.3 billion meters because\n", "# cg.sssp uses the max int value for unreachable nodes, such as those on different islands)\n", "shortest_distances_from_demo_node['distance'].loc[shortest_distances_from_demo_node['distance'] < 2**32].describe()[1:]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Analyze a Graph with Time Weights ##" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For this exercise, you are going to analyze the graph of GB's roads, but this time, instead of using raw distance for a road's weights, you will be using how long it will take to travel along the road." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise #1 - Step 1: Construct the Graph ###" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Construct a cuGraph graph called `G_ex` using the sources and destinations found in `speed_graph`, along with length in seconds values for the edges' weights." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "G_ex=cg.Graph()\n", "G_ex.from_cudf_edgelist(speed_graph, source='src', destination='dst', edge_attr='length_s')" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "\n", "G_ex = cg.Graph()\n", "G_ex.from_cudf_edgelist(speed_graph, source='src', destination='dst', edge_attr='length_s')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Click ... for solution. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise #2 - Step 2: Get Travel Times From a Node to All Others ###" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Choose one of the nodes and calculate the time it would take to travel from it to all other nodes via SSSP, calling the results `ex_dist`." ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " degree vertex\n", "0 16 652907\n" ] }, { "data": { "text/plain": [ "mean 7424.900285\n", "std 4666.250239\n", "min 0.000000\n", "25% 4484.137695\n", "50% 6451.895508\n", "75% 9064.045410\n", "max 31424.103516\n", "Name: distance, dtype: float64" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "deg = G_ex.degree()\n", "node = deg.nlargest(1, 'degree')\n", "\n", "print(node)\n", "\n", "ex_dist=cg.sssp(G_ex, node['vertex'].iloc[0])\n", "\n", "ex_dist['distance'].loc[ex_dist['distance'] < 2**32].describe()[1:]" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
distancevertexpredecessor
00.000000652907-1
13753.2165531252792423201
27388.64502016063751311665
34061.98828118267811963186
49050.32324219901101652530
............
30781127909.5161133078094710744
307811314547.45214830780951858716
307811412944.94238330780991761154
30781158544.3154303078103563256
30781165369.40527330781152721612
\n", "

3078117 rows × 3 columns

\n", "
" ], "text/plain": [ " distance vertex predecessor\n", "0 0.000000 652907 -1\n", "1 3753.216553 1252792 423201\n", "2 7388.645020 1606375 1311665\n", "3 4061.988281 1826781 1963186\n", "4 9050.323242 1990110 1652530\n", "... ... ... ...\n", "3078112 7909.516113 3078094 710744\n", "3078113 14547.452148 3078095 1858716\n", "3078114 12944.942383 3078099 1761154\n", "3078115 8544.315430 3078103 563256\n", "3078116 5369.405273 3078115 2721612\n", "\n", "[3078117 rows x 3 columns]" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex_dist" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "\n", "# If you have time, see what the SSSP visualization looks like starting from nodes at different extreme coordinates,\n", "# or one of the end nodes of an especially long edge, or even one of the nodes unreachable from the main road network.\n", "ex_deg = G_ex.degree()\n", "ex_node = ex_deg.nlargest(1, 'degree')\n", "\n", "%time ex_dist = cg.sssp(G_ex, ex_node['vertex'].iloc[0])\n", "\n", "# limiting to those nodes that were connected (within ~4.3 billion seconds; .sssp uses the max int value for unconnected nodes)\n", "ex_dist['distance'].loc[ex_dist['distance'] < 2**32].describe()[1:]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Click ... for solution. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Visualize the Node Travel Times ###" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In order to create a graphic showing the road network by travel time from the selected node, we first need to align the just-calculated distances with their original nodes. For that, we use the mapping from `node_id` strings to their `graph_id` integers." ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
node_idgraph_id
0id000000F5-5180-4C03-B05D-B01352C54F890
1id000003F8-9E09-4829-AD87-6DA4438D22D81
2id000010DA-C89A-4198-847A-6E62815E038A2
3id000017A0-1843-4BC7-BCF7-C943B67808393
4id00001B2A-155F-4CD3-8E06-7677ADC6AF744
\n", "
" ], "text/plain": [ " node_id graph_id\n", "0 id000000F5-5180-4C03-B05D-B01352C54F89 0\n", "1 id000003F8-9E09-4829-AD87-6DA4438D22D8 1\n", "2 id000010DA-C89A-4198-847A-6E62815E038A 2\n", "3 id000017A0-1843-4BC7-BCF7-C943B6780839 3\n", "4 id00001B2A-155F-4CD3-8E06-7677ADC6AF74 4" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mapping = cudf.read_csv('./data/node_graph_map.csv')\n", "mapping.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We see that the `sssp` algorithm has put the `graph_id`s in the `vertex` column, so we will merge on that." ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
distancevertexpredecessor
00.000000652907-1
13753.2165531252792423201
27388.64502016063751311665
34061.98828118267811963186
49050.32324219901101652530
\n", "
" ], "text/plain": [ " distance vertex predecessor\n", "0 0.000000 652907 -1\n", "1 3753.216553 1252792 423201\n", "2 7388.645020 1606375 1311665\n", "3 4061.988281 1826781 1963186\n", "4 9050.323242 1990110 1652530" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex_dist.head()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
node_ideastnorthtypegraph_iddistancevertexpredecessor
0id0F5B22B0-AB17-4653-A9C2-9E7DE9B37373371540.00000859847.000junction18414823863.84179718414846693
1idBC5AA063-AA06-488F-851C-DA7C91F65321371107.43750859912.875junction226381023894.375000226381046693
2id07664552-7DBD-488F-8F88-29485A3BE149372712.06250859948.125road end8913124078.251953891311841117
3id0B167A97-56F4-4455-87AE-199F7B1C85AF373182.78125859969.125junction13319624051.931641133196532422
4id7CF7B336-0AB4-45FD-9181-85DB87D3CF81373800.78125859987.375junction150271124115.46289115027112427593
\n", "
" ], "text/plain": [ " node_id east north type \\\n", "0 id0F5B22B0-AB17-4653-A9C2-9E7DE9B37373 371540.00000 859847.000 junction \n", "1 idBC5AA063-AA06-488F-851C-DA7C91F65321 371107.43750 859912.875 junction \n", "2 id07664552-7DBD-488F-8F88-29485A3BE149 372712.06250 859948.125 road end \n", "3 id0B167A97-56F4-4455-87AE-199F7B1C85AF 373182.78125 859969.125 junction \n", "4 id7CF7B336-0AB4-45FD-9181-85DB87D3CF81 373800.78125 859987.375 junction \n", "\n", " graph_id distance vertex predecessor \n", "0 184148 23863.841797 184148 46693 \n", "1 2263810 23894.375000 2263810 46693 \n", "2 89131 24078.251953 89131 1841117 \n", "3 133196 24051.931641 133196 532422 \n", "4 1502711 24115.462891 1502711 2427593 " ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "road_nodes = road_nodes.merge(mapping, on='node_id')\n", "road_nodes = road_nodes.merge(ex_dist, left_on='graph_id', right_on='vertex')\n", "road_nodes.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we select those columns we are going to use for the visualization.\n", "\n", "For color-scaling purposes, we get rid of the unreachable nodes with their extreme distances, and we invert the distance numbers so that brighter pixels indicate closer locations." ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "gdf = road_nodes[['east', 'north', 'distance']]\n", "gdf = gdf[gdf['distance'] < 2**32]\n", "gdf['distance'] = gdf['distance'].pow(1/2).mul(-1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Otherwise, this visualization will be largely similar to the scatter plots we made to visualize the population, but instead of coloring by point density as in those cases, we will color by mean travel time to the nodes within a pixel." ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "cxf_data = cxf.DataFrame.from_dataframe(gdf)" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "heatmap_chart = cxf.charts.datashader.scatter(x='east', y='north', \n", " # color_palette=Plasma256, # try also Turbo256, Viridis256, Magma, Plasma256\n", " # pixel_shade_type='linear', # can also be log, cbrt, linear\n", " aggregate_col='distance',\n", " aggregate_fn='mean',\n", " # point_shape='square',\n", " point_size=1)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " const force = true;\n", " const py_version = '3.5.2'.replace('rc', '-rc.').replace('.dev', '-dev.');\n", " const reloading = false;\n", " const Bokeh = root.Bokeh;\n", "\n", " // Set a timeout for this load but only if we are not already initializing\n", " if (typeof (root._bokeh_timeout) === \"undefined\" || (force || !root._bokeh_is_initializing)) {\n", " root._bokeh_timeout = Date.now() + 5000;\n", " root._bokeh_failed_load = false;\n", " }\n", "\n", " function run_callbacks() {\n", " try {\n", " root._bokeh_onload_callbacks.forEach(function(callback) {\n", " if (callback != null)\n", " callback();\n", " });\n", " } finally {\n", " delete root._bokeh_onload_callbacks;\n", " }\n", " console.debug(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(css_urls, js_urls, js_modules, js_exports, callback) {\n", " if (css_urls == null) css_urls = [];\n", " if (js_urls == null) js_urls = [];\n", " if (js_modules == null) js_modules = [];\n", " if (js_exports == null) js_exports = {};\n", "\n", " root._bokeh_onload_callbacks.push(callback);\n", "\n", " if (root._bokeh_is_loading > 0) {\n", " // Don't load bokeh if it is still initializing\n", " console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", " return null;\n", " } else if (js_urls.length === 0 && js_modules.length === 0 && Object.keys(js_exports).length === 0) {\n", " // There is nothing to load\n", " run_callbacks();\n", " return null;\n", " }\n", "\n", " function on_load() {\n", " root._bokeh_is_loading--;\n", " if (root._bokeh_is_loading === 0) {\n", " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", " run_callbacks()\n", " }\n", " }\n", " window._bokeh_on_load = on_load\n", "\n", " function on_error(e) {\n", " const src_el = e.srcElement\n", " console.error(\"failed to load \" + (src_el.href || src_el.src));\n", " }\n", "\n", " const skip = [];\n", " if (window.requirejs) {\n", " window.requirejs.config({'packages': {}, 'paths': {'h3': 'https://cdn.jsdelivr.net/npm/h3-js@4.1.0/dist/h3-js.umd', 'deck-gl': 'https://cdn.jsdelivr.net/npm/deck.gl@9.0.20/dist.min', 'deck-json': 'https://cdn.jsdelivr.net/npm/@deck.gl/json@9.0.20/dist.min', 'loader-csv': 'https://cdn.jsdelivr.net/npm/@loaders.gl/csv@4.2.2/dist/dist.min', 'loader-json': 'https://cdn.jsdelivr.net/npm/@loaders.gl/json@4.2.2/dist/dist.min', 'loader-tiles': 'https://cdn.jsdelivr.net/npm/@loaders.gl/3d-tiles@4.2.2/dist/dist.min', 'mapbox-gl': 'https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl', 'carto': 'https://cdn.jsdelivr.net/npm/@deck.gl/carto@^9.0.20/dist.min'}, 'shim': {'deck-json': {'deps': ['deck-gl']}, 'deck-gl': {'deps': ['h3']}}});\n", " require([\"h3\"], function(h3) {\n", " window.h3 = h3\n", " on_load()\n", " })\n", " require([\"deck-gl\"], function(deck) {\n", " window.deck = deck\n", " on_load()\n", " })\n", " require([\"deck-json\"], function() {\n", " on_load()\n", " })\n", " require([\"loader-csv\"], function() {\n", " on_load()\n", " })\n", " require([\"loader-json\"], function() {\n", " on_load()\n", " })\n", " require([\"loader-tiles\"], function() {\n", " on_load()\n", " })\n", " require([\"mapbox-gl\"], function(mapboxgl) {\n", " window.mapboxgl = mapboxgl\n", " on_load()\n", " })\n", " require([\"carto\"], function() {\n", " on_load()\n", " })\n", " root._bokeh_is_loading = css_urls.length + 8;\n", " } else {\n", " root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length + Object.keys(js_exports).length;\n", " }\n", "\n", " const existing_stylesheets = []\n", " const links = document.getElementsByTagName('link')\n", " for (let i = 0; i < links.length; i++) {\n", " const link = links[i]\n", " if (link.href != null) {\n", " existing_stylesheets.push(link.href)\n", " }\n", " }\n", " for (let i = 0; i < css_urls.length; i++) {\n", " const url = css_urls[i];\n", " const escaped = encodeURI(url)\n", " if (existing_stylesheets.indexOf(escaped) !== -1) {\n", " on_load()\n", " continue;\n", " }\n", " const element = document.createElement(\"link\");\n", " element.onload = on_load;\n", " element.onerror = on_error;\n", " element.rel = \"stylesheet\";\n", " element.type = \"text/css\";\n", " element.href = url;\n", " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", " document.body.appendChild(element);\n", " } if (((window.deck !== undefined) && (!(window.deck instanceof HTMLElement))) || window.requirejs) {\n", " var urls = ['https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/h3-js@4.1.0/dist/h3-js.umd.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/deck.gl@9.0.20/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/json@9.0.20/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/csv@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/json@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/3d-tiles@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl/dist/maplibre-gl.js'];\n", " for (var i = 0; i < urls.length; i++) {\n", " skip.push(encodeURI(urls[i]))\n", " }\n", " } if (((window.mapboxgl !== undefined) && (!(window.mapboxgl instanceof HTMLElement))) || window.requirejs) {\n", " var urls = ['https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/carto@^9.0.20/dist.min.js'];\n", " for (var i = 0; i < urls.length; i++) {\n", " skip.push(encodeURI(urls[i]))\n", " }\n", " } var existing_scripts = []\n", " const scripts = document.getElementsByTagName('script')\n", " for (let i = 0; i < scripts.length; i++) {\n", " var script = scripts[i]\n", " if (script.src != null) {\n", " existing_scripts.push(script.src)\n", " }\n", " }\n", " for (let i = 0; i < js_urls.length; i++) {\n", " const url = js_urls[i];\n", " const escaped = encodeURI(url)\n", " if (skip.indexOf(escaped) !== -1 || existing_scripts.indexOf(escaped) !== -1) {\n", " if (!window.requirejs) {\n", " on_load();\n", " }\n", " continue;\n", " }\n", " const element = document.createElement('script');\n", " element.onload = on_load;\n", " element.onerror = on_error;\n", " element.async = false;\n", " element.src = url;\n", " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " document.head.appendChild(element);\n", " }\n", " for (let i = 0; i < js_modules.length; i++) {\n", " const url = js_modules[i];\n", " const escaped = encodeURI(url)\n", " if (skip.indexOf(escaped) !== -1 || existing_scripts.indexOf(escaped) !== -1) {\n", " if (!window.requirejs) {\n", " on_load();\n", " }\n", " continue;\n", " }\n", " var element = document.createElement('script');\n", " element.onload = on_load;\n", " element.onerror = on_error;\n", " element.async = false;\n", " element.src = url;\n", " element.type = \"module\";\n", " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " document.head.appendChild(element);\n", " }\n", " for (const name in js_exports) {\n", " const url = js_exports[name];\n", " const escaped = encodeURI(url)\n", " if (skip.indexOf(escaped) >= 0 || root[name] != null) {\n", " if (!window.requirejs) {\n", " on_load();\n", " }\n", " continue;\n", " }\n", " var element = document.createElement('script');\n", " element.onerror = on_error;\n", " element.async = false;\n", " element.type = \"module\";\n", " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " element.textContent = `\n", " import ${name} from \"${url}\"\n", " window.${name} = ${name}\n", " window._bokeh_on_load()\n", " `\n", " document.head.appendChild(element);\n", " }\n", " if (!js_urls.length && !js_modules.length) {\n", " on_load()\n", " }\n", " };\n", "\n", " function inject_raw_css(css) {\n", " const element = document.createElement(\"style\");\n", " element.appendChild(document.createTextNode(css));\n", " document.body.appendChild(element);\n", " }\n", "\n", " const js_urls = [\"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/h3-js@4.1.0/dist/h3-js.umd.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/deck.gl@9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/json@9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/csv@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/json@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/3d-tiles@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl/dist/maplibre-gl.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/carto@^9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-3.5.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.5.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.5.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.5.2.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/panel.min.js\"];\n", " const js_modules = [];\n", " const js_exports = {};\n", " const css_urls = [\"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.css?v=1.5.2\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl@4.4.1/dist/maplibre-gl.css?v=1.5.2\"];\n", " const inline_js = [ function(Bokeh) {\n", " inject_raw_css(\"\\n.dataframe table{\\n border: none;\\n}\\n\\n.panel-df table{\\n width: 100%;\\n border-collapse: collapse;\\n border: none;\\n}\\n.panel-df td{\\n white-space: nowrap;\\n overflow: auto;\\n text-overflow: ellipsis;\\n}\\n\");\n", " }, function(Bokeh) {\n", " inject_raw_css(\"\\n.multi-select{\\n color: white;\\n z-index: 100;\\n background: rgba(44,43,43,0.5);\\n border-radius: 1px;\\n width: 120px !important;\\n height: 30px !important;\\n}\\n.multi-select > .bk {\\n padding: 5px;\\n width: 120px !important;\\n height: 30px !important;\\n}\\n\\n.deck-chart {\\n z-index: 10;\\n position: initial !important;\\n}\\n\");\n", " }, function(Bokeh) {\n", " inject_raw_css(\"\\n.center-header {\\n text-align: center\\n}\\n.bk-input-group {\\n padding: 10px;\\n}\\n#sidebar {\\n padding-top: 10px;\\n}\\n.custom-widget-box {\\n margin-top: 20px;\\n padding: 5px;\\n border: None !important;\\n}\\n.custom-widget-box > p {\\n margin: 0px;\\n}\\n.bk-input-group {\\n color: None !important;\\n}\\n.indicator {\\n text-align: center;\\n}\\n.widget-card {\\n margin: 5px 10px;\\n}\\n.number-card {\\n margin: 5px 10px;\\n text-align: center;\\n}\\n.number-card-value {\\n width: 100%;\\n margin: 0px;\\n}\\n\");\n", " }, function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " function(Bokeh) {\n", " (function(root, factory) {\n", " factory(root[\"Bokeh\"]);\n", " })(this, function(Bokeh) {\n", " let define;\n", " return (function outer(modules, entry) {\n", " if (Bokeh != null) {\n", " return Bokeh.register_plugin(modules, entry);\n", " } else {\n", " throw new Error(\"Cannot find Bokeh. You have to load it prior to loading plugins.\");\n", " }\n", " })\n", " ({\n", " \"custom/main\": function(require, module, exports) {\n", " const models = {\n", " \"CustomInspectTool\": require(\"custom/cuxfilter.charts.datashader.custom_extensions.graph_inspect_widget.custom_inspect_tool\").CustomInspectTool\n", " };\n", " require(\"base\").register_models(models);\n", " module.exports = models;\n", " },\n", " \"custom/cuxfilter.charts.datashader.custom_extensions.graph_inspect_widget.custom_inspect_tool\": function(require, module, exports) {\n", " \"use strict\";\n", " var _a;\n", " Object.defineProperty(exports, \"__esModule\", { value: true });\n", " exports.CustomInspectTool = exports.CustomInspectToolView = void 0;\n", " const inspect_tool_1 = require(\"models/tools/inspectors/inspect_tool\");\n", " class CustomInspectToolView extends inspect_tool_1.InspectToolView {\n", " connect_signals() {\n", " super.connect_signals();\n", " this.on_change([this.model.properties.active], () => {\n", " this.model._active = this.model.active;\n", " });\n", " }\n", " }\n", " exports.CustomInspectToolView = CustomInspectToolView;\n", " CustomInspectToolView.__name__ = \"CustomInspectToolView\";\n", " class CustomInspectTool extends inspect_tool_1.InspectTool {\n", " constructor(attrs) {\n", " super(attrs);\n", " }\n", " }\n", " exports.CustomInspectTool = CustomInspectTool;\n", " _a = CustomInspectTool;\n", " CustomInspectTool.__name__ = \"CustomInspectTool\";\n", " (() => {\n", " _a.prototype.default_view = CustomInspectToolView;\n", " _a.define(({ Boolean }) => ({\n", " _active: [Boolean, true]\n", " }));\n", " _a.register_alias(\"customInspect\", () => new _a());\n", " })();\n", " //# sourceMappingURL=graph_inspect_widget.py:CustomInspectTool.js.map\n", " }\n", " }, \"custom/main\");\n", " ;\n", " });\n", "\n", " },\n", "function(Bokeh) {} // ensure no trailing comma for IE\n", " ];\n", "\n", " function run_inline_js() {\n", " if ((root.Bokeh !== undefined) || (force === true)) {\n", " for (let i = 0; i < inline_js.length; i++) {\n", " try {\n", " inline_js[i].call(root, root.Bokeh);\n", " } catch(e) {\n", " if (!reloading) {\n", " throw e;\n", " }\n", " }\n", " }\n", " // Cache old bokeh versions\n", " if (Bokeh != undefined && !reloading) {\n", " var NewBokeh = root.Bokeh;\n", " if (Bokeh.versions === undefined) {\n", " Bokeh.versions = new Map();\n", " }\n", " if (NewBokeh.version !== Bokeh.version) {\n", " Bokeh.versions.set(NewBokeh.version, NewBokeh)\n", " }\n", " root.Bokeh = Bokeh;\n", " }\n", " } else if (Date.now() < root._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!root._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " root._bokeh_failed_load = true;\n", " }\n", " root._bokeh_is_initializing = false\n", " }\n", "\n", " function load_or_wait() {\n", " // Implement a backoff loop that tries to ensure we do not load multiple\n", " // versions of Bokeh and its dependencies at the same time.\n", " // In recent versions we use the root._bokeh_is_initializing flag\n", " // to determine whether there is an ongoing attempt to initialize\n", " // bokeh, however for backward compatibility we also try to ensure\n", " // that we do not start loading a newer (Panel>=1.0 and Bokeh>3) version\n", " // before older versions are fully initialized.\n", " if (root._bokeh_is_initializing && Date.now() > root._bokeh_timeout) {\n", " // If the timeout and bokeh was not successfully loaded we reset\n", " // everything and try loading again\n", " root._bokeh_timeout = Date.now() + 5000;\n", " root._bokeh_is_initializing = false;\n", " root._bokeh_onload_callbacks = undefined;\n", " root._bokeh_is_loading = 0\n", " console.log(\"Bokeh: BokehJS was loaded multiple times but one version failed to initialize.\");\n", " load_or_wait();\n", " } else if (root._bokeh_is_initializing || (typeof root._bokeh_is_initializing === \"undefined\" && root._bokeh_onload_callbacks !== undefined)) {\n", " setTimeout(load_or_wait, 100);\n", " } else {\n", " root._bokeh_is_initializing = true\n", " root._bokeh_onload_callbacks = []\n", " const bokeh_loaded = root.Bokeh != null && (root.Bokeh.version === py_version || (root.Bokeh.versions !== undefined && root.Bokeh.versions.has(py_version)));\n", " if (!reloading && !bokeh_loaded) {\n", " if (root.Bokeh) {\n", " root.Bokeh = undefined;\n", " }\n", " console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", " }\n", " load_libs(css_urls, js_urls, js_modules, js_exports, function() {\n", " console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n", " run_inline_js();\n", " });\n", " }\n", " }\n", " // Give older versions of the autoload script a head-start to ensure\n", " // they initialize before we start loading newer version.\n", " setTimeout(load_or_wait, 100)\n", "}(window));" ], "application/vnd.holoviews_load.v0+json": "(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n const py_version = '3.5.2'.replace('rc', '-rc.').replace('.dev', '-dev.');\n const reloading = false;\n const Bokeh = root.Bokeh;\n\n // Set a timeout for this load but only if we are not already initializing\n if (typeof (root._bokeh_timeout) === \"undefined\" || (force || !root._bokeh_is_initializing)) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks;\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, js_modules, js_exports, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n if (js_modules == null) js_modules = [];\n if (js_exports == null) js_exports = {};\n\n root._bokeh_onload_callbacks.push(callback);\n\n if (root._bokeh_is_loading > 0) {\n // Don't load bokeh if it is still initializing\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n } else if (js_urls.length === 0 && js_modules.length === 0 && Object.keys(js_exports).length === 0) {\n // There is nothing to load\n run_callbacks();\n return null;\n }\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n window._bokeh_on_load = on_load\n\n function on_error(e) {\n const src_el = e.srcElement\n console.error(\"failed to load \" + (src_el.href || src_el.src));\n }\n\n const skip = [];\n if (window.requirejs) {\n window.requirejs.config({'packages': {}, 'paths': {'h3': 'https://cdn.jsdelivr.net/npm/h3-js@4.1.0/dist/h3-js.umd', 'deck-gl': 'https://cdn.jsdelivr.net/npm/deck.gl@9.0.20/dist.min', 'deck-json': 'https://cdn.jsdelivr.net/npm/@deck.gl/json@9.0.20/dist.min', 'loader-csv': 'https://cdn.jsdelivr.net/npm/@loaders.gl/csv@4.2.2/dist/dist.min', 'loader-json': 'https://cdn.jsdelivr.net/npm/@loaders.gl/json@4.2.2/dist/dist.min', 'loader-tiles': 'https://cdn.jsdelivr.net/npm/@loaders.gl/3d-tiles@4.2.2/dist/dist.min', 'mapbox-gl': 'https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl', 'carto': 'https://cdn.jsdelivr.net/npm/@deck.gl/carto@^9.0.20/dist.min'}, 'shim': {'deck-json': {'deps': ['deck-gl']}, 'deck-gl': {'deps': ['h3']}}});\n require([\"h3\"], function(h3) {\n window.h3 = h3\n on_load()\n })\n require([\"deck-gl\"], function(deck) {\n window.deck = deck\n on_load()\n })\n require([\"deck-json\"], function() {\n on_load()\n })\n require([\"loader-csv\"], function() {\n on_load()\n })\n require([\"loader-json\"], function() {\n on_load()\n })\n require([\"loader-tiles\"], function() {\n on_load()\n })\n require([\"mapbox-gl\"], function(mapboxgl) {\n window.mapboxgl = mapboxgl\n on_load()\n })\n require([\"carto\"], function() {\n on_load()\n })\n root._bokeh_is_loading = css_urls.length + 8;\n } else {\n root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length + Object.keys(js_exports).length;\n }\n\n const existing_stylesheets = []\n const links = document.getElementsByTagName('link')\n for (let i = 0; i < links.length; i++) {\n const link = links[i]\n if (link.href != null) {\n existing_stylesheets.push(link.href)\n }\n }\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const escaped = encodeURI(url)\n if (existing_stylesheets.indexOf(escaped) !== -1) {\n on_load()\n continue;\n }\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n } if (((window.deck !== undefined) && (!(window.deck instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/h3-js@4.1.0/dist/h3-js.umd.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/deck.gl@9.0.20/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/json@9.0.20/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/csv@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/json@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/3d-tiles@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl/dist/maplibre-gl.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(encodeURI(urls[i]))\n }\n } if (((window.mapboxgl !== undefined) && (!(window.mapboxgl instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/carto@^9.0.20/dist.min.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(encodeURI(urls[i]))\n }\n } var existing_scripts = []\n const scripts = document.getElementsByTagName('script')\n for (let i = 0; i < scripts.length; i++) {\n var script = scripts[i]\n if (script.src != null) {\n existing_scripts.push(script.src)\n }\n }\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const escaped = encodeURI(url)\n if (skip.indexOf(escaped) !== -1 || existing_scripts.indexOf(escaped) !== -1) {\n if (!window.requirejs) {\n on_load();\n }\n continue;\n }\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (let i = 0; i < js_modules.length; i++) {\n const url = js_modules[i];\n const escaped = encodeURI(url)\n if (skip.indexOf(escaped) !== -1 || existing_scripts.indexOf(escaped) !== -1) {\n if (!window.requirejs) {\n on_load();\n }\n continue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (const name in js_exports) {\n const url = js_exports[name];\n const escaped = encodeURI(url)\n if (skip.indexOf(escaped) >= 0 || root[name] != null) {\n if (!window.requirejs) {\n on_load();\n }\n continue;\n }\n var element = document.createElement('script');\n element.onerror = on_error;\n element.async = false;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n element.textContent = `\n import ${name} from \"${url}\"\n window.${name} = ${name}\n window._bokeh_on_load()\n `\n document.head.appendChild(element);\n }\n if (!js_urls.length && !js_modules.length) {\n on_load()\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/h3-js@4.1.0/dist/h3-js.umd.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/deck.gl@9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/json@9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/csv@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/json@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/3d-tiles@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl/dist/maplibre-gl.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/carto@^9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-3.5.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.5.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.5.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.5.2.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/panel.min.js\"];\n const js_modules = [];\n const js_exports = {};\n const css_urls = [\"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.css?v=1.5.2\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl@4.4.1/dist/maplibre-gl.css?v=1.5.2\"];\n const inline_js = [ function(Bokeh) {\n inject_raw_css(\"\\n.dataframe table{\\n border: none;\\n}\\n\\n.panel-df table{\\n width: 100%;\\n border-collapse: collapse;\\n border: none;\\n}\\n.panel-df td{\\n white-space: nowrap;\\n overflow: auto;\\n text-overflow: ellipsis;\\n}\\n\");\n }, function(Bokeh) {\n inject_raw_css(\"\\n.multi-select{\\n color: white;\\n z-index: 100;\\n background: rgba(44,43,43,0.5);\\n border-radius: 1px;\\n width: 120px !important;\\n height: 30px !important;\\n}\\n.multi-select > .bk {\\n padding: 5px;\\n width: 120px !important;\\n height: 30px !important;\\n}\\n\\n.deck-chart {\\n z-index: 10;\\n position: initial !important;\\n}\\n\");\n }, function(Bokeh) {\n inject_raw_css(\"\\n.center-header {\\n text-align: center\\n}\\n.bk-input-group {\\n padding: 10px;\\n}\\n#sidebar {\\n padding-top: 10px;\\n}\\n.custom-widget-box {\\n margin-top: 20px;\\n padding: 5px;\\n border: None !important;\\n}\\n.custom-widget-box > p {\\n margin: 0px;\\n}\\n.bk-input-group {\\n color: None !important;\\n}\\n.indicator {\\n text-align: center;\\n}\\n.widget-card {\\n margin: 5px 10px;\\n}\\n.number-card {\\n margin: 5px 10px;\\n text-align: center;\\n}\\n.number-card-value {\\n width: 100%;\\n margin: 0px;\\n}\\n\");\n }, function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n (function(root, factory) {\n factory(root[\"Bokeh\"]);\n })(this, function(Bokeh) {\n let define;\n return (function outer(modules, entry) {\n if (Bokeh != null) {\n return Bokeh.register_plugin(modules, entry);\n } else {\n throw new Error(\"Cannot find Bokeh. You have to load it prior to loading plugins.\");\n }\n })\n ({\n \"custom/main\": function(require, module, exports) {\n const models = {\n \"CustomInspectTool\": require(\"custom/cuxfilter.charts.datashader.custom_extensions.graph_inspect_widget.custom_inspect_tool\").CustomInspectTool\n };\n require(\"base\").register_models(models);\n module.exports = models;\n },\n \"custom/cuxfilter.charts.datashader.custom_extensions.graph_inspect_widget.custom_inspect_tool\": function(require, module, exports) {\n \"use strict\";\n var _a;\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.CustomInspectTool = exports.CustomInspectToolView = void 0;\n const inspect_tool_1 = require(\"models/tools/inspectors/inspect_tool\");\n class CustomInspectToolView extends inspect_tool_1.InspectToolView {\n connect_signals() {\n super.connect_signals();\n this.on_change([this.model.properties.active], () => {\n this.model._active = this.model.active;\n });\n }\n }\n exports.CustomInspectToolView = CustomInspectToolView;\n CustomInspectToolView.__name__ = \"CustomInspectToolView\";\n class CustomInspectTool extends inspect_tool_1.InspectTool {\n constructor(attrs) {\n super(attrs);\n }\n }\n exports.CustomInspectTool = CustomInspectTool;\n _a = CustomInspectTool;\n CustomInspectTool.__name__ = \"CustomInspectTool\";\n (() => {\n _a.prototype.default_view = CustomInspectToolView;\n _a.define(({ Boolean }) => ({\n _active: [Boolean, true]\n }));\n _a.register_alias(\"customInspect\", () => new _a());\n })();\n //# sourceMappingURL=graph_inspect_widget.py:CustomInspectTool.js.map\n }\n }, \"custom/main\");\n ;\n });\n\n },\nfunction(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n if ((root.Bokeh !== undefined) || (force === true)) {\n for (let i = 0; i < inline_js.length; i++) {\n try {\n inline_js[i].call(root, root.Bokeh);\n } catch(e) {\n if (!reloading) {\n throw e;\n }\n }\n }\n // Cache old bokeh versions\n if (Bokeh != undefined && !reloading) {\n var NewBokeh = root.Bokeh;\n if (Bokeh.versions === undefined) {\n Bokeh.versions = new Map();\n }\n if (NewBokeh.version !== Bokeh.version) {\n Bokeh.versions.set(NewBokeh.version, NewBokeh)\n }\n root.Bokeh = Bokeh;\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n }\n root._bokeh_is_initializing = false\n }\n\n function load_or_wait() {\n // Implement a backoff loop that tries to ensure we do not load multiple\n // versions of Bokeh and its dependencies at the same time.\n // In recent versions we use the root._bokeh_is_initializing flag\n // to determine whether there is an ongoing attempt to initialize\n // bokeh, however for backward compatibility we also try to ensure\n // that we do not start loading a newer (Panel>=1.0 and Bokeh>3) version\n // before older versions are fully initialized.\n if (root._bokeh_is_initializing && Date.now() > root._bokeh_timeout) {\n // If the timeout and bokeh was not successfully loaded we reset\n // everything and try loading again\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_is_initializing = false;\n root._bokeh_onload_callbacks = undefined;\n root._bokeh_is_loading = 0\n console.log(\"Bokeh: BokehJS was loaded multiple times but one version failed to initialize.\");\n load_or_wait();\n } else if (root._bokeh_is_initializing || (typeof root._bokeh_is_initializing === \"undefined\" && root._bokeh_onload_callbacks !== undefined)) {\n setTimeout(load_or_wait, 100);\n } else {\n root._bokeh_is_initializing = true\n root._bokeh_onload_callbacks = []\n const bokeh_loaded = root.Bokeh != null && (root.Bokeh.version === py_version || (root.Bokeh.versions !== undefined && root.Bokeh.versions.has(py_version)));\n if (!reloading && !bokeh_loaded) {\n if (root.Bokeh) {\n root.Bokeh = undefined;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n }\n load_libs(css_urls, js_urls, js_modules, js_exports, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n }\n // Give older versions of the autoload script a head-start to ensure\n // they initialize before we start loading newer version.\n setTimeout(load_or_wait, 100)\n}(window));" }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "if ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n", " window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n", "}\n", "\n", "\n", " function JupyterCommManager() {\n", " }\n", "\n", " JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n", " if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n", " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n", " comm_manager.register_target(comm_id, function(comm) {\n", " comm.on_msg(msg_handler);\n", " });\n", " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n", " window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n", " comm.onMsg = msg_handler;\n", " });\n", " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n", " google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n", " var messages = comm.messages[Symbol.asyncIterator]();\n", " function processIteratorResult(result) {\n", " var message = result.value;\n", " console.log(message)\n", " var content = {data: message.data, comm_id};\n", " var buffers = []\n", " for (var buffer of message.buffers || []) {\n", " buffers.push(new DataView(buffer))\n", " }\n", " var metadata = message.metadata || {};\n", " var msg = {content, buffers, metadata}\n", " msg_handler(msg);\n", " return messages.next().then(processIteratorResult);\n", " }\n", " return messages.next().then(processIteratorResult);\n", " })\n", " }\n", " }\n", "\n", " JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n", " if (comm_id in window.PyViz.comms) {\n", " return window.PyViz.comms[comm_id];\n", " } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n", " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n", " var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n", " if (msg_handler) {\n", " comm.on_msg(msg_handler);\n", " }\n", " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n", " var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n", " comm.open();\n", " if (msg_handler) {\n", " comm.onMsg = msg_handler;\n", " }\n", " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n", " var comm_promise = google.colab.kernel.comms.open(comm_id)\n", " comm_promise.then((comm) => {\n", " window.PyViz.comms[comm_id] = comm;\n", " if (msg_handler) {\n", " var messages = comm.messages[Symbol.asyncIterator]();\n", " function processIteratorResult(result) {\n", " var message = result.value;\n", " var content = {data: message.data};\n", " var metadata = message.metadata || {comm_id};\n", " var msg = {content, metadata}\n", " msg_handler(msg);\n", " return messages.next().then(processIteratorResult);\n", " }\n", " return messages.next().then(processIteratorResult);\n", " }\n", " }) \n", " var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n", " return comm_promise.then((comm) => {\n", " comm.send(data, metadata, buffers, disposeOnDone);\n", " });\n", " };\n", " var comm = {\n", " send: sendClosure\n", " };\n", " }\n", " window.PyViz.comms[comm_id] = comm;\n", " return comm;\n", " }\n", " window.PyViz.comm_manager = new JupyterCommManager();\n", " \n", "\n", "\n", "var JS_MIME_TYPE = 'application/javascript';\n", "var HTML_MIME_TYPE = 'text/html';\n", "var EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\n", "var CLASS_NAME = 'output';\n", "\n", "/**\n", " * Render data to the DOM node\n", " */\n", "function render(props, node) {\n", " var div = document.createElement(\"div\");\n", " var script = document.createElement(\"script\");\n", " node.appendChild(div);\n", " node.appendChild(script);\n", "}\n", "\n", "/**\n", " * Handle when a new output is added\n", " */\n", "function handle_add_output(event, handle) {\n", " var output_area = handle.output_area;\n", " var output = handle.output;\n", " if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n", " return\n", " }\n", " var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", " var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", " if (id !== undefined) {\n", " var nchildren = toinsert.length;\n", " var html_node = toinsert[nchildren-1].children[0];\n", " html_node.innerHTML = output.data[HTML_MIME_TYPE];\n", " var scripts = [];\n", " var nodelist = html_node.querySelectorAll(\"script\");\n", " for (var i in nodelist) {\n", " if (nodelist.hasOwnProperty(i)) {\n", " scripts.push(nodelist[i])\n", " }\n", " }\n", "\n", " scripts.forEach( function (oldScript) {\n", " var newScript = document.createElement(\"script\");\n", " var attrs = [];\n", " var nodemap = oldScript.attributes;\n", " for (var j in nodemap) {\n", " if (nodemap.hasOwnProperty(j)) {\n", " attrs.push(nodemap[j])\n", " }\n", " }\n", " attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n", " newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n", " oldScript.parentNode.replaceChild(newScript, oldScript);\n", " });\n", " if (JS_MIME_TYPE in output.data) {\n", " toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n", " }\n", " output_area._hv_plot_id = id;\n", " if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n", " window.PyViz.plot_index[id] = Bokeh.index[id];\n", " } else {\n", " window.PyViz.plot_index[id] = null;\n", " }\n", " } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", " var bk_div = document.createElement(\"div\");\n", " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", " var script_attrs = bk_div.children[0].attributes;\n", " for (var i = 0; i < script_attrs.length; i++) {\n", " toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n", " }\n", " // store reference to server id on output_area\n", " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", " }\n", "}\n", "\n", "/**\n", " * Handle when an output is cleared or removed\n", " */\n", "function handle_clear_output(event, handle) {\n", " var id = handle.cell.output_area._hv_plot_id;\n", " var server_id = handle.cell.output_area._bokeh_server_id;\n", " if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n", " var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n", " if (server_id !== null) {\n", " comm.send({event_type: 'server_delete', 'id': server_id});\n", " return;\n", " } else if (comm !== null) {\n", " comm.send({event_type: 'delete', 'id': id});\n", " }\n", " delete PyViz.plot_index[id];\n", " if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n", " var doc = window.Bokeh.index[id].model.document\n", " doc.clear();\n", " const i = window.Bokeh.documents.indexOf(doc);\n", " if (i > -1) {\n", " window.Bokeh.documents.splice(i, 1);\n", " }\n", " }\n", "}\n", "\n", "/**\n", " * Handle kernel restart event\n", " */\n", "function handle_kernel_cleanup(event, handle) {\n", " delete PyViz.comms[\"hv-extension-comm\"];\n", " window.PyViz.plot_index = {}\n", "}\n", "\n", "/**\n", " * Handle update_display_data messages\n", " */\n", "function handle_update_output(event, handle) {\n", " handle_clear_output(event, {cell: {output_area: handle.output_area}})\n", " handle_add_output(event, handle)\n", "}\n", "\n", "function register_renderer(events, OutputArea) {\n", " function append_mime(data, metadata, element) {\n", " // create a DOM node to render to\n", " var toinsert = this.create_output_subarea(\n", " metadata,\n", " CLASS_NAME,\n", " EXEC_MIME_TYPE\n", " );\n", " this.keyboard_manager.register_events(toinsert);\n", " // Render to node\n", " var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", " render(props, toinsert[0]);\n", " element.append(toinsert);\n", " return toinsert\n", " }\n", "\n", " events.on('output_added.OutputArea', handle_add_output);\n", " events.on('output_updated.OutputArea', handle_update_output);\n", " events.on('clear_output.CodeCell', handle_clear_output);\n", " events.on('delete.Cell', handle_clear_output);\n", " events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n", "\n", " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", " safe: true,\n", " index: 0\n", " });\n", "}\n", "\n", "if (window.Jupyter !== undefined) {\n", " try {\n", " var events = require('base/js/events');\n", " var OutputArea = require('notebook/js/outputarea').OutputArea;\n", " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", " register_renderer(events, OutputArea);\n", " }\n", " } catch(err) {\n", " }\n", "}\n" ], "application/vnd.holoviews_load.v0+json": "\nif ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n}\n\n\n function JupyterCommManager() {\n }\n\n JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n comm_manager.register_target(comm_id, function(comm) {\n comm.on_msg(msg_handler);\n });\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n comm.onMsg = msg_handler;\n });\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n console.log(message)\n var content = {data: message.data, comm_id};\n var buffers = []\n for (var buffer of message.buffers || []) {\n buffers.push(new DataView(buffer))\n }\n var metadata = message.metadata || {};\n var msg = {content, buffers, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n })\n }\n }\n\n JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n if (comm_id in window.PyViz.comms) {\n return window.PyViz.comms[comm_id];\n } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n if (msg_handler) {\n comm.on_msg(msg_handler);\n }\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n comm.open();\n if (msg_handler) {\n comm.onMsg = msg_handler;\n }\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n var comm_promise = google.colab.kernel.comms.open(comm_id)\n comm_promise.then((comm) => {\n window.PyViz.comms[comm_id] = comm;\n if (msg_handler) {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n var content = {data: message.data};\n var metadata = message.metadata || {comm_id};\n var msg = {content, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n }\n }) \n var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n return comm_promise.then((comm) => {\n comm.send(data, metadata, buffers, disposeOnDone);\n });\n };\n var comm = {\n send: sendClosure\n };\n }\n window.PyViz.comms[comm_id] = comm;\n return comm;\n }\n window.PyViz.comm_manager = new JupyterCommManager();\n \n\n\nvar JS_MIME_TYPE = 'application/javascript';\nvar HTML_MIME_TYPE = 'text/html';\nvar EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\nvar CLASS_NAME = 'output';\n\n/**\n * Render data to the DOM node\n */\nfunction render(props, node) {\n var div = document.createElement(\"div\");\n var script = document.createElement(\"script\");\n node.appendChild(div);\n node.appendChild(script);\n}\n\n/**\n * Handle when a new output is added\n */\nfunction handle_add_output(event, handle) {\n var output_area = handle.output_area;\n var output = handle.output;\n if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n return\n }\n var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n if (id !== undefined) {\n var nchildren = toinsert.length;\n var html_node = toinsert[nchildren-1].children[0];\n html_node.innerHTML = output.data[HTML_MIME_TYPE];\n var scripts = [];\n var nodelist = html_node.querySelectorAll(\"script\");\n for (var i in nodelist) {\n if (nodelist.hasOwnProperty(i)) {\n scripts.push(nodelist[i])\n }\n }\n\n scripts.forEach( function (oldScript) {\n var newScript = document.createElement(\"script\");\n var attrs = [];\n var nodemap = oldScript.attributes;\n for (var j in nodemap) {\n if (nodemap.hasOwnProperty(j)) {\n attrs.push(nodemap[j])\n }\n }\n attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n oldScript.parentNode.replaceChild(newScript, oldScript);\n });\n if (JS_MIME_TYPE in output.data) {\n toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n }\n output_area._hv_plot_id = id;\n if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n window.PyViz.plot_index[id] = Bokeh.index[id];\n } else {\n window.PyViz.plot_index[id] = null;\n }\n } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n var bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n var script_attrs = bk_div.children[0].attributes;\n for (var i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n}\n\n/**\n * Handle when an output is cleared or removed\n */\nfunction handle_clear_output(event, handle) {\n var id = handle.cell.output_area._hv_plot_id;\n var server_id = handle.cell.output_area._bokeh_server_id;\n if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n if (server_id !== null) {\n comm.send({event_type: 'server_delete', 'id': server_id});\n return;\n } else if (comm !== null) {\n comm.send({event_type: 'delete', 'id': id});\n }\n delete PyViz.plot_index[id];\n if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n var doc = window.Bokeh.index[id].model.document\n doc.clear();\n const i = window.Bokeh.documents.indexOf(doc);\n if (i > -1) {\n window.Bokeh.documents.splice(i, 1);\n }\n }\n}\n\n/**\n * Handle kernel restart event\n */\nfunction handle_kernel_cleanup(event, handle) {\n delete PyViz.comms[\"hv-extension-comm\"];\n window.PyViz.plot_index = {}\n}\n\n/**\n * Handle update_display_data messages\n */\nfunction handle_update_output(event, handle) {\n handle_clear_output(event, {cell: {output_area: handle.output_area}})\n handle_add_output(event, handle)\n}\n\nfunction register_renderer(events, OutputArea) {\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n var toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[0]);\n element.append(toinsert);\n return toinsert\n }\n\n events.on('output_added.OutputArea', handle_add_output);\n events.on('output_updated.OutputArea', handle_update_output);\n events.on('clear_output.CodeCell', handle_clear_output);\n events.on('delete.Cell', handle_clear_output);\n events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n safe: true,\n index: 0\n });\n}\n\nif (window.Jupyter !== undefined) {\n try {\n var events = require('base/js/events');\n var OutputArea = require('notebook/js/outputarea').OutputArea;\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n } catch(err) {\n }\n}\n" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " const force = false;\n", " const py_version = '3.5.2'.replace('rc', '-rc.').replace('.dev', '-dev.');\n", " const reloading = true;\n", " const Bokeh = root.Bokeh;\n", "\n", " // Set a timeout for this load but only if we are not already initializing\n", " if (typeof (root._bokeh_timeout) === \"undefined\" || (force || !root._bokeh_is_initializing)) {\n", " root._bokeh_timeout = Date.now() + 5000;\n", " root._bokeh_failed_load = false;\n", " }\n", "\n", " function run_callbacks() {\n", " try {\n", " root._bokeh_onload_callbacks.forEach(function(callback) {\n", " if (callback != null)\n", " callback();\n", " });\n", " } finally {\n", " delete root._bokeh_onload_callbacks;\n", " }\n", " console.debug(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(css_urls, js_urls, js_modules, js_exports, callback) {\n", " if (css_urls == null) css_urls = [];\n", " if (js_urls == null) js_urls = [];\n", " if (js_modules == null) js_modules = [];\n", " if (js_exports == null) js_exports = {};\n", "\n", " root._bokeh_onload_callbacks.push(callback);\n", "\n", " if (root._bokeh_is_loading > 0) {\n", " // Don't load bokeh if it is still initializing\n", " console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", " return null;\n", " } else if (js_urls.length === 0 && js_modules.length === 0 && Object.keys(js_exports).length === 0) {\n", " // There is nothing to load\n", " run_callbacks();\n", " return null;\n", " }\n", "\n", " function on_load() {\n", " root._bokeh_is_loading--;\n", " if (root._bokeh_is_loading === 0) {\n", " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", " run_callbacks()\n", " }\n", " }\n", " window._bokeh_on_load = on_load\n", "\n", " function on_error(e) {\n", " const src_el = e.srcElement\n", " console.error(\"failed to load \" + (src_el.href || src_el.src));\n", " }\n", "\n", " const skip = [];\n", " if (window.requirejs) {\n", " window.requirejs.config({'packages': {}, 'paths': {'h3': 'https://cdn.jsdelivr.net/npm/h3-js@4.1.0/dist/h3-js.umd', 'deck-gl': 'https://cdn.jsdelivr.net/npm/deck.gl@9.0.20/dist.min', 'deck-json': 'https://cdn.jsdelivr.net/npm/@deck.gl/json@9.0.20/dist.min', 'loader-csv': 'https://cdn.jsdelivr.net/npm/@loaders.gl/csv@4.2.2/dist/dist.min', 'loader-json': 'https://cdn.jsdelivr.net/npm/@loaders.gl/json@4.2.2/dist/dist.min', 'loader-tiles': 'https://cdn.jsdelivr.net/npm/@loaders.gl/3d-tiles@4.2.2/dist/dist.min', 'mapbox-gl': 'https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl', 'carto': 'https://cdn.jsdelivr.net/npm/@deck.gl/carto@^9.0.20/dist.min'}, 'shim': {'deck-json': {'deps': ['deck-gl']}, 'deck-gl': {'deps': ['h3']}}});\n", " require([\"h3\"], function(h3) {\n", " window.h3 = h3\n", " on_load()\n", " })\n", " require([\"deck-gl\"], function(deck) {\n", " window.deck = deck\n", " on_load()\n", " })\n", " require([\"deck-json\"], function() {\n", " on_load()\n", " })\n", " require([\"loader-csv\"], function() {\n", " on_load()\n", " })\n", " require([\"loader-json\"], function() {\n", " on_load()\n", " })\n", " require([\"loader-tiles\"], function() {\n", " on_load()\n", " })\n", " require([\"mapbox-gl\"], function(mapboxgl) {\n", " window.mapboxgl = mapboxgl\n", " on_load()\n", " })\n", " require([\"carto\"], function() {\n", " on_load()\n", " })\n", " root._bokeh_is_loading = css_urls.length + 8;\n", " } else {\n", " root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length + Object.keys(js_exports).length;\n", " }\n", "\n", " const existing_stylesheets = []\n", " const links = document.getElementsByTagName('link')\n", " for (let i = 0; i < links.length; i++) {\n", " const link = links[i]\n", " if (link.href != null) {\n", " existing_stylesheets.push(link.href)\n", " }\n", " }\n", " for (let i = 0; i < css_urls.length; i++) {\n", " const url = css_urls[i];\n", " const escaped = encodeURI(url)\n", " if (existing_stylesheets.indexOf(escaped) !== -1) {\n", " on_load()\n", " continue;\n", " }\n", " const element = document.createElement(\"link\");\n", " element.onload = on_load;\n", " element.onerror = on_error;\n", " element.rel = \"stylesheet\";\n", " element.type = \"text/css\";\n", " element.href = url;\n", " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", " document.body.appendChild(element);\n", " } if (((window.deck !== undefined) && (!(window.deck instanceof HTMLElement))) || window.requirejs) {\n", " var urls = ['https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/h3-js@4.1.0/dist/h3-js.umd.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/deck.gl@9.0.20/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/json@9.0.20/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/csv@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/json@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/3d-tiles@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl/dist/maplibre-gl.js'];\n", " for (var i = 0; i < urls.length; i++) {\n", " skip.push(encodeURI(urls[i]))\n", " }\n", " } if (((window.mapboxgl !== undefined) && (!(window.mapboxgl instanceof HTMLElement))) || window.requirejs) {\n", " var urls = ['https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/carto@^9.0.20/dist.min.js'];\n", " for (var i = 0; i < urls.length; i++) {\n", " skip.push(encodeURI(urls[i]))\n", " }\n", " } var existing_scripts = []\n", " const scripts = document.getElementsByTagName('script')\n", " for (let i = 0; i < scripts.length; i++) {\n", " var script = scripts[i]\n", " if (script.src != null) {\n", " existing_scripts.push(script.src)\n", " }\n", " }\n", " for (let i = 0; i < js_urls.length; i++) {\n", " const url = js_urls[i];\n", " const escaped = encodeURI(url)\n", " if (skip.indexOf(escaped) !== -1 || existing_scripts.indexOf(escaped) !== -1) {\n", " if (!window.requirejs) {\n", " on_load();\n", " }\n", " continue;\n", " }\n", " const element = document.createElement('script');\n", " element.onload = on_load;\n", " element.onerror = on_error;\n", " element.async = false;\n", " element.src = url;\n", " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " document.head.appendChild(element);\n", " }\n", " for (let i = 0; i < js_modules.length; i++) {\n", " const url = js_modules[i];\n", " const escaped = encodeURI(url)\n", " if (skip.indexOf(escaped) !== -1 || existing_scripts.indexOf(escaped) !== -1) {\n", " if (!window.requirejs) {\n", " on_load();\n", " }\n", " continue;\n", " }\n", " var element = document.createElement('script');\n", " element.onload = on_load;\n", " element.onerror = on_error;\n", " element.async = false;\n", " element.src = url;\n", " element.type = \"module\";\n", " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " document.head.appendChild(element);\n", " }\n", " for (const name in js_exports) {\n", " const url = js_exports[name];\n", " const escaped = encodeURI(url)\n", " if (skip.indexOf(escaped) >= 0 || root[name] != null) {\n", " if (!window.requirejs) {\n", " on_load();\n", " }\n", " continue;\n", " }\n", " var element = document.createElement('script');\n", " element.onerror = on_error;\n", " element.async = false;\n", " element.type = \"module\";\n", " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " element.textContent = `\n", " import ${name} from \"${url}\"\n", " window.${name} = ${name}\n", " window._bokeh_on_load()\n", " `\n", " document.head.appendChild(element);\n", " }\n", " if (!js_urls.length && !js_modules.length) {\n", " on_load()\n", " }\n", " };\n", "\n", " function inject_raw_css(css) {\n", " const element = document.createElement(\"style\");\n", " element.appendChild(document.createTextNode(css));\n", " document.body.appendChild(element);\n", " }\n", "\n", " const js_urls = [\"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/h3-js@4.1.0/dist/h3-js.umd.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/deck.gl@9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/json@9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/csv@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/json@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/3d-tiles@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl/dist/maplibre-gl.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/carto@^9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js\"];\n", " const js_modules = [];\n", " const js_exports = {};\n", " const css_urls = [\"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.css?v=1.5.2\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl@4.4.1/dist/maplibre-gl.css?v=1.5.2\"];\n", " const inline_js = [ function(Bokeh) {\n", " inject_raw_css(\"\\n.dataframe table{\\n border: none;\\n}\\n\\n.panel-df table{\\n width: 100%;\\n border-collapse: collapse;\\n border: none;\\n}\\n.panel-df td{\\n white-space: nowrap;\\n overflow: auto;\\n text-overflow: ellipsis;\\n}\\n\");\n", " }, function(Bokeh) {\n", " inject_raw_css(\"\\n.multi-select{\\n color: white;\\n z-index: 100;\\n background: rgba(44,43,43,0.5);\\n border-radius: 1px;\\n width: 120px !important;\\n height: 30px !important;\\n}\\n.multi-select > .bk {\\n padding: 5px;\\n width: 120px !important;\\n height: 30px !important;\\n}\\n\\n.deck-chart {\\n z-index: 10;\\n position: initial !important;\\n}\\n\");\n", " }, function(Bokeh) {\n", " inject_raw_css(\"\\n.center-header {\\n text-align: center\\n}\\n.bk-input-group {\\n padding: 10px;\\n}\\n#sidebar {\\n padding-top: 10px;\\n}\\n.custom-widget-box {\\n margin-top: 20px;\\n padding: 5px;\\n border: None !important;\\n}\\n.custom-widget-box > p {\\n margin: 0px;\\n}\\n.bk-input-group {\\n color: None !important;\\n}\\n.indicator {\\n text-align: center;\\n}\\n.widget-card {\\n margin: 5px 10px;\\n}\\n.number-card {\\n margin: 5px 10px;\\n text-align: center;\\n}\\n.number-card-value {\\n width: 100%;\\n margin: 0px;\\n}\\n\");\n", " }, function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " function(Bokeh) {\n", " (function(root, factory) {\n", " factory(root[\"Bokeh\"]);\n", " })(this, function(Bokeh) {\n", " let define;\n", " return (function outer(modules, entry) {\n", " if (Bokeh != null) {\n", " return Bokeh.register_plugin(modules, entry);\n", " } else {\n", " throw new Error(\"Cannot find Bokeh. You have to load it prior to loading plugins.\");\n", " }\n", " })\n", " ({\n", " \"custom/main\": function(require, module, exports) {\n", " const models = {\n", " \"CustomInspectTool\": require(\"custom/cuxfilter.charts.datashader.custom_extensions.graph_inspect_widget.custom_inspect_tool\").CustomInspectTool\n", " };\n", " require(\"base\").register_models(models);\n", " module.exports = models;\n", " },\n", " \"custom/cuxfilter.charts.datashader.custom_extensions.graph_inspect_widget.custom_inspect_tool\": function(require, module, exports) {\n", " \"use strict\";\n", " var _a;\n", " Object.defineProperty(exports, \"__esModule\", { value: true });\n", " exports.CustomInspectTool = exports.CustomInspectToolView = void 0;\n", " const inspect_tool_1 = require(\"models/tools/inspectors/inspect_tool\");\n", " class CustomInspectToolView extends inspect_tool_1.InspectToolView {\n", " connect_signals() {\n", " super.connect_signals();\n", " this.on_change([this.model.properties.active], () => {\n", " this.model._active = this.model.active;\n", " });\n", " }\n", " }\n", " exports.CustomInspectToolView = CustomInspectToolView;\n", " CustomInspectToolView.__name__ = \"CustomInspectToolView\";\n", " class CustomInspectTool extends inspect_tool_1.InspectTool {\n", " constructor(attrs) {\n", " super(attrs);\n", " }\n", " }\n", " exports.CustomInspectTool = CustomInspectTool;\n", " _a = CustomInspectTool;\n", " CustomInspectTool.__name__ = \"CustomInspectTool\";\n", " (() => {\n", " _a.prototype.default_view = CustomInspectToolView;\n", " _a.define(({ Boolean }) => ({\n", " _active: [Boolean, true]\n", " }));\n", " _a.register_alias(\"customInspect\", () => new _a());\n", " })();\n", " //# sourceMappingURL=graph_inspect_widget.py:CustomInspectTool.js.map\n", " }\n", " }, \"custom/main\");\n", " ;\n", " });\n", "\n", " },\n", "function(Bokeh) {} // ensure no trailing comma for IE\n", " ];\n", "\n", " function run_inline_js() {\n", " if ((root.Bokeh !== undefined) || (force === true)) {\n", " for (let i = 0; i < inline_js.length; i++) {\n", " try {\n", " inline_js[i].call(root, root.Bokeh);\n", " } catch(e) {\n", " if (!reloading) {\n", " throw e;\n", " }\n", " }\n", " }\n", " // Cache old bokeh versions\n", " if (Bokeh != undefined && !reloading) {\n", " var NewBokeh = root.Bokeh;\n", " if (Bokeh.versions === undefined) {\n", " Bokeh.versions = new Map();\n", " }\n", " if (NewBokeh.version !== Bokeh.version) {\n", " Bokeh.versions.set(NewBokeh.version, NewBokeh)\n", " }\n", " root.Bokeh = Bokeh;\n", " }\n", " } else if (Date.now() < root._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!root._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " root._bokeh_failed_load = true;\n", " }\n", " root._bokeh_is_initializing = false\n", " }\n", "\n", " function load_or_wait() {\n", " // Implement a backoff loop that tries to ensure we do not load multiple\n", " // versions of Bokeh and its dependencies at the same time.\n", " // In recent versions we use the root._bokeh_is_initializing flag\n", " // to determine whether there is an ongoing attempt to initialize\n", " // bokeh, however for backward compatibility we also try to ensure\n", " // that we do not start loading a newer (Panel>=1.0 and Bokeh>3) version\n", " // before older versions are fully initialized.\n", " if (root._bokeh_is_initializing && Date.now() > root._bokeh_timeout) {\n", " // If the timeout and bokeh was not successfully loaded we reset\n", " // everything and try loading again\n", " root._bokeh_timeout = Date.now() + 5000;\n", " root._bokeh_is_initializing = false;\n", " root._bokeh_onload_callbacks = undefined;\n", " root._bokeh_is_loading = 0\n", " console.log(\"Bokeh: BokehJS was loaded multiple times but one version failed to initialize.\");\n", " load_or_wait();\n", " } else if (root._bokeh_is_initializing || (typeof root._bokeh_is_initializing === \"undefined\" && root._bokeh_onload_callbacks !== undefined)) {\n", " setTimeout(load_or_wait, 100);\n", " } else {\n", " root._bokeh_is_initializing = true\n", " root._bokeh_onload_callbacks = []\n", " const bokeh_loaded = root.Bokeh != null && (root.Bokeh.version === py_version || (root.Bokeh.versions !== undefined && root.Bokeh.versions.has(py_version)));\n", " if (!reloading && !bokeh_loaded) {\n", " if (root.Bokeh) {\n", " root.Bokeh = undefined;\n", " }\n", " console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", " }\n", " load_libs(css_urls, js_urls, js_modules, js_exports, function() {\n", " console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n", " run_inline_js();\n", " });\n", " }\n", " }\n", " // Give older versions of the autoload script a head-start to ensure\n", " // they initialize before we start loading newer version.\n", " setTimeout(load_or_wait, 100)\n", "}(window));" ], "application/vnd.holoviews_load.v0+json": "(function(root) {\n function now() {\n return new Date();\n }\n\n const force = false;\n const py_version = '3.5.2'.replace('rc', '-rc.').replace('.dev', '-dev.');\n const reloading = true;\n const Bokeh = root.Bokeh;\n\n // Set a timeout for this load but only if we are not already initializing\n if (typeof (root._bokeh_timeout) === \"undefined\" || (force || !root._bokeh_is_initializing)) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks;\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, js_modules, js_exports, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n if (js_modules == null) js_modules = [];\n if (js_exports == null) js_exports = {};\n\n root._bokeh_onload_callbacks.push(callback);\n\n if (root._bokeh_is_loading > 0) {\n // Don't load bokeh if it is still initializing\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n } else if (js_urls.length === 0 && js_modules.length === 0 && Object.keys(js_exports).length === 0) {\n // There is nothing to load\n run_callbacks();\n return null;\n }\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n window._bokeh_on_load = on_load\n\n function on_error(e) {\n const src_el = e.srcElement\n console.error(\"failed to load \" + (src_el.href || src_el.src));\n }\n\n const skip = [];\n if (window.requirejs) {\n window.requirejs.config({'packages': {}, 'paths': {'h3': 'https://cdn.jsdelivr.net/npm/h3-js@4.1.0/dist/h3-js.umd', 'deck-gl': 'https://cdn.jsdelivr.net/npm/deck.gl@9.0.20/dist.min', 'deck-json': 'https://cdn.jsdelivr.net/npm/@deck.gl/json@9.0.20/dist.min', 'loader-csv': 'https://cdn.jsdelivr.net/npm/@loaders.gl/csv@4.2.2/dist/dist.min', 'loader-json': 'https://cdn.jsdelivr.net/npm/@loaders.gl/json@4.2.2/dist/dist.min', 'loader-tiles': 'https://cdn.jsdelivr.net/npm/@loaders.gl/3d-tiles@4.2.2/dist/dist.min', 'mapbox-gl': 'https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl', 'carto': 'https://cdn.jsdelivr.net/npm/@deck.gl/carto@^9.0.20/dist.min'}, 'shim': {'deck-json': {'deps': ['deck-gl']}, 'deck-gl': {'deps': ['h3']}}});\n require([\"h3\"], function(h3) {\n window.h3 = h3\n on_load()\n })\n require([\"deck-gl\"], function(deck) {\n window.deck = deck\n on_load()\n })\n require([\"deck-json\"], function() {\n on_load()\n })\n require([\"loader-csv\"], function() {\n on_load()\n })\n require([\"loader-json\"], function() {\n on_load()\n })\n require([\"loader-tiles\"], function() {\n on_load()\n })\n require([\"mapbox-gl\"], function(mapboxgl) {\n window.mapboxgl = mapboxgl\n on_load()\n })\n require([\"carto\"], function() {\n on_load()\n })\n root._bokeh_is_loading = css_urls.length + 8;\n } else {\n root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length + Object.keys(js_exports).length;\n }\n\n const existing_stylesheets = []\n const links = document.getElementsByTagName('link')\n for (let i = 0; i < links.length; i++) {\n const link = links[i]\n if (link.href != null) {\n existing_stylesheets.push(link.href)\n }\n }\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const escaped = encodeURI(url)\n if (existing_stylesheets.indexOf(escaped) !== -1) {\n on_load()\n continue;\n }\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n } if (((window.deck !== undefined) && (!(window.deck instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/h3-js@4.1.0/dist/h3-js.umd.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/deck.gl@9.0.20/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/json@9.0.20/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/csv@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/json@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/3d-tiles@4.2.2/dist/dist.min.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.js', 'https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl/dist/maplibre-gl.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(encodeURI(urls[i]))\n }\n } if (((window.mapboxgl !== undefined) && (!(window.mapboxgl instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/carto@^9.0.20/dist.min.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(encodeURI(urls[i]))\n }\n } var existing_scripts = []\n const scripts = document.getElementsByTagName('script')\n for (let i = 0; i < scripts.length; i++) {\n var script = scripts[i]\n if (script.src != null) {\n existing_scripts.push(script.src)\n }\n }\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const escaped = encodeURI(url)\n if (skip.indexOf(escaped) !== -1 || existing_scripts.indexOf(escaped) !== -1) {\n if (!window.requirejs) {\n on_load();\n }\n continue;\n }\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (let i = 0; i < js_modules.length; i++) {\n const url = js_modules[i];\n const escaped = encodeURI(url)\n if (skip.indexOf(escaped) !== -1 || existing_scripts.indexOf(escaped) !== -1) {\n if (!window.requirejs) {\n on_load();\n }\n continue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (const name in js_exports) {\n const url = js_exports[name];\n const escaped = encodeURI(url)\n if (skip.indexOf(escaped) >= 0 || root[name] != null) {\n if (!window.requirejs) {\n on_load();\n }\n continue;\n }\n var element = document.createElement('script');\n element.onerror = on_error;\n element.async = false;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n element.textContent = `\n import ${name} from \"${url}\"\n window.${name} = ${name}\n window._bokeh_on_load()\n `\n document.head.appendChild(element);\n }\n if (!js_urls.length && !js_modules.length) {\n on_load()\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/h3-js@4.1.0/dist/h3-js.umd.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/deck.gl@9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/json@9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/csv@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/json@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@loaders.gl/3d-tiles@4.2.2/dist/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl/dist/maplibre-gl.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/@deck.gl/carto@^9.0.20/dist.min.js\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/reactiveesm/es-module-shims@^1.10.0/dist/es-module-shims.min.js\"];\n const js_modules = [];\n const js_exports = {};\n const css_urls = [\"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/mapbox-gl-js/v3.0.1/mapbox-gl.css?v=1.5.2\", \"https://cdn.holoviz.org/panel/1.5.2/dist/bundled/deckglplot/maplibre-gl@4.4.1/dist/maplibre-gl.css?v=1.5.2\"];\n const inline_js = [ function(Bokeh) {\n inject_raw_css(\"\\n.dataframe table{\\n border: none;\\n}\\n\\n.panel-df table{\\n width: 100%;\\n border-collapse: collapse;\\n border: none;\\n}\\n.panel-df td{\\n white-space: nowrap;\\n overflow: auto;\\n text-overflow: ellipsis;\\n}\\n\");\n }, function(Bokeh) {\n inject_raw_css(\"\\n.multi-select{\\n color: white;\\n z-index: 100;\\n background: rgba(44,43,43,0.5);\\n border-radius: 1px;\\n width: 120px !important;\\n height: 30px !important;\\n}\\n.multi-select > .bk {\\n padding: 5px;\\n width: 120px !important;\\n height: 30px !important;\\n}\\n\\n.deck-chart {\\n z-index: 10;\\n position: initial !important;\\n}\\n\");\n }, function(Bokeh) {\n inject_raw_css(\"\\n.center-header {\\n text-align: center\\n}\\n.bk-input-group {\\n padding: 10px;\\n}\\n#sidebar {\\n padding-top: 10px;\\n}\\n.custom-widget-box {\\n margin-top: 20px;\\n padding: 5px;\\n border: None !important;\\n}\\n.custom-widget-box > p {\\n margin: 0px;\\n}\\n.bk-input-group {\\n color: None !important;\\n}\\n.indicator {\\n text-align: center;\\n}\\n.widget-card {\\n margin: 5px 10px;\\n}\\n.number-card {\\n margin: 5px 10px;\\n text-align: center;\\n}\\n.number-card-value {\\n width: 100%;\\n margin: 0px;\\n}\\n\");\n }, function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n (function(root, factory) {\n factory(root[\"Bokeh\"]);\n })(this, function(Bokeh) {\n let define;\n return (function outer(modules, entry) {\n if (Bokeh != null) {\n return Bokeh.register_plugin(modules, entry);\n } else {\n throw new Error(\"Cannot find Bokeh. You have to load it prior to loading plugins.\");\n }\n })\n ({\n \"custom/main\": function(require, module, exports) {\n const models = {\n \"CustomInspectTool\": require(\"custom/cuxfilter.charts.datashader.custom_extensions.graph_inspect_widget.custom_inspect_tool\").CustomInspectTool\n };\n require(\"base\").register_models(models);\n module.exports = models;\n },\n \"custom/cuxfilter.charts.datashader.custom_extensions.graph_inspect_widget.custom_inspect_tool\": function(require, module, exports) {\n \"use strict\";\n var _a;\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.CustomInspectTool = exports.CustomInspectToolView = void 0;\n const inspect_tool_1 = require(\"models/tools/inspectors/inspect_tool\");\n class CustomInspectToolView extends inspect_tool_1.InspectToolView {\n connect_signals() {\n super.connect_signals();\n this.on_change([this.model.properties.active], () => {\n this.model._active = this.model.active;\n });\n }\n }\n exports.CustomInspectToolView = CustomInspectToolView;\n CustomInspectToolView.__name__ = \"CustomInspectToolView\";\n class CustomInspectTool extends inspect_tool_1.InspectTool {\n constructor(attrs) {\n super(attrs);\n }\n }\n exports.CustomInspectTool = CustomInspectTool;\n _a = CustomInspectTool;\n CustomInspectTool.__name__ = \"CustomInspectTool\";\n (() => {\n _a.prototype.default_view = CustomInspectToolView;\n _a.define(({ Boolean }) => ({\n _active: [Boolean, true]\n }));\n _a.register_alias(\"customInspect\", () => new _a());\n })();\n //# sourceMappingURL=graph_inspect_widget.py:CustomInspectTool.js.map\n }\n }, \"custom/main\");\n ;\n });\n\n },\nfunction(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n if ((root.Bokeh !== undefined) || (force === true)) {\n for (let i = 0; i < inline_js.length; i++) {\n try {\n inline_js[i].call(root, root.Bokeh);\n } catch(e) {\n if (!reloading) {\n throw e;\n }\n }\n }\n // Cache old bokeh versions\n if (Bokeh != undefined && !reloading) {\n var NewBokeh = root.Bokeh;\n if (Bokeh.versions === undefined) {\n Bokeh.versions = new Map();\n }\n if (NewBokeh.version !== Bokeh.version) {\n Bokeh.versions.set(NewBokeh.version, NewBokeh)\n }\n root.Bokeh = Bokeh;\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n }\n root._bokeh_is_initializing = false\n }\n\n function load_or_wait() {\n // Implement a backoff loop that tries to ensure we do not load multiple\n // versions of Bokeh and its dependencies at the same time.\n // In recent versions we use the root._bokeh_is_initializing flag\n // to determine whether there is an ongoing attempt to initialize\n // bokeh, however for backward compatibility we also try to ensure\n // that we do not start loading a newer (Panel>=1.0 and Bokeh>3) version\n // before older versions are fully initialized.\n if (root._bokeh_is_initializing && Date.now() > root._bokeh_timeout) {\n // If the timeout and bokeh was not successfully loaded we reset\n // everything and try loading again\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_is_initializing = false;\n root._bokeh_onload_callbacks = undefined;\n root._bokeh_is_loading = 0\n console.log(\"Bokeh: BokehJS was loaded multiple times but one version failed to initialize.\");\n load_or_wait();\n } else if (root._bokeh_is_initializing || (typeof root._bokeh_is_initializing === \"undefined\" && root._bokeh_onload_callbacks !== undefined)) {\n setTimeout(load_or_wait, 100);\n } else {\n root._bokeh_is_initializing = true\n root._bokeh_onload_callbacks = []\n const bokeh_loaded = root.Bokeh != null && (root.Bokeh.version === py_version || (root.Bokeh.versions !== undefined && root.Bokeh.versions.has(py_version)));\n if (!reloading && !bokeh_loaded) {\n if (root.Bokeh) {\n root.Bokeh = undefined;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n }\n load_libs(css_urls, js_urls, js_modules, js_exports, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n }\n // Give older versions of the autoload script a head-start to ensure\n // they initialize before we start loading newer version.\n setTimeout(load_or_wait, 100)\n}(window));" }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "if ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n", " window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n", "}\n", "\n", "\n", " function JupyterCommManager() {\n", " }\n", "\n", " JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n", " if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n", " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n", " comm_manager.register_target(comm_id, function(comm) {\n", " comm.on_msg(msg_handler);\n", " });\n", " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n", " window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n", " comm.onMsg = msg_handler;\n", " });\n", " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n", " google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n", " var messages = comm.messages[Symbol.asyncIterator]();\n", " function processIteratorResult(result) {\n", " var message = result.value;\n", " console.log(message)\n", " var content = {data: message.data, comm_id};\n", " var buffers = []\n", " for (var buffer of message.buffers || []) {\n", " buffers.push(new DataView(buffer))\n", " }\n", " var metadata = message.metadata || {};\n", " var msg = {content, buffers, metadata}\n", " msg_handler(msg);\n", " return messages.next().then(processIteratorResult);\n", " }\n", " return messages.next().then(processIteratorResult);\n", " })\n", " }\n", " }\n", "\n", " JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n", " if (comm_id in window.PyViz.comms) {\n", " return window.PyViz.comms[comm_id];\n", " } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n", " var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n", " var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n", " if (msg_handler) {\n", " comm.on_msg(msg_handler);\n", " }\n", " } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n", " var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n", " comm.open();\n", " if (msg_handler) {\n", " comm.onMsg = msg_handler;\n", " }\n", " } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n", " var comm_promise = google.colab.kernel.comms.open(comm_id)\n", " comm_promise.then((comm) => {\n", " window.PyViz.comms[comm_id] = comm;\n", " if (msg_handler) {\n", " var messages = comm.messages[Symbol.asyncIterator]();\n", " function processIteratorResult(result) {\n", " var message = result.value;\n", " var content = {data: message.data};\n", " var metadata = message.metadata || {comm_id};\n", " var msg = {content, metadata}\n", " msg_handler(msg);\n", " return messages.next().then(processIteratorResult);\n", " }\n", " return messages.next().then(processIteratorResult);\n", " }\n", " }) \n", " var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n", " return comm_promise.then((comm) => {\n", " comm.send(data, metadata, buffers, disposeOnDone);\n", " });\n", " };\n", " var comm = {\n", " send: sendClosure\n", " };\n", " }\n", " window.PyViz.comms[comm_id] = comm;\n", " return comm;\n", " }\n", " window.PyViz.comm_manager = new JupyterCommManager();\n", " \n", "\n", "\n", "var JS_MIME_TYPE = 'application/javascript';\n", "var HTML_MIME_TYPE = 'text/html';\n", "var EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\n", "var CLASS_NAME = 'output';\n", "\n", "/**\n", " * Render data to the DOM node\n", " */\n", "function render(props, node) {\n", " var div = document.createElement(\"div\");\n", " var script = document.createElement(\"script\");\n", " node.appendChild(div);\n", " node.appendChild(script);\n", "}\n", "\n", "/**\n", " * Handle when a new output is added\n", " */\n", "function handle_add_output(event, handle) {\n", " var output_area = handle.output_area;\n", " var output = handle.output;\n", " if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n", " return\n", " }\n", " var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", " var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", " if (id !== undefined) {\n", " var nchildren = toinsert.length;\n", " var html_node = toinsert[nchildren-1].children[0];\n", " html_node.innerHTML = output.data[HTML_MIME_TYPE];\n", " var scripts = [];\n", " var nodelist = html_node.querySelectorAll(\"script\");\n", " for (var i in nodelist) {\n", " if (nodelist.hasOwnProperty(i)) {\n", " scripts.push(nodelist[i])\n", " }\n", " }\n", "\n", " scripts.forEach( function (oldScript) {\n", " var newScript = document.createElement(\"script\");\n", " var attrs = [];\n", " var nodemap = oldScript.attributes;\n", " for (var j in nodemap) {\n", " if (nodemap.hasOwnProperty(j)) {\n", " attrs.push(nodemap[j])\n", " }\n", " }\n", " attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n", " newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n", " oldScript.parentNode.replaceChild(newScript, oldScript);\n", " });\n", " if (JS_MIME_TYPE in output.data) {\n", " toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n", " }\n", " output_area._hv_plot_id = id;\n", " if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n", " window.PyViz.plot_index[id] = Bokeh.index[id];\n", " } else {\n", " window.PyViz.plot_index[id] = null;\n", " }\n", " } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", " var bk_div = document.createElement(\"div\");\n", " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", " var script_attrs = bk_div.children[0].attributes;\n", " for (var i = 0; i < script_attrs.length; i++) {\n", " toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n", " }\n", " // store reference to server id on output_area\n", " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", " }\n", "}\n", "\n", "/**\n", " * Handle when an output is cleared or removed\n", " */\n", "function handle_clear_output(event, handle) {\n", " var id = handle.cell.output_area._hv_plot_id;\n", " var server_id = handle.cell.output_area._bokeh_server_id;\n", " if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n", " var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n", " if (server_id !== null) {\n", " comm.send({event_type: 'server_delete', 'id': server_id});\n", " return;\n", " } else if (comm !== null) {\n", " comm.send({event_type: 'delete', 'id': id});\n", " }\n", " delete PyViz.plot_index[id];\n", " if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n", " var doc = window.Bokeh.index[id].model.document\n", " doc.clear();\n", " const i = window.Bokeh.documents.indexOf(doc);\n", " if (i > -1) {\n", " window.Bokeh.documents.splice(i, 1);\n", " }\n", " }\n", "}\n", "\n", "/**\n", " * Handle kernel restart event\n", " */\n", "function handle_kernel_cleanup(event, handle) {\n", " delete PyViz.comms[\"hv-extension-comm\"];\n", " window.PyViz.plot_index = {}\n", "}\n", "\n", "/**\n", " * Handle update_display_data messages\n", " */\n", "function handle_update_output(event, handle) {\n", " handle_clear_output(event, {cell: {output_area: handle.output_area}})\n", " handle_add_output(event, handle)\n", "}\n", "\n", "function register_renderer(events, OutputArea) {\n", " function append_mime(data, metadata, element) {\n", " // create a DOM node to render to\n", " var toinsert = this.create_output_subarea(\n", " metadata,\n", " CLASS_NAME,\n", " EXEC_MIME_TYPE\n", " );\n", " this.keyboard_manager.register_events(toinsert);\n", " // Render to node\n", " var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", " render(props, toinsert[0]);\n", " element.append(toinsert);\n", " return toinsert\n", " }\n", "\n", " events.on('output_added.OutputArea', handle_add_output);\n", " events.on('output_updated.OutputArea', handle_update_output);\n", " events.on('clear_output.CodeCell', handle_clear_output);\n", " events.on('delete.Cell', handle_clear_output);\n", " events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n", "\n", " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", " safe: true,\n", " index: 0\n", " });\n", "}\n", "\n", "if (window.Jupyter !== undefined) {\n", " try {\n", " var events = require('base/js/events');\n", " var OutputArea = require('notebook/js/outputarea').OutputArea;\n", " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", " register_renderer(events, OutputArea);\n", " }\n", " } catch(err) {\n", " }\n", "}\n" ], "application/vnd.holoviews_load.v0+json": "\nif ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n}\n\n\n function JupyterCommManager() {\n }\n\n JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n comm_manager.register_target(comm_id, function(comm) {\n comm.on_msg(msg_handler);\n });\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n comm.onMsg = msg_handler;\n });\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n console.log(message)\n var content = {data: message.data, comm_id};\n var buffers = []\n for (var buffer of message.buffers || []) {\n buffers.push(new DataView(buffer))\n }\n var metadata = message.metadata || {};\n var msg = {content, buffers, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n })\n }\n }\n\n JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n if (comm_id in window.PyViz.comms) {\n return window.PyViz.comms[comm_id];\n } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n if (msg_handler) {\n comm.on_msg(msg_handler);\n }\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n comm.open();\n if (msg_handler) {\n comm.onMsg = msg_handler;\n }\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n var comm_promise = google.colab.kernel.comms.open(comm_id)\n comm_promise.then((comm) => {\n window.PyViz.comms[comm_id] = comm;\n if (msg_handler) {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n var content = {data: message.data};\n var metadata = message.metadata || {comm_id};\n var msg = {content, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n }\n }) \n var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n return comm_promise.then((comm) => {\n comm.send(data, metadata, buffers, disposeOnDone);\n });\n };\n var comm = {\n send: sendClosure\n };\n }\n window.PyViz.comms[comm_id] = comm;\n return comm;\n }\n window.PyViz.comm_manager = new JupyterCommManager();\n \n\n\nvar JS_MIME_TYPE = 'application/javascript';\nvar HTML_MIME_TYPE = 'text/html';\nvar EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\nvar CLASS_NAME = 'output';\n\n/**\n * Render data to the DOM node\n */\nfunction render(props, node) {\n var div = document.createElement(\"div\");\n var script = document.createElement(\"script\");\n node.appendChild(div);\n node.appendChild(script);\n}\n\n/**\n * Handle when a new output is added\n */\nfunction handle_add_output(event, handle) {\n var output_area = handle.output_area;\n var output = handle.output;\n if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n return\n }\n var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n if (id !== undefined) {\n var nchildren = toinsert.length;\n var html_node = toinsert[nchildren-1].children[0];\n html_node.innerHTML = output.data[HTML_MIME_TYPE];\n var scripts = [];\n var nodelist = html_node.querySelectorAll(\"script\");\n for (var i in nodelist) {\n if (nodelist.hasOwnProperty(i)) {\n scripts.push(nodelist[i])\n }\n }\n\n scripts.forEach( function (oldScript) {\n var newScript = document.createElement(\"script\");\n var attrs = [];\n var nodemap = oldScript.attributes;\n for (var j in nodemap) {\n if (nodemap.hasOwnProperty(j)) {\n attrs.push(nodemap[j])\n }\n }\n attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n oldScript.parentNode.replaceChild(newScript, oldScript);\n });\n if (JS_MIME_TYPE in output.data) {\n toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n }\n output_area._hv_plot_id = id;\n if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n window.PyViz.plot_index[id] = Bokeh.index[id];\n } else {\n window.PyViz.plot_index[id] = null;\n }\n } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n var bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n var script_attrs = bk_div.children[0].attributes;\n for (var i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n}\n\n/**\n * Handle when an output is cleared or removed\n */\nfunction handle_clear_output(event, handle) {\n var id = handle.cell.output_area._hv_plot_id;\n var server_id = handle.cell.output_area._bokeh_server_id;\n if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n if (server_id !== null) {\n comm.send({event_type: 'server_delete', 'id': server_id});\n return;\n } else if (comm !== null) {\n comm.send({event_type: 'delete', 'id': id});\n }\n delete PyViz.plot_index[id];\n if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n var doc = window.Bokeh.index[id].model.document\n doc.clear();\n const i = window.Bokeh.documents.indexOf(doc);\n if (i > -1) {\n window.Bokeh.documents.splice(i, 1);\n }\n }\n}\n\n/**\n * Handle kernel restart event\n */\nfunction handle_kernel_cleanup(event, handle) {\n delete PyViz.comms[\"hv-extension-comm\"];\n window.PyViz.plot_index = {}\n}\n\n/**\n * Handle update_display_data messages\n */\nfunction handle_update_output(event, handle) {\n handle_clear_output(event, {cell: {output_area: handle.output_area}})\n handle_add_output(event, handle)\n}\n\nfunction register_renderer(events, OutputArea) {\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n var toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[0]);\n element.append(toinsert);\n return toinsert\n }\n\n events.on('output_added.OutputArea', handle_add_output);\n events.on('output_updated.OutputArea', handle_update_output);\n events.on('clear_output.CodeCell', handle_clear_output);\n events.on('delete.Cell', handle_clear_output);\n events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n safe: true,\n index: 0\n });\n}\n\nif (window.Jupyter !== undefined) {\n try {\n var events = require('base/js/events');\n var OutputArea = require('notebook/js/outputarea').OutputArea;\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n } catch(err) {\n }\n}\n" }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.holoviews_exec.v0+json": "", "text/html": [ "
\n", "
\n", "
\n", "" ] }, "metadata": { "application/vnd.holoviews_exec.v0+json": { "id": "c833f2a7-b033-4842-af33-6d341dac55c9" } }, "output_type": "display_data" }, { "data": {}, "metadata": {}, "output_type": "display_data" }, { "data": {}, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.holoviews_exec.v0+json": "", "text/html": [ "
\n", "
\n", "
\n", "" ], "text/plain": [ "GridSpec(ncols=12, nrows=1)\n", " [0] GridSpec(height=800, ncols=12, nrows=5, sizing_mode='fixed', width=1200)\n", " [0] HoloViews(DynamicMap, height=800, sizing_mode='stretch_both', width=1200)\n", " [1] WidgetBox(styles={'border-color': '...})\n", " [0] Number(css_classes=['indicator'], default_color='#2B2B2B', font_size='18pt', format='{value:,}', name='Datapoints Selected', sizing_mode='stretch_width', title_size='14pt', value=3048671)\n", " [1] Progress(sizing_mode='stretch_width', styles={'--success-bg-color': '...}, value=100)" ] }, "execution_count": 31, "metadata": { "application/vnd.holoviews_exec.v0+json": { "id": "c579838c-ec72-4a6d-aafd-3647931753b4" } }, "output_type": "execute_result" } ], "source": [ "dash = cxf_data.dashboard([heatmap_chart], theme=cxf.themes.dark, data_size_widget=True)\n", "\n", "dash.app()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import IPython\n", "app = IPython.Application.instance()\n", "app.kernel.do_shutdown(True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Well Done!** Let's move to the [next notebook](2-04_networkx_cugraph.ipynb). " ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.15" } }, "nbformat": 4, "nbformat_minor": 4 }