Hello,
I’m trying use DataCube to represent the bit statuses that are decoded from different integer codes. Ultimately I want to create something like this:
- Tier 1 Code
- Bit 1 Position | Bit 1 Definition | Bit 1 status
- Bit 2 Position | Bit 2 Definition | Bit 2 status
…
- Tier 2 Code
- Bit 1 Position | Bit 1 Definition | Bit 1 status
- Bit 2 Position | Bit 2 Definition | Bit 2 status
…
- Tier 3 Code
- Bit 1 Position | Bit 1 Definition | Bit 1 status
- Bit 2 Position | Bit 2 Definition | Bit 2 status
…
I have a text box for user to enter the codes, and when submit is pressed, the table should be updated with the newly decoded values. I chose DataCube because I like the idea of making my table collapsible so only the statuses from the expanded system is shown rather than displayed all at once.
I have a callback for the DataCube that updates the data content in the ColumnDataSource when new values are submitted by the user, and the values are being updated correctly. However, the issue I have is the updated table values don’t reflect on the DataCube until I either collapse/expand a row, or when I scroll up and down on the table. It’s almost as if the DataCube has a refresh functionality that is called only when there is a display change on the table, but that functionality is not triggered when data source is updated. Am I doing anything wrong, or is this a known issue/feature of the DataCube. If so, are there any workarounds?
I won’t provide the entire code to avoid overcrowding this question, but CreateStackStatusList() basically retrieves the current bit status based on what the user inputs and decodes them. source data is udpated with a pandas dataframe. I’ve test the user input and data conversion pipeline and it works as expected. Plus, when the data is refreshed on the DataCube, the values are correct. I’m just struggling to figure out if there is a way to manually refresh the DataCube in my callback function. Thanks!
Here is a snippet of my current data cube:
Here is the code:
def submit_callback():
"""
call back function when submit button is pressed.
"""
table_source.data = pd.DataFrame(CreateStackStatusList())
cube.columns = cube.columns
cube.source = table_source
table_source = ColumnDataSource(data=pd.DataFrame(CreateStackStatusList()))
target = ColumnDataSource(data=dict(row_indices=[], labels=[]))
formatter = StringFormatter(font_style='bold')
columns = [
TableColumn(field='Bit', title='Bit', width=40),
TableColumn(field='Name', title='Bit Name', width=100, formatter=formatter),
TableColumn(field='Status', title='Bit Status', width=50, formatter=HTMLTemplateFormatter(
template='<div style="background:<%= (value == 1) ? "lightgreen" : "lightpink" %>;"><%= value %></div>')),
]
grouping = [ GroupingInfo(getter='Tier', aggregators=[]), ]
cube = DataCube(source=table_source, columns=columns, grouping=grouping, target=target, height=1000)
button = Button(label="Submit")
button.on_event('button_click', submit_callback)