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

[feat] add click callback for textPane #868

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
20 changes: 10 additions & 10 deletions example/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,17 @@ def run_demo(viz, env, args):
np.random.seed(int(FLAGS.seed))

if FLAGS.run == "all":
try:
# try:
run_demo(viz, FLAGS.env if FLAGS.env else None, FLAGS.args)
except Exception as e:
print(
"The visdom experienced an exception while running: {}\n"
"The demo displays up-to-date functionality with the GitHub "
"version, which may not yet be pushed to pip. Please upgrade "
"using `pip install -e .` or `easy_install .`\n"
"If this does not resolve the problem, please open an issue on "
"our GitHub.".format(repr(e))
)
# except Exception as e:
# print(
# "The visdom experienced an exception while running: {}\n"
# "The demo displays up-to-date functionality with the GitHub "
# "version, which may not yet be pushed to pip. Please upgrade "
# "using `pip install -e .` or `easy_install .`\n"
# "If this does not resolve the problem, please open an issue on "
# "our GitHub.".format(repr(e))
# )
else:
locals()[FLAGS.run](viz, FLAGS.run + FLAGS.env_suffix if not FLAGS.env else FLAGS.env, FLAGS.args)

Expand Down
6 changes: 6 additions & 0 deletions js/TextPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class TextPane extends React.Component {
key_code: e.keyCode,
});
break;
case 'click':
this.props.appApi.sendPaneMessage({
event_type: 'Click',
});
break;

}
};

Expand Down
21 changes: 21 additions & 0 deletions py/visdom/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
clean:
rm -rf ./test_data/*

serve_test:
python3 -mpdb -cc server.py -env_path test_data -eager_data_loading -logging_level 5

serve_test_jpwa:
python3 -mpdb -cc server.py -env_path test_data -eager_data_loading -logging_level 5 -cache_type JPWA

serve_test_jpe:
python3 -mpdb -cc server.py -env_path test_data -eager_data_loading -logging_level 5 -cache_type JPE

serve_test_jpw:
python3 -mpdb -cc server.py -env_path test_data -eager_data_loading -logging_level 5 -cache_type JPW


test_save.py:
python3 test_save.py
test_cache.py:
python3 test_cache.py
.PHONY: test_cache.py test_save.py
21 changes: 11 additions & 10 deletions py/visdom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# __version__ = 'test'

import os.path
import requests
Expand Down Expand Up @@ -405,7 +406,7 @@ def __init__(
'base_url should not end with / as it is appended automatically'

self.ipv6 = ipv6
self.env = env
self.env = env
self.env_list={f'{env}'} # default env
self.send = send
self.event_handlers = {} # Haven't registered any events
Expand Down Expand Up @@ -801,7 +802,7 @@ def get_env_list(self):
This function returns a list of all of the env names that are currently
in the server.
"""
if self.offline:
if self.offline:
return list(self.env_list)
else:
return json.loads(self._send({}, endpoint='env_state', quiet=True))
Expand Down Expand Up @@ -1694,7 +1695,7 @@ def line(self, Y, X=None, win=None, env=None, opts=None, update=None,
assert X.ndim == 1 or X.ndim == 2, 'X should have 1 or 2 dim'
else:
X = np.linspace(0, 1, Y.shape[0])

if Y.ndim == 2 and X.ndim == 1:
X = np.tile(X, (Y.shape[1], 1)).transpose()

Expand Down Expand Up @@ -2180,7 +2181,7 @@ def sunburst(self, labels, parents, values=None, win=None, env=None, opts=None):
line_width=opts.get("marker_width")

assert len(parents.tolist())==len(labels.tolist()), "length of parents and labels should be equal"

data_dict=[{
'labels': labels.tolist(),
"parents":parents.tolist(),
Expand All @@ -2196,7 +2197,7 @@ def sunburst(self, labels, parents, values=None, win=None, env=None, opts=None):

data_dict[0]['values']=values.tolist()

data=data_dict
data=data_dict
return self._send({
'data': data,
'win': win,
Expand Down Expand Up @@ -2397,7 +2398,7 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No
"""
This function draws interactive network graphs. It takes list of edges as one of the arguments.
The user can also provide custom edge Labels and node Labels in edgeLabels and nodeLabels respectively.
Along with that we have different parameters in opts for making it more user friendly.
Along with that we have different parameters in opts for making it more user friendly.

Args:
edges : list, required
Expand All @@ -2419,7 +2420,7 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No
except:
raise RuntimeError(
"networkx must be installed to plot Graph figures")

G = nx.Graph()
G.add_edges_from(edges)
node_data = list(G.nodes())
Expand All @@ -2434,7 +2435,7 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No
if nodeLabels is not None:
assert len(nodeLabels) == len(node_data),\
"length of nodeLabels does not match with the length of nodes {len1} != {len2}".format(len1 = len(nodeLabels), len2 = len(node_data))

for i in range(len(node_data)):
if i != node_data[i]:
raise RuntimeError("The nodes should be numbered from 0 to n-1 for n nodes! {} node is missing!".format(i))
Expand All @@ -2455,15 +2456,15 @@ def graph(self, edges, edgeLabels = None, nodeLabels = None, opts=dict(), env=No
edge["target"] = int(link_data[i][1])
edge["label"] = str(edgeLabels[i]) if edgeLabels is not None else str(link_data[i][0])+"-"+str(link_data[i][1])
edges.append(edge)

for i in range(len(node_data)):
node = {}
node["name"] = int(node_data[i])
node["label"] = str(nodeLabels[i]) if nodeLabels is not None else str(node_data[i])
if opts['scheme'] == 'different':
node["club"] = int(i)
nodes.append(node)


data = [{
'content': {"nodes": nodes, "edges": edges},
Expand Down
Loading