Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fea/sidebar api change #262

Merged
merged 23 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion python/cuxfilter/charts/core/aggregate/core_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ class BaseAggregateChart(BaseChart):
def datatile_loaded_state(self):
return self._datatile_loaded_state

@property
def name(self):
# overwrite BaseChart name function to allow unique choropleths on
# value x
if self.chart_type is not None:
return f"{self.x}_{self.aggregate_fn}_{self.chart_type}"
else:
return f"{self.x}_{self.aggregate_fn}_chart"

@datatile_loaded_state.setter
def datatile_loaded_state(self, state: bool):
self._datatile_loaded_state = state
Expand Down Expand Up @@ -289,7 +298,7 @@ def add_range_slider_filter(self, dashboard_cls):
)

def filter_widget_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
dashboard_cls._reset_current_view(new_active_view=self)
dashboard_cls._calc_data_tiles()
query_tuple = self._xaxis_np_dt64_transform(event.new)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ class BaseChoropleth(BaseChart):
def datatile_loaded_state(self):
return self._datatile_loaded_state

@property
def name(self):
# overwrite BaseChart name function to allow unique choropleths on
# value x
if self.chart_type is not None:
return f"{self.x}_{self.aggregate_fn}_{self.chart_type}"
else:
return f"{self.x}_{self.aggregate_fn}_chart"

@datatile_loaded_state.setter
def datatile_loaded_state(self, state: bool):
self._datatile_loaded_state = state
Expand Down Expand Up @@ -228,7 +237,7 @@ def get_selection_callback(self, dashboard_cls):
"""

def selection_callback(old, new):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
dashboard_cls._reset_current_view(new_active_view=self)
dashboard_cls._calc_data_tiles(cumsum=False)
dashboard_cls._query_datatiles_by_indices(old, new)
Expand Down Expand Up @@ -286,7 +295,7 @@ def add_reset_event(self, dashboard_cls):
"""

def reset_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
# reset previous active view and set current chart as
# active view
dashboard_cls._reset_current_view(new_active_view=self)
Expand Down
2 changes: 2 additions & 0 deletions python/cuxfilter/charts/core/aggregate/core_number_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

class BaseNumberChart(BaseChart):
stride = 1
# widget is a chart type that can be rendered in a sidebar or main layout
bryevdv marked this conversation as resolved.
Show resolved Hide resolved
is_widget = True

@property
def use_data_tiles(self):
Expand Down
8 changes: 4 additions & 4 deletions python/cuxfilter/charts/core/core_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class BaseChart:
x_label_map = {}
y_label_map = {}
_initialized = False
# widget=False can only be rendered the main layout
is_widget = False

@property
def name(self):
if self.chart_type is not None:
return self.x + "_" + self.chart_type
else:
return self.x + "_"
chart_type = self.chart_type if self.chart_type else "chart"
return f"{self.x}_{chart_type}"

@property
def width(self):
Expand Down
2 changes: 2 additions & 0 deletions python/cuxfilter/charts/core/core_view_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class ViewDataFrame:
use_data_tiles = False
drop_duplicates = False
_initialized = False
# widget=False can only be rendered the main layout
is_widget = False

