MCPcopy Index your code
hub / github.com/clips/pattern / HTMLCanvasRenderer

Class HTMLCanvasRenderer

pattern/graph/__init__.py:1131–1454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1129HTML, CANVAS, STYLE, SCRIPT, DATA = "html", "canvas", "style", "script", "data"
1130
1131class HTMLCanvasRenderer(object):
1132
1133 def __init__(self, graph, **kwargs):
1134 self.graph = graph
1135 self._source = \
1136 "<!DOCTYPE html>\n" \
1137 "<html>\n" \
1138 "<head>\n" \
1139 "\t<title>%s</title>\n" \
1140 "\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" \
1141 "\t%s\n" \
1142 "\t<script type=\"text/javascript\" src=\"%scanvas.js\"></script>\n" \
1143 "\t<script type=\"text/javascript\" src=\"%sgraph.js\"></script>\n" \
1144 "</head>\n" \
1145 "<body>\n" \
1146 "\t<div id=\"%s\" style=\"width:%spx; height:%spx;\">\n" \
1147 "\t\t<script type=\"text/canvas\">\n" \
1148 "\t\t%s\n" \
1149 "\t\t</script>\n" \
1150 "\t</div>\n" \
1151 "</body>\n" \
1152 "</html>"
1153 # HTML
1154 self.title = "Graph" # <title>Graph</title>
1155 self.javascript = "js/" # Path to canvas.js + graph.js.
1156 self.stylesheet = INLINE # Either None, INLINE, DEFAULT (style.css) or a custom path.
1157 self.id = "graph" # <div id="graph">
1158 self.ctx = "canvas.element"
1159 self.width = 700 # Canvas width in pixels.
1160 self.height = 500 # Canvas height in pixels.
1161 # JS Graph
1162 self.frames = 500 # Number of frames of animation.
1163 self.fps = 30 # Frames per second.
1164 self.ipf = 2 # Iterations per frame.
1165 self.weighted = False # Indicate betweenness centrality as a shadow?
1166 self.directed = False # Indicate edge direction with an arrow?
1167 self.prune = None # None or int, calls Graph.prune() in Javascript.
1168 self.pack = True # Shortens leaf edges, adds eigenvector weight to node radius.
1169 # JS GraphLayout
1170 self.distance = 10 # Node spacing.
1171 self.k = 4.0 # Force constant.
1172 self.force = 0.01 # Force dampener.
1173 self.repulsion = 50 # Repulsive force radius.
1174 # Data
1175 self.weight = [WEIGHT, CENTRALITY] # Calculate these in Python, or True (in Javascript).
1176 self.href = {} # Dictionary of Node.id => URL.
1177 self.css = {} # Dictionary of Node.id => CSS classname.
1178 # Default options.
1179 # If a Node or Edge has one of these settings,
1180 # it is not passed to Javascript to save bandwidth.
1181 self.default = {
1182 "radius": 5,
1183 "fixed": False,
1184 "fill": None,
1185 "stroke": (0,0,0,1),
1186 "strokewidth": 1,
1187 "text": (0,0,0,1),
1188 "fontsize": 11,

Callers 2

renderFunction · 0.85
exportFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…