Skip to content

Commit

Permalink
fix slashes in filepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
erdogant committed Apr 2, 2024
1 parent e2508ee commit 6b0806d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 33 deletions.
30 changes: 27 additions & 3 deletions d3blocks/d3blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,14 +1093,14 @@ def sankey(self,
>>> df = d3.import_example('energy')
>>> #
>>> # Custom color the nodes
>>> html = d3.sankey(df.copy(), filepath=r'c:\temp\sankey.html', color={'Nuclear': '#FF0000', 'Wind':'#000000', 'Electricity grid':'#FF0000'})
>>> html = d3.sankey(df.copy(), filepath=r'c://temp//sankey.html', color={'Nuclear': '#FF0000', 'Wind':'#000000', 'Electricity grid':'#FF0000'})
>>> #
>>> # Alternatively:
>>> d3 = D3Blocks(chart='Sankey', frame=True)
>>> df = d3.import_example(data='energy')
>>> d3.set_node_properties(df, color={'Nuclear': '#FF0000', 'Wind':'#FF0000', 'Electricity grid':'#7FFFD4', 'Bio-conversion':'#000000', 'Industry': '#000000'})
>>> d3.set_edge_properties(df, color='target', opacity='target')
>>> d3.show(filepath=r'c:\temp\sankey.html')
>>> d3.show(filepath=r'c://temp//sankey.html')
>>> #
References
Expand Down Expand Up @@ -2242,7 +2242,7 @@ def tree(self,
>>> d3.set_edge_properties(df)
>>>
>>> # Show chart
>>> d3.show(hierarchy=[1, 2, 3, 4, 5, 6, 7, 8], filepath=r'c:\temp\tree.html')
>>> d3.show(hierarchy=[1, 2, 3, 4, 5, 6, 7, 8], filepath=r'c://temp//tree.html')
Examples
--------
Expand Down Expand Up @@ -2399,6 +2399,30 @@ def treemap(self,
>>> # Show the chart
>>> d3.show()
Examples
--------
>>> # Add tooltip
>>> #
>>> # Intialize Treemap
>>> from d3blocks import D3Blocks
>>> d3 = D3Blocks(chart='treemap', frame=False)
>>> #
>>> # Import example
>>> df = d3.import_example('energy')
>>> #
>>> # Set node properties
>>> d3.set_node_properties(df)
>>> #
>>> # Set tooltip for specific nodes
>>> d3.node_properties['Bio-conversion']['tooltip'] = 'Title: Bio conversion Operations'
>>> d3.node_properties.get('Losses')['tooltip'] = 'losses tooltip'
>>> #
>>> # Set edge properties
>>> d3.set_edge_properties(df)
>>> #
>>> # Show chart
>>> d3.show(filepath=r'c://temp//treemap.html')
References
----------
* Mike Bostock; http://bl.ocks.org/mbostock/4063582
Expand Down
51 changes: 23 additions & 28 deletions d3blocks/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@
import pandas as pd
import numpy as np

# %% issue 45
# https://github.com/d3blocks/d3blocks/issues/45
# Treemap
from d3blocks import D3Blocks
# Initialize
d3 = D3Blocks(chart='treemap', frame=False)
# Import example
df = d3.import_example('energy')

# Set node properties
d3.set_node_properties(df)

# Set specific properties
d3.node_properties['Bio-conversion']['tooltip'] = 'Title: Bio conversion Operations'
d3.node_properties.get('Losses')['tooltip'] = 'losses tooltip'

# Set edge properties
d3.set_edge_properties(df)

# Show chart
d3.show(filepath=r'c:\temp\treemap.html')


# %%
# Load d3blocks
from d3blocks import D3Blocks
Expand Down Expand Up @@ -96,34 +119,6 @@



# %% issue 45
# https://github.com/d3blocks/d3blocks/issues/45
# from d3blocks import D3Blocks
# d3 = D3Blocks()
# Treemap
# df = d3.import_example(data='energy')
# html = d3.treemap(df, filepath=r'c:\temp\treemap1.html')


from d3blocks import D3Blocks
# Initialize
d3 = D3Blocks(chart='treemap', frame=False)
# Import example
df = d3.import_example('energy')

# Set node properties
d3.set_node_properties(df)

# Set specific properties
d3.node_properties['Bio-conversion']['tooltip'] = 'Title: P Operations<br><img src="https://source.unsplash.com/collection/385548/150x100">'
# Set properties for Losses
d3.node_properties.get('Losses')['tooltip'] = ''

# Set edge properties
d3.set_edge_properties(df)

# Show chart
d3.show(filepath=r'c:\temp\treemap.html')

# %% issue 45
# https://github.com/d3blocks/d3blocks/issues/45
Expand Down
5 changes: 4 additions & 1 deletion d3blocks/tests/test_d3blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,15 @@ def test_treemap(self):
# Load d3blocks
from d3blocks import D3Blocks
# Initialize
d3 = D3Blocks(chart='Treemap', frame=True)
d3 = D3Blocks(chart='Treemap', frame=False)
# Import example
df = d3.import_example('energy')
# Node properties
d3.set_node_properties(df)
d3.set_edge_properties(df)
# Set specific properties
d3.node_properties['Bio-conversion']['tooltip'] = 'Title: Bio conversion Operations'
d3.node_properties.get('Losses')['tooltip'] = 'losses tooltip'
# Show the chart
d3.show()

Expand Down
2 changes: 1 addition & 1 deletion d3blocks/treemap/Treemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def set_node_properties(df, **kwargs):
dict_labels = {}
for i, label in enumerate(uilabels):
# dict_labels[label] = {'id': i, 'label': label, 'tooltip': ''}
dict_labels[label] = {'tooltip': ''}
dict_labels[label] = {'label': label, 'tooltip': ''}
# Return
return dict_labels

Expand Down

0 comments on commit 6b0806d

Please sign in to comment.