Hi Again, I have created an example which doesn’t quite work. The call back is being now being called. So some progress. I don’t know how to change the CDSView Filter list.
Is impossibly to pass in another argument to the callback?
At the moment I set it to [] which seems to zoom the map to a single point but does not update the table view.
Any advice would be appreciated
Ian
from arcgis import geometry
from bokeh.io import output_file, show
from bokeh.models import ColumnDataSource, Range1d, CDSView, IndexFilter, CustomJS, Div
from bokeh.plotting import figure
from bokeh.models import BoxZoomTool, ResetTool, PanTool, WheelZoomTool, BoxSelectTool, TapTool, HoverTool, WheelPanTool
from bokeh.models import WMTSTileSource
from bokeh.layouts import layout, column, row, Spacer, gridplot
from bokeh.models.glyphs import ImageURL
import pandas as pd
from bokeh.models.widgets import DataTable, TableColumn
import json
from bokeh import events
#create the data sructure for most all of the applications
table_data = {‘x’: [1,2,3,4,5,6], ‘y’: [1,2,3,4,5,6]}
#table of data
plot_table = figure(title=‘Tabular Representation’)
df = pd.DataFrame(table_data)
table_source_data = ColumnDataSource(df)
plot_table_columns = [
TableColumn(field=“x”, title=“X”),
TableColumn(field=“y”, title=“Y”)
]
#test filter
table_filter = [IndexFilter([0, 2, 4])]
table_filter2 = [IndexFilter([1, 2, 3, 4, 5])]
#table_filter =
table_view = CDSView(source=table_source_data, filters=table_filter)
table_view2 = CDSView(source=table_source_data, filters=table_filter2)
#plot_table = DataTable(source=table_source_data, columns=plot_table_columns, width=1000, height=500)
#plot_table = DataTable(source=table_source_data, columns=plot_table_columns, width=1000, height=500, view = table_view)
plot_table = DataTable(source=table_source_data, columns=plot_table_columns, width=1000, height=500, view = table_view)
#Callback for Reset Tool
mapResetCallback= CustomJS(args=dict(source=table_source_data), code=“”"
var data = source.data;
data.view = []
console.log(source.data)
source.change.emit()
“”")
#Callback for Reset Tool
resetTool = ResetTool()
resetTool.js_on_change(‘do’, mapResetCallback)
#plot_map.callback = CustomJS(args=dict(source=source, code=mapResetCallback))
map with plotted points
plot_map = figure(plot_width=700, plot_height=700,title=‘Map’)
plot_map_tools = [BoxZoomTool(), resetTool, PanTool(), WheelZoomTool(), BoxSelectTool(), TapTool(), HoverTool()]
plot_map.tools = plot_map_tools
plot_map.circle(x=‘x’, y=‘y’, alpha=0.9, size=20, color=‘red’,source=table_source_data,selection_color=‘yellow’,nonselection_fill_alpha=0.8, nonselection_fill_color=“white”,nonselection_line_color=“red”,nonselection_line_alpha=1.0)
plot_map.xaxis.visible = False
plot_map.yaxis.visible = False
#create tile source from templated url
tile_options = {}
tile_options[‘url’] = ‘https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg’
#tile_options[‘url’] = ‘https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{Z}/{Y}/{X}.jpg’
tile_source = WMTSTileSource(**tile_options)
tile_renderer_options = {}
plot_map.add_tile(tile_source, **tile_renderer_options)
lay = layout(plot_map, plot_table, sizing_mode=‘fixed’)
#lay = layout(row(column(plot_image),plot_map), plot_table, sizing_mode=‘fixed’)
output_file(“41Tester.html”, mode=‘inline’)
show(lay)
#show(row(plot_image))
···
On Sunday, 7 January 2018 16:44:31 UTC+10, Ian wrote:
Hi, being new I am finding this pretty impossible to figure out. I am creating a standalone html page with a map of point data and a table of the same data.
I would like to have the table reset to show all values when I click on the Reset Tool for the map.
I have created a CDSView and filter which works when called. I presume that updating the filter will update the rows displayed in the Table.
I have been unable to add a callback to the ResetTool that works. I would like to update the filters to show all the points in the reset map view.
From the documentation I have read I think I would have to create a javascript callback of some sort but nothing that I try alters the table contents.
Much appreciated if someone has an example of this they could post, otherwise step by step instructions so I at least know I am going down the right path.
I would also like a similar behaviour when I select a number of points in the map. i.e. to only display the selected rows in the table and “remove” the unselected from the table.
I should be able to figure that out if I could get a working solution to the reset event problem.
Thanks,
Ian