Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const DEFAULT_ORDER = [
'partition',
'event_flow',
'deck_path',
'directed_force',
'graph_chart',
'world_map',
'paired_ttest',
'para',
Expand Down
16 changes: 7 additions & 9 deletions superset/examples/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,21 @@ def load_energy(

slc = Slice(
slice_name="Energy Force Layout",
viz_type="directed_force",
viz_type="graph_chart",
datasource_type="table",
datasource_id=tbl.id,
params=textwrap.dedent(
"""\
{
"charge": "-500",
"collapsed_fieldsets": "",
"groupby": [
"source",
"target"
],
"link_length": "200",
"source": "source",
"target": "target",
"edgeLength": 400,
"repulsion": 1000,
"layout": "force",
"metric": "sum__value",
"row_limit": "5000",
"slice_name": "Force",
"viz_type": "directed_force"
"viz_type": "graph_chart"
}
"""
),
Expand Down
25 changes: 0 additions & 25 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1898,31 +1898,6 @@ def visit(vertex: str) -> Optional[Tuple[str, str]]:
return recs


class DirectedForceViz(BaseViz):

"""An animated directed force layout graph visualization"""

viz_type = "directed_force"
verbose_name = _("Directed Force Layout")
credits = 'd3noob @<a href="http://bl.ocks.org/d3noob/5141278">bl.ocks.org</a>'
is_timeseries = False

def query_obj(self) -> QueryObjectDict:
qry = super().query_obj()
if len(self.form_data["groupby"]) != 2:
raise QueryObjectValidationError(_("Pick exactly 2 columns to 'Group By'"))
qry["metrics"] = [self.form_data["metric"]]
if self.form_data.get("sort_by_metric", False):
qry["orderby"] = [(qry["metrics"][0], False)]
return qry

def get_data(self, df: pd.DataFrame) -> VizData:
if df.empty:
return None
df.columns = ["source", "target", "value"]
return df.to_dict(orient="records")


class ChordViz(BaseViz):

"""A Chord diagram"""
Expand Down
13 changes: 7 additions & 6 deletions tests/fixtures/energy_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,17 @@ def _get_energy_slices():
},
{
"slice_title": "Energy Force Layout",
"viz_type": "directed_force",
"viz_type": "graph_chart",
"params": {
"charge": "-500",
"collapsed_fieldsets": "",
"groupby": ["source", "target"],
"link_length": "200",
"source": "source",
"target": "target",
"edgeLength": 400,
"repulsion": 1000,
"layout": "force",
"metric": "sum__value",
"row_limit": "5000",
"slice_name": "Force",
"viz_type": "directed_force",
"viz_type": "graph_chart",
},
},
{
Expand Down