def __init__(
self,
Expand Down
5 changes: 4 additions & 1 deletion python/cuxfilter/charts/core/core_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ class BaseWidget:
label_map: Dict[str, str] = None
use_data_tiles = False
_initialized = False
# widget is a chart type that can be rendered in a sidebar or main layout
is_widget = True

@property
def name(self):
return self.x
chart_type = self.chart_type if self.chart_type else "widget"
return f"{self.x}_{chart_type}"

@property
def stride(self):
Expand Down
10 changes: 8 additions & 2 deletions python/cuxfilter/charts/core/non_aggregate/core_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class BaseGraph(BaseChart):
def colors_set(self):
return self._node_color_palette_input is not None

@property
def name(self):
# overwrite BaseChart name function to allow unique chart on value x
chart_type = self.chart_type if self.chart_type else "chart"
return f"{self.node_x}_{self.node_y}_{self._node_id}_{chart_type}"

@property
def node_color_palette(self):
if self.colors_set:
Expand Down Expand Up @@ -313,7 +319,7 @@ def box_callback(xmin, xmax, ymin, ymax):
del nodes, edges

def selection_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
# reset previous active view and
# set current chart as active view
dashboard_cls._reset_current_view(new_active_view=self)
Expand Down Expand Up @@ -404,7 +410,7 @@ def add_reset_event(self, dashboard_cls):
"""

def reset_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
# reset previous active view and set current
# chart as active view
dashboard_cls._reset_current_view(new_active_view=self)
Expand Down
2 changes: 1 addition & 1 deletion python/cuxfilter/charts/core/non_aggregate/core_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def add_range_slider_filter(self, dashboard_cls):
)

def filter_widget_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
dashboard_cls._reset_current_view(new_active_view=self)
dashboard_cls._calc_data_tiles()
query_tuple = self._xaxis_np_dt64_transform(event.new)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class BaseNonAggregate(BaseChart):
aggregate_col = None
use_data_tiles = False

@property
def name(self):
# overwrite BaseChart name function to allow unique chart on value x
chart_type = self.chart_type if self.chart_type else "chart"
return f"{self.x}_{self.y}_{chart_type}"

def initiate_chart(self, dashboard_cls):
"""
Description:
Expand Down Expand Up @@ -149,7 +155,7 @@ def box_callback(xmin, xmax, ymin, ymax):

def selection_callback(event):
self.test_event = event
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
# reset previous active view and
# set current chart as active view
dashboard_cls._reset_current_view(new_active_view=self)
Expand Down Expand Up @@ -240,7 +246,7 @@ def add_reset_event(self, dashboard_cls):
"""

def reset_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
# reset previous active view and set current
# chart as active view
dashboard_cls._reset_current_view(new_active_view=self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def selection_callback(event):
xmin, xmax = self._xaxis_dt_transform(
(event.geometry["x0"], event.geometry["x1"])
)
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
# reset previous active view and
# set current chart as active view
dashboard_cls._reset_current_view(new_active_view=self)
Expand Down Expand Up @@ -262,7 +262,7 @@ def add_reset_event(self, dashboard_cls):
"""

def reset_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
# reset previous active view and
# set current chart as active view
dashboard_cls._reset_current_view(new_active_view=self)
Expand Down
12 changes: 6 additions & 6 deletions python/cuxfilter/charts/panel_widgets/panel_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def range_slider(
plot = RangeSlider(
x, width, height, data_points, step_size, step_size_type, **params
)
plot.chart_type = "widget_range_slider"
plot.chart_type = "range_slider"
return plot


Expand Down Expand Up @@ -98,7 +98,7 @@ def date_range_slider(
step_size_type=CUDF_TIMEDELTA_TYPE,
**params,
)
plot.chart_type = "widget_date_range_slider"
plot.chart_type = "date_range_slider"
return plot


Expand Down Expand Up @@ -136,7 +136,7 @@ def int_slider(
plot = IntSlider(
x, width, height, data_points, step_size, step_size_type=int, **params
)
plot.chart_type = "widget_int_slider"
plot.chart_type = "int_slider"
return plot


Expand Down Expand Up @@ -180,7 +180,7 @@ def float_slider(
step_size_type=float,
**params,
)
plot.chart_type = "widget_float_slider"
plot.chart_type = "float_slider"
return plot


Expand Down Expand Up @@ -209,7 +209,7 @@ def drop_down(x, width=400, height=50, **params):

"""
plot = DropDown(x, width, height, **params)
plot.chart_type = "widget_dropdown"
plot.chart_type = "dropdown"
return plot


Expand Down Expand Up @@ -238,7 +238,7 @@ def multi_select(x, width=400, height=200, **params):

"""
plot = MultiSelect(x, width, height, **params)
plot.chart_type = "widget_multi_select"
plot.chart_type = "multi_select"
return plot


Expand Down
16 changes: 9 additions & 7 deletions python/cuxfilter/charts/panel_widgets/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def add_events(self, dashboard_cls):
"""

def widget_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
dashboard_cls._reset_current_view(new_active_view=self)
dashboard_cls._calc_data_tiles()

Expand Down Expand Up @@ -186,7 +186,7 @@ def add_events(self, dashboard_cls):
"""

def widget_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
dashboard_cls._reset_current_view(new_active_view=self)
dashboard_cls._calc_data_tiles()
query_tuple = self._xaxis_np_dt64_transform(event.new)
Expand Down Expand Up @@ -285,7 +285,7 @@ def add_events(self, dashboard_cls):
"""

def widget_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
dashboard_cls._reset_current_view(new_active_view=self)
dashboard_cls._calc_data_tiles()
dashboard_cls._query_datatiles_by_indices([], [event.new])
Expand Down Expand Up @@ -380,7 +380,7 @@ def add_events(self, dashboard_cls):
"""

def widget_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
dashboard_cls._reset_current_view(new_active_view=self)
dashboard_cls._calc_data_tiles(cumsum=False)

Expand Down Expand Up @@ -481,7 +481,7 @@ def add_events(self, dashboard_cls):
"""

def widget_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
dashboard_cls._reset_current_view(new_active_view=self)
dashboard_cls._calc_data_tiles(cumsum=False)
dashboard_cls._query_datatiles_by_indices([], [event.new])
Expand Down Expand Up @@ -581,7 +581,7 @@ def add_events(self, dashboard_cls):
"""

def widget_callback(event):
if dashboard_cls._active_view != self.name:
if dashboard_cls._active_view != self:
dashboard_cls._reset_current_view(new_active_view=self)
dashboard_cls._calc_data_tiles(cumsum=False)
dashboard_cls._query_datatiles_by_indices(event.old, event.new)
Expand Down Expand Up @@ -757,6 +757,8 @@ def reset_chart(self, data: float = -1):
class Card:
use_data_tiles = False
_initialized = True
# widget is a chart type that can be rendered in a sidebar or main layout
is_widget = True

@property
def name(self):
Expand All @@ -765,7 +767,7 @@ def name(self):
def __init__(self, content="", title="", widget=True):
self.content = content
self.title = title
self.chart_type = "card" if not widget else "card_widget"
self.chart_type = "card"

def view(self):
return chart_view(self.content, title=self.title)
Expand Down
Loading