mirror of https://github.com/apache/superset.git
changes added (#13431)
This commit is contained in:
parent
dc170397c5
commit
8b38d63b7d
|
@ -85,7 +85,7 @@ const DEFAULT_ORDER = [
|
|||
'partition',
|
||||
'event_flow',
|
||||
'deck_path',
|
||||
'directed_force',
|
||||
'graph_chart',
|
||||
'world_map',
|
||||
'paired_ttest',
|
||||
'para',
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
"""
|
||||
),
|
||||
|
|
|
@ -1898,31 +1898,6 @@ class SankeyViz(BaseViz):
|
|||
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"""
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue