GithubHelp home page GithubHelp logo

ipysankeywidget's People

Contributors

chimeworld avatar dependabot[bot] avatar mmeendez8 avatar npmcdn-to-unpkg-bot avatar ricklupton avatar sildar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ipysankeywidget's Issues

"Error displaying widget" in Jupyterlab

Hi

I can get ipysankeywidget working in jupyter (on jupyterhub), but it fails when the notebook is opened with jupyterlab. Here the error:

Error displaying widget

The console shows a bit more information:
error-ipysankey

Any idea on how to install it on jupyterlab? jupyterlab-manager is well installed, plotly and other ipywidget extension work fine. I can't get ipysankey to load jupyter-sankey-widget.

Thanks

Changing font size and style

I am trying to use the ipysankeywidget, and it works fine, but I can't find a way to change the font size of node titles. I have tried setting things by accessing the sankey object like this:
nbsankeyExample.font_style = 'italic'
nbsankeyExample.font_style
u'italic'
, and it returns the value correctly, but when showing the widget again, the value is not used.

Controlling max iterations

Hello,
I would like to know if it is possible to control the maximum iterations for a sankey plot.
I have the impression that this is allowed in d3-sankey-diagram.

If this functionality is not available just for python , I could give it a try

Thanks

Chart fails to display depending on data

In the Quickstart tutorial, I tried my own data from our maintenance records. There are 12 records in one file, and this displays without problems. But, when data collected over a few more days are added, as in the second csv file with 16 records, the chart fails to display.
TwoInputCSVfiles.zip

Widget not displayed in Jupyter (Chrome)

Windows 10 on Chrome. The code is right (copypasted from the example). I tried both pip and conda installations. The widget is simply not displayed, no error message. I activated the jupyter extensions. This thread was not helpful.

Another formatting question

I am trying to display patient paths using sankey diagrams. I increased the node width using
.node-body { fill: #bbb; stroke: gray; stroke-width: 20px; opacity: 1.0; }

Now I want to change the following

  1. The position of the labels and values so that the wide node does not cover them.
  2. The size of numbers (linkValues). Is there a font size option for this?
  3. Is there any way to write values within the node rectangle. I have already accomplished this using groups so I was wondering if there is a better approach for this?

image

Compatibility with Jupyter Lab

Is there any chance of updating this to make it work with Jupyter Labs? It's a bit tedious to constantly swap between the Lab and Notebook interfaces to see outputs.

jupyterlab error displaying widget

Hello

I was using ipsankeywidget with jupyter notebooks but I've recently (today) reinstalled it and was hoping to be able to use on jupyter lab with the new support.

However I am getting an error: Error displaying widget: model not found even with very simple diagrams. the extensions seem to be correctly installed.

imagen

If I try to run the same notebook using the classic notebook I don't get the same error but there is no rendered image.

thanks!

Broken Saved PNG

Hi,

I'm running to create multiple sankey diagrams in a for loop and all plots well on jupyter notebook. However, the auto_save_png files sometimes does not look ok. They may be cropped - while colors, etc. (as seen below)

As the png or svg appears sometimes:
sankey_0_16 639

Expected output and what is being seen on jupyter notebook:
sankey_3_21 733

Do you know if there is a way to overcome this problem?

Stuck on "Loading widget" while plotting in jupyterlab

Hey guys, I encounter a problem with sankey widget.

OS: Ubuntu with nodejs10 and d3-sankey package installed.
Jupyterlab: 1.1.4 with jlab-manager plugin installed
ipywidgets: 7.5.1
python: 3.7.4
browser: chrome and firefox

I make sure ipywidgets works proper but while I test the simple example listed in the document, it shows "Loading widget..." on displaying the sankeywidget object as coding shows below:

layout = Layout(width="500", height="200")
w = SankeyWidget(links=links, margins=dict(top=0, bottom=0, left=50, right=80), layout=layout)
w <- stuck here

I tried to print w.png and it is ''.

So what's the possible reason and what could I do to get the figure?
Thanks in advance.

flow_selection with 'source.some_key' doesn't work because of pandas.eval()

When creating a dataset with dim_process (and also probably with dim_material and dim_time, although I didn't try), there is a problem if you try to later use the flow_selection param when creating a Bundle. Because the dataset is constructed by adding a prefix source. and target. (note the dot), pandas gets angry whenever floweaver.dataset.eval_selection gets called.

For example, if I have created a Dataset like so:

import pandas as pd
from floweaver import *
flows = pd.DataFrame(
    [['a', 'b', 10],
     ['a', 'c', 20],
     ['b', 'b', 5],
     ['b', 'd', 5],
     ['c', 'd', 20]],
    columns=['source', 'target', 'value']
)
processes = pd.DataFrame(
    ['fooA', 'fooB', 'fooC', 'fooD'],
    columns=['foo'],
    index=['a', 'b', 'c', 'd']
)

dataset = Dataset(flows, dim_process=processes)


nodes = {
    'node1': ProcessGroup(['a']),
    'node2': ProcessGroup(['b', 'c']),
    'node3': ProcessGroup(['d']),
    'wp': Waypoint(direction='R')
}
ordering = [['node1'], ['node2', 'wp'], ['node3']]
bundles = [
    Bundle('node1', 'node2'),
    Bundle('node2', 'node2', flow_selection='source.foo == "fooB"', waypoints=['wp']),
    Bundle('node2', 'node3'),
]

sdd = SankeyDefinition(nodes, bundles, ordering)

weave(sdd, dataset).to_widget()

This fails with the following traceback:

AttributeError                            Traceback (most recent call last)
<ipython-input-6-04c4391e4f95> in <module>
     33 sdd = SankeyDefinition(nodes, bundles, ordering)
     34 
---> 35 weave(sdd, dataset).to_widget()

~/.pyenv/versions/3.6.7/envs/flotest/lib/python3.6/site-packages/floweaver/weave.py in weave(sankey_definition, dataset, measures, link_width, link_color, palette)
     43     # Get the flows selected by the bundles
     44     bundle_flows, unused_flows = dataset.apply_view(
---> 45         sankey_definition.nodes, bundles2, sankey_definition.flow_selection)
     46 
     47     # Calculate the results graph (actual Sankey data)

~/.pyenv/versions/3.6.7/envs/flotest/lib/python3.6/site-packages/floweaver/dataset.py in apply_view(self, process_groups, bundles, flow_selection)
     88 
     89     def apply_view(self, process_groups, bundles, flow_selection=None):
---> 90         return _apply_view(self, process_groups, bundles, flow_selection)
     91 
     92     def save(self, filename):

~/.pyenv/versions/3.6.7/envs/flotest/lib/python3.6/site-packages/floweaver/dataset.py in _apply_view(dataset, process_groups, bundles, flow_selection)
    191         target = process_groups[bundle.target]
    192         flows, internal_source, internal_target = \
--> 193             find_flows(table, source.selection, target.selection, bundle.flow_selection)
    194         assert len(used_edges.intersection(
    195             flows.index.values)) == 0, 'duplicate bundle'

~/.pyenv/versions/3.6.7/envs/flotest/lib/python3.6/site-packages/floweaver/dataset.py in find_flows(flows, source_query, target_query, flow_query, ignore_edges)
    136     """
    137     if flow_query is not None:
--> 138         flows = flows[eval_selection(flows, '', flow_query)]
    139 
    140     if source_query is None and target_query is None:

~/.pyenv/versions/3.6.7/envs/flotest/lib/python3.6/site-packages/floweaver/dataset.py in eval_selection(df, column, sel)
     38                        local_dict={},
     39                        global_dict={},
---> 40                        resolvers=(resolver, ))
     41     else:
     42         raise TypeError('Unknown selection type: %s' % type(sel))

~/.pyenv/versions/3.6.7/envs/flotest/lib/python3.6/site-packages/pandas/core/frame.py in eval(self, expr, inplace, **kwargs)
   3191             kwargs['target'] = self
   3192         kwargs['resolvers'] = kwargs.get('resolvers', ()) + tuple(resolvers)
-> 3193         return _eval(expr, inplace=inplace, **kwargs)
   3194 
   3195     def select_dtypes(self, include=None, exclude=None):

.....
{removed for brevity}
.....

~/.pyenv/versions/3.6.7/envs/flotest/lib/python3.6/site-packages/pandas/core/computation/expr.py in visit_Attribute(self, node, **kwargs)
    548 
    549         raise ValueError("Invalid Attribute context {name}"
--> 550                          .format(name=ctx.__name__))
    551 
    552     def visit_Call_35(self, node, side=None, **kwargs):

AttributeError: 'Load' object has no attribute '__name__'

Full traceback here: https://gist.github.com/mskoh52/7054199865c214ad1de8f0e4772582d4

I was able to solve this by editing dataset.py and replacing all the dots with underscores on lines 28 and 70-77, then replacing flow_selection string with underscores as well. Can submit a PR if desired, but I might be missing some other places where the dot is important and not realize it (haven't looked too extensively at the rest of the code)

Can't create graphic with single source

I have spent a reasonable amount trying to figure out why the widget was not appearing and finally I discover it was crashing due to the fact of using a single source.

You can reproduce the error with:

from ipysankeywidget import SankeyWidget

links = [{'source': 'A', 'target': 'R548', 'value': 2},
 {'source': 'A', 'target': 'R141', 'value': 2},
 {'source': 'A', 'target': 'R141', 'value': 2},
 {'source': 'A', 'target': 'R434', 'value': 2}]

w = SankeyWidget(links=links, margins=dict(top=0, bottom=0, left=50, right=100))

I might try to find the fix for it, but I am running out of time at this moment!

Cannot change height in Internet Explorer

Reported by Mike E: changes in height do not affect size of widget in Internet Explorer.

links = [
    {'source':'a_','target':'a','value':0},
    {'source':'a_','target':'b','value':4811.5},
    {'source':'a_','target':'c','value':6809},
    {'source':'b_','target':'a','value':3528.5},
    {'source':'b_','target':'b','value':0},
    {'source':'b_','target':'c','value':1307},
    {'source':'b_','target':'d','value':1342},
]

layout = Layout(width="300", height="100")
def sankey(margin_top=10, **value):
    """Show SankeyWidget with default values for size and margins"""
    return SankeyWidget(layout=layout, scale=0.001,
                        margins=dict(top=margin_top, bottom=0, left=100, right=100),
                        **value)
sankey(links=links)

Long labels of source and target gets cut off :'(

Long labels gets cut off.
Sometimes I need long labels.
I've been trying to get it to work all weekend. :'(

Thank you very much for helping!

for example, the image is produced by:
cutoff_example

layout = Layout( width="600", height="600", #margins=dict(left=300, right=300, top=50, bottom=50), #paddings=dict(left=300, right=300, top=50, bottom=50), flex_flow='row wrap', overflow = 'visible', border='1px solid black', grid_auto_flow='row', display='block' ) flows = pd.read_csv('simple_fruit_sales.csv') flows['source'] = flows['source'].apply(lambda x: x + "\nblahblah\n100000\n") flows['target'] = flows['target'].apply(lambda x: x + " derpy derp derp") w = SankeyWidget(links=flows.to_dict('records'), layout=layout) w

Is there a way to increase figure size?

I am using Chrome together with Jupyter and I am not able to increase the size of the diagram.
I have deduced from here #18 that it must exist some way to do this.
This is what I have tried and it is not working:

SankeyWidget(links=data.to_dict('records'), width=1000, height=900)

Nodes Vertical Alignment

Hi,

I was wondering if it'd be possible in an easy way to implement node sorting function in order to reduce cross links on the diagram as much as possible. Some other tools (e.g. Google Charts) can handle this automatically.

Another open sourced visualisation project Raw does it by the code snippet which I copy below:

d3.values(nested)
	.forEach(function (d){
    	var y = ( height() - d3.sum(d,function(n){ return n.dy+sankey.nodePadding();}) ) / 2 + sankey.nodePadding()/2;
    	d.sort(function (a,b){
    		if (sortBy() == "automatic") return b.y - a.y;
    		if (sortBy() == "size") return b.dy - a.dy;
    		if (sortBy() == "name") return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
    	})
    	d.forEach(function (node){
    		node.y = y;
    		y += node.dy +sankey.nodePadding();
    	})
    })

I'd like to do this and contribute. I tried, but I don't have a clue about javascript.

Error on align types

Hello,

I'm facing a weird bug when I try to align different links. It seems that for some reason including numbers in the type name causes some issues.
Example:
The following doesn't work properly

d1 = [
 {'source': 'start', 'target': 'E02000314_1', 'value': 32.0, 'type': 't41037'},
 {'source': 'E02000314_1', 'target': 'E09000025_2', 'value': 32.0, 'type': 't41037'},
 {'source': 'E09000025_2', 'target': 'end', 'value': 32.0, 'type': 't41037'},
    
 {'source': 'start', 'target': 'E02000313_1', 'value': 15.0, 'type': 't39174'},
 {'source': 'E02000313_1', 'target': 'E09000025_2', 'value': 15.0, 'type': 't39174'},
 {'source': 'E09000025_2', 'target': 'E02000321_3', 'value': 15.0, 'type': 't39174'},
 {'source': 'E02000321_3', 'target': 'end', 'value': 15.0, 'type': 't39174'}]

sankey(links=d1, align_link_types=True)

while this does:

d2 = [
 {'source': 'start', 'target': 'E02000314_1', 'value': 32.0, 'type': 'Α'},
 {'source': 'E02000314_1', 'target': 'E09000025_2', 'value': 32.0, 'type': 'Α'},
 {'source': 'E09000025_2', 'target': 'end', 'value': 32.0, 'type': 'Α'},
    
 {'source': 'start', 'target': 'E02000313_1', 'value': 15.0, 'type': 'Β'},
 {'source': 'E02000313_1', 'target': 'E09000025_2', 'value': 15.0, 'type': 'Β'},
 {'source': 'E09000025_2', 'target': 'E02000321_3', 'value': 15.0, 'type': 'Β'},
 {'source': 'E02000321_3', 'target': 'end', 'value': 15.0, 'type': 'Β'}]

sankey(links=d2, align_link_types=True)

I'm happy to try and find a solution but I'd need some initial guidance as to where I should look for. I have a feeling this is an issue of js rather than python right?

Cheers

Example don't working

Hello,

I tried to run the sript "Simple example" and I get the TypeError:

TypeError                                 Traceback (most recent call last)
<ipython-input-10-dda820b7c5a3> in <module>()
      1 
      2 
----> 3 w = SankeyWidget(links=links, margins=dict(top=0, bottom=0, left=50, right=100))

TypeError: wrap() got an unexpected keyword argument 'links'

I have anaconda with Python 3.4, it's doesn't work in Spyder and in the qtconsole either.

Is this error known?

Thanks for help and best regards.

Does not display in Google Colab notebooks

It took a little hacking around to get it to install and enable the extension, and I'm still not sure if I got that right, but it seems to work. That is until you try to display the widget. It's blank. Furthermore, if you access the .png property, it is empty.

Check out my notebook

render image from ipython (not jupyter notebook)

Hi,

I would like to use ipysankeywidget from an IPython terminal (from spyder actually) to generate Sankey diagram.
If I try the simple example, I can do everything without any error but nothing is displayed.

Is it possible to output the result in a html or svg file from an IPython terminal? I didn't find anything in the documentation.

Thanks for this great project!

The 'kernel' trait of a Comm instance must be a Kernel, but a value of class 'NoneType' (i.e. None) was specified.

In [1]: from ipysankeywidget import SankeyWidget
...:

In [2]: links = [
...: {'source': 'start', 'target': 'A', 'value': 2},
...: {'source': 'A', 'target': 'B', 'value': 2},
...: {'source': 'B', 'target': 'start', 'value': 0.2},
...: {'source': 'C', 'target': 'A', 'value': 2},
...: {'source': 'A', 'target': 'C', 'value': 2},
...: ]
...:

In [3]: nbsankeyExample = SankeyWidget(value={'links': links}, width=400, height=200,
...: margins=dict(top=0, bottom=0))
...:

KeyError Traceback (most recent call last)
C:\Users\username\Anaconda3\lib\site-packages\traitlets\traitlets.py in get(self, obj, cls)
525 try:
--> 526 value = obj._trait_values[self.name]
527 except KeyError:

KeyError: 'layout'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)
C:\Users\username\Anaconda3\lib\site-packages\traitlets\traitlets.py in get(self, obj, cls)
525 try:
--> 526 value = obj._trait_values[self.name]
527 except KeyError:

KeyError: 'kernel'

During handling of the above exception, another exception occurred:

TraitError Traceback (most recent call last)
in ()
1 nbsankeyExample = SankeyWidget(value={'links': links}, width=400, height=200,
----> 2 margins=dict(top=0, bottom=0))

C:\Users\username\Anaconda3\lib\site-packages\ipysankeywidget\sankey_widget.py in init(self, **kwargs)
28 def init(self, **kwargs):
29 """Constructor"""
---> 30 super(SankeyWidget, self).init(**kwargs)
31 self._selected_handlers = widgets.CallbackDispatcher()
32 self._auto_png_filename = None

C:\Users\username\Anaconda3\lib\site-packages\ipywidgets\widgets\domwidget.py in init(self, *pargs, **kwargs)
88
89 def init(self, *pargs, **kwargs):
---> 90 super(DOMWidget, self).init(*pargs, **kwargs)
91
92 # Deprecation added in 5.0. TODO: Remove me and corresponging traits.

C:\Users\username\Anaconda3\lib\site-packages\ipywidgets\widgets\widget.py in init(self, **kwargs)
179 """Public constructor"""
180 self._model_id = kwargs.pop('model_id', None)
--> 181 super(Widget, self).init(**kwargs)
182
183 Widget._call_widget_constructed(self)

C:\Users\username\Anaconda3\lib\site-packages\traitlets\config\configurable.py in init(self, **kwargs)
91 # explicitly assigned values.
92 for key, value in kwargs.items():
---> 93 setattr(self, key, value)
94
95 #-------------------------------------------------------------------------

C:\Users\username\Anaconda3\lib\site-packages\ipywidgets\widgets\domwidget.py in width(self, value)
32 @width.setter
33 def width(self, value): # Removed in ipywidgets 6.0
---> 34 self.layout.width = value
35
36 @Property

C:\Users\username\Anaconda3\lib\site-packages\traitlets\traitlets.py in get(self, obj, cls)
552 return self
553 else:
--> 554 return self.get(obj, cls)
555
556 def set(self, obj, value):

C:\Users\username\Anaconda3\lib\site-packages\traitlets\traitlets.py in get(self, obj, cls)
531 raise TraitError("No default value found for %s trait of %r"
532 % (self.name, obj))
--> 533 value = self._validate(obj, dynamic_default())
534 obj._trait_values[self.name] = value
535 return value

C:\Users\username\Anaconda3\lib\site-packages\ipywidgets\widgets\domwidget.py in _layout_default(self)
21 layout = Instance(Layout, allow_none=True).tag(sync=True, **widget_serialization)
22 def _layout_default(self):
---> 23 return Layout()
24
25 # width, height, padding, margin border properties rebinding to the layout attribute.

C:\Users\username\Anaconda3\lib\site-packages\ipywidgets\widgets\widget.py in init(self, **kwargs)
182
183 Widget._call_widget_constructed(self)
--> 184 self.open()
185
186 def del(self):

C:\Users\username\Anaconda3\lib\site-packages\ipywidgets\widgets\widget.py in open(self)
201 args['comm_id'] = self._model_id
202
--> 203 self.comm = Comm(**args)
204 if buffers:
205 # FIXME: workaround ipykernel missing binary message support in open-on-init

C:\Users\username\Anaconda3\lib\site-packages\ipykernel\comm\comm.py in init(self, target_name, data, metadata, buffers, **kwargs)
54 if self.primary:
55 # I am primary, open my peer.
---> 56 self.open(data=data, metadata=metadata, buffers=buffers)
57 else:
58 self._closed = False

C:\Users\username\Anaconda3\lib\site-packages\ipykernel\comm\comm.py in open(self, data, metadata, buffers)
81 if data is None:
82 data = self._open_data
---> 83 comm_manager = getattr(self.kernel, 'comm_manager', None)
84 if comm_manager is None:
85 raise RuntimeError("Comms cannot be opened without a kernel "

C:\Users\username\Anaconda3\lib\site-packages\traitlets\traitlets.py in get(self, obj, cls)
552 return self
553 else:
--> 554 return self.get(obj, cls)
555
556 def set(self, obj, value):

C:\Users\username\Anaconda3\lib\site-packages\traitlets\traitlets.py in get(self, obj, cls)
531 raise TraitError("No default value found for %s trait of %r"
532 % (self.name, obj))
--> 533 value = self._validate(obj, dynamic_default())
534 obj._trait_values[self.name] = value
535 return value

C:\Users\username\Anaconda3\lib\site-packages\traitlets\traitlets.py in _validate(self, obj, value)
587 return value
588 if hasattr(self, 'validate'):
--> 589 value = self.validate(obj, value)
590 if obj._cross_validation_lock is False:
591 value = self._cross_validate(obj, value)

C:\Users\username\Anaconda3\lib\site-packages\traitlets\traitlets.py in validate(self, obj, value)
1679 return value
1680 else:
-> 1681 self.error(obj, value)
1682
1683 def info(self):

C:\Users\username\Anaconda3\lib\site-packages\traitlets\traitlets.py in error(self, obj, value)
1526 % (self.name, self.info(), msg)
1527
-> 1528 raise TraitError(e)
1529
1530

TraitError: The 'kernel' trait of a Comm instance must be a Kernel, but a value of class 'NoneType' (i.e. None) was specified.

Google Colab

Just wondering if anybody has managed to get this widget to run in Google Colab? I don't get any error but the chart does not display
image

image

Could not create model

Could not create model:
Model name SankeyModel
Model module jupyter-sankey-widget
Model module version *
Script error for "jupyter-sankey-widget" http://requirejs.org/docs/errors.html#scripterror

Windows 10.
pip list:
alabaster (0.7.7)
anaconda-client (1.4.0)
anaconda-navigator (1.1.0)
argcomplete (1.0.0)
astropy (1.1.2)
Babel (2.2.0)
beautifulsoup4 (4.4.1)
bitarray (0.8.1)
blaze (0.9.1)
bokeh (0.11.1)
boto (2.39.0)
Bottlechest (0.7.1)
Bottleneck (1.0.0)
cffi (1.5.2)
chardet (2.3.0)
chest (0.2.3)
cloudpickle (0.1.1)
clyent (1.2.1)
colorama (0.3.7)
comtypes (1.1.2)
conda (4.3.16)
conda-build (1.20.0)
conda-manager (0.3.1)
configobj (5.0.6)
cryptography (1.4)
cycler (0.10.0)
Cython (0.23.4)
cytoolz (0.7.5)
dask (0.8.1)
datashape (0.5.1)
decorator (4.0.9)
dill (0.2.4)
docutils (0.12)
dynd (c328ab7)
et-xmlfile (1.0.1)
fastcache (1.0.2)
Flask (0.10.1)
Flask-Cors (2.1.2)
gevent (1.1.0)
greenlet (0.4.9)
h5py (2.5.0)
HeapDict (1.0.0)
idna (2.0)
ipykernel (4.6.1)
ipysankeywidget (0.1.6)
ipython (4.1.2)
ipython-d3-sankey (0.1.1)
ipython-genutils (0.1.0)
ipywidgets (6.0.0)
itsdangerous (0.24)
jdcal (1.2)
jedi (0.9.0)
Jinja2 (2.8)
jsonschema (2.4.0)
jupyter (1.0.0)
jupyter-client (4.2.2)
jupyter-console (4.1.1)
jupyter-core (4.1.0)
jupyter-pip (0.3)
llvmlite (0.9.0)
locket (0.2.0)
lxml (3.6.0)
MarkupSafe (0.23)
matplotlib (1.5.1)
menuinst (1.3.2)
mistune (0.7.2)
mpmath (0.19)
multipledispatch (0.4.8)
nbconvert (4.1.0)
nbformat (4.3.0)
networkx (1.11)
nltk (3.2)
nose (1.3.7)
notebook (5.0.0)
numba (0.24.0)
numexpr (2.5)
numpy (1.10.4)
odo (0.4.2)
openpyxl (2.3.2)
Orange (3.2.dev0+dfc525c)
pandas (0.18.0)
partd (0.3.2)
path.py (0.0.0)
patsy (0.4.0)
pep8 (1.7.0)
pickleshare (0.5)
Pillow (3.1.1)
pip (9.0.1)
ply (3.8)
psutil (4.1.0)
py (1.4.31)
pyasn1 (0.1.9)
pycosat (0.6.1)
pycparser (2.14)
pycrypto (2.6.1)
pyflakes (1.1.0)
Pygments (2.1.1)
pyOpenSSL (16.2.0)
pyparsing (2.0.3)
pyqtgraph (0.9.10)
pyreadline (2.1)
pytest (2.8.5)
python-dateutil (2.5.1)
pytz (2016.2)
pywin32 (220)
PyYAML (3.11)
pyzmq (15.2.0)
QtAwesome (0.3.2)
qtconsole (4.2.0)
QtPy (1.0)
requests (2.12.4)
rope-py3k (0.9.4.post1)
scikit-image (0.12.3)
scikit-learn (0.17.1)
scipy (0.17.0)
seaborn (0.7.0)
setuptools (20.3)
simplegeneric (0.8.1)
singledispatch (3.4.0.3)
six (1.10.0)
snowballstemmer (1.2.1)
sockjs-tornado (1.0.1)
Sphinx (1.3.1)
sphinx-rtd-theme (0.1.9)
spyder (2.3.8)
SQLAlchemy (1.0.12)
statsmodels (0.6.1)
sympy (1.0)
tables (3.2.2)
toolz (0.7.4)
tornado (4.3)
tqdm (4.11.2)
traitlets (4.3.2)
unicodecsv (0.14.1)
update (0.4.4)
Werkzeug (0.11.4)
wheel (0.29.0)
widgetsnbextension (2.0.0)
xlrd (0.9.4)
XlsxWriter (0.8.4)
xlwings (0.7.0)
xlwt (1.0.0)

exporting SVG

I tried exporting a diagram to SVG and png as in the example. The png works fine. If I right-click the pngimage in my notebook, I can save it. If I try the same for the svg image, I can only save the whole notebook, not the svg image. When I try the same from the example html notebook on your github, I can save the SVG. I tried to find a way to programmatically save the svg, but failed to find one.

Setting the colour of specific processes

I can’t seem to find a way to color differentially the nodes and make them wider than the default setting. I tried to set this up using a dictionary as follows: {'id': 'Anc', 'title': 'Anc', 'style': 'process', 'color': 'blue', 'stroke-width': '20px’}. But unfortunately nothing seems to work. Is there a way to go around this without altering the CSS style?

Cannot create multiple sankey diagrams

Hi,

I do have a list of different datasets which I want to visualise in Sankey Diagrams.

I can visualise them one after another, manually but cannot replicate the same in a for loop. An example code is provided below:

from ipysankeywidget import SankeyWidget

links = [
    {'source': 'start', 'target': 'A', 'value': 2},
    {'source': 'A', 'target': 'B', 'value': 2},
    {'source': 'C', 'target': 'A', 'value': 2},
    {'source': 'A', 'target': 'C', 'value': 2},
]

w = SankeyWidget(links=links, margins=dict(top=0, bottom=0, left=50, right=100))

for i in [w,w]:
    i

For me, it is more important to save Sankey diagrams to a folder rather than printing them in jupyter notebook but they cannot be saved before shown in Jupyter as well. Could you show me a work around to achieve this goal?

Display silently fails when there are duplicates in links

Hi and thanks for the great work!

The following code silently fails (i.e. displays nothing without any error message).

faultylinks = [{'source': 'farm1', 'target': 'client1', 'value': 5}, {'source': 'farm1', 'target': 'client1', 'value': 10}]
SankeyWidget(links=faultylinks)

Obviously, having duplicates in the links should not happen, but I think an error message should be displayed when this happens rather than failing silently.

Not sure if this is due to ipysankeywidget directly, but a safety check could be performed anyway during the init.

I see two distinct solutions:

  1. Automatically sum values for entries that have the same source and target. This should be what a large majority of users wanted to do. You can log a warning when this happens.
  2. Raise an exception.

Solution 2 is easier to implement (there is no logging implemented for now) and probably safer too. Solution 1 focuses on ease of use in case that's what the widget aims for.

I can implement any solution or leave it to you.

The sankey is not shown in Jupyter notebook

Hi!
Since a while I am trying to execute it in Jupyter notebook. Seams that everything works but ... is not displaying a chart. Only white space. I tried to save it as a png but is failing (any file is installed).
I tested it:

  1. Windows 10, Chrome, Jupyter version 4.2.0, conda 4.3.21, pip 9.x, ipysankeywidget (installed), and enable.
  2. MacOS, Chrome, and Safari, Jupyter 5x, ipysankeywidget (installed), and enable
    In both cases:
    I used ipywidgets==5.2.2, and ipykernel==4.5.0 and ipysankeywidget==0.2.1

What could be a reason that it´s executed but neither displayed nor known?
Thanks!

install problem on linux jupyterlab

I am not able to install the widget on a jupyter-lap platform on Ubuntu 18.04.

When running this code
jupyter labextension install jupyter-sankey-widget

I get the following error:

error [email protected]: The platform "linux" is incompatible with this module.

Link Titles

How do I set the link titles? I want to show the link values, preferably on the links, but I can't find a way to do it. Currently I am instead setting the node titles as the values of the links, but it does not look good. In general, how do I access the link appearance functions of d3-sankey-diagram diagram object?

Not plotting anymore

Hello,

I have been using the package for couple of years and it does not work anymore. When I run my old scripts in Jupyter Notebook, I don't see anything. I have installed Jupyter lab and it does not work. I have update the package using the conda line, and updated Jupyter too. Still not working! The codes run fine, the SankeyWidget object is created without error. But I just cannot plot it. Thanks for the help. I have python 3.6.12, ipysankeywidget 0.4.0, ipython 7.12.0, jupyter-notebook 6.2.0.

Hiding Labels

Hi Rick,

I was wondering if there is a way to code the sankey so that some of the labels attached to nodes are hidden? Couldn't find it in the tutorials.

Cheers

Install using conda

If anyone has experience of building conda packages, or wants to give it a try, it would be great if ipysankeywidget could be installed using conda. I think this just involves putting together a conda recipe.

See also ricklupton/floweaver#43

Any questions let me know by replying below or asking in the chat!

calling SankeyWidget keeps kernel busy

Hi,

I am new to jupyter notebooks, so this problem might be something I'm doing wrong. I've installed the widget and can see it listed and enabled in 'Environment' parameters page using anaconda. I've opened the shared notebook and can import the libraries etc. When I get to calling SankeyWidget (third cell), the kernel is kept busy (I assume this is what is happening seeing I get an asterisk?). Either way, I can't get the diagram to show.

Could you advise?

Thanks
D

Check nbextension json config file

Installing ipysankeywidget seems to install an extension file in notebook.d which refers to "ipysankeywidget/extension", which I think is wrong -- it should be jupyter-sankey-widget/extension.

The latter is created in notebook.json when running jupyter nbextension enable --py --sys-prefix ipysankeywidget

Bulk change the values with a slider doesn't work

Hi,

I'm trying to use sankey diagrams alongside some standard matplotlib plots in an interactive jupyter session by using some widgets. I have a function that calculates the necessary values for each link from some input variables, one of which is an int slider. However when I move the slider around the sankey diagram is redrawn for each slider value rather than being dynamically updated. Could you please advise is there a way to fix this or am I doing something wrong.

Many Thanks,

[Feature Request] Can I use this to create behavior flow chart?

Hi @ricklupton :

Thanks for your contribution!
Related to what I'm working on(users behaviors flow visualization), the data-set like:

	step1	step2	step3
user1	A	B	C
user2	B	C	A
user3	C	B	bounce out
user4	C	A	C

Can I use the ipysankeywidget to create a flow chart like the attached picture?
behavior_flow_report_from_google_analytics

Wish to hear from you soon!

Changing color scheme

Is there anyway to change the color scheme? I can see you're using d3.scale.category20() in the javascript

Can I replace this palette with, say, an seaborn palette? Thanks!

Node & Link value labels.

Hello, is there any way to show the flow values as well as the totals flowing into each node?

image

I've uploaded my current sankey chart, and added in red the text labels I am looking for.

Thanks

Node customization

For my application purpose it is required that the node values are displayed (tilted) inside the nodes.
Ideally, I would like to be able to customize the diagram more or less as in the tool below, but with python.
http://sankey.csaladen.es/
Screenshot from tool;
image

I don't see the possibility to do this as of yet, could this be possible in the future?

Disable printing of nodeTitle

Hey, thanks for your work :)

Since I have pretty long node titles/names/ids I would like to disable the display of those and purely rely on the tooltips to identify nodes.

Is there an easy way to do that?

Thanks a lot!

Error in reproducing simple example

I tried reproducing your simple example but received the following error:

TypeError Traceback (most recent call last)
<ipython-input-24-b42a1aad6fb3> in <module>()
----> 1 w = SankeyWidget(links=links, margins=dict(top=0, bottom=0, left=50, right=100))
TypeError: wrap() got an unexpected keyword argument 'links'

JupyterLab error displaying widget (Chrome, MacOS)

Hi,

I followed conda installation instructions for ipysankeywidget and then tried the simple example code but found that a widget did not display using JupyterLab (2.0.1) but did display using Jupyter Notebook.

This is on same computer (MacOS 10.15.4) and same browser (Chrome).

Anaconda Navigator is showing ipsankeywidget 0.3.0 installed and jiupyter-sankey-widget appears in the JupyterLab extension manager.

Chrome developer console shows the following error when executing the layout = Layout(width="500", height="200") line of code.

Executing the sankey command in simple example shows the sankey object but no diagram.
localhost-1585306478218.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.