MCPcopy Create free account
hub / github.com/dask/dask / svg_3d

Function svg_3d

dask/array/svg.py:88–143  ·  view source on GitHub ↗
(chunks, size=200, sizes=None, offset=(0, 0))

Source from the content-addressed store, hash-verified

86
87
88def svg_3d(chunks, size=200, sizes=None, offset=(0, 0)):
89 shape = tuple(map(sum, chunks))
90 sizes = sizes or draw_sizes(shape, size=size)
91 x, y, z = grid_points(chunks, sizes)
92 ox, oy = offset
93
94 xy, (mnx, mxx, mny, mxy) = svg_grid(
95 x / 1.7, y, offset=(ox + 10, oy + 0), skew=(1, 0), size=size
96 )
97
98 zx, (_, _, _, max_x) = svg_grid(
99 z, x / 1.7, offset=(ox + 10, oy + 0), skew=(0, 1), size=size
100 )
101 zy, (min_z, max_z, min_y, max_y) = svg_grid(
102 z, y, offset=(ox + max_x + 10, oy + max_x), skew=(0, 0), size=size
103 )
104
105 header = '<svg width="{}" height="{}" style="stroke:rgb(0,0,0);stroke-width:1" >\n'.format(
106 int(max_z + 50), int(max_y + 50)
107 )
108 footer = "\n</svg>"
109
110 if shape[1] >= 100:
111 rotate = -90
112 else:
113 rotate = 0
114
115 text = [
116 "",
117 " <!-- Text -->",
118 ' <text x="{}" y="{}" {} >{}</text>'.format(
119 (min_z + max_z) / 2,
120 max_y + 20,
121 text_style,
122 shape[2],
123 ),
124 ' <text x="{}" y="{}" {} transform="rotate({},{},{})">{}</text>'.format(
125 max_z + 20,
126 (min_y + max_y) / 2,
127 text_style,
128 rotate,
129 max_z + 20,
130 (min_y + max_y) / 2,
131 shape[1],
132 ),
133 ' <text x="{}" y="{}" {} transform="rotate(45,{},{})">{}</text>'.format(
134 (mnx + mxx) / 2 - 10,
135 mxy - (mxx - mnx) / 2 + 20,
136 text_style,
137 (mnx + mxx) / 2 - 10,
138 mxy - (mxx - mnx) / 2 + 20,
139 shape[0],
140 ),
141 ]
142
143 return header + "\n".join(xy + zx + zy + text) + footer
144
145

Callers 1

svgFunction · 0.85

Calls 4

draw_sizesFunction · 0.85
grid_pointsFunction · 0.85
svg_gridFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected