@windborne/grapher 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/.eslintrc.js +85 -0
  2. package/.idea/codeStyles/Project.xml +19 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/grapher.iml +12 -0
  5. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  6. package/.idea/misc.xml +6 -0
  7. package/.idea/modules.xml +8 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/0.bundle.js +2 -0
  10. package/0.bundle.js.map +1 -0
  11. package/1767282193a714f63082.module.wasm +0 -0
  12. package/537.bundle.js +2 -0
  13. package/537.bundle.js.map +1 -0
  14. package/831.bundle.js +2 -0
  15. package/831.bundle.js.map +1 -0
  16. package/bundle.js +2 -0
  17. package/bundle.js.map +1 -0
  18. package/package.json +75 -0
  19. package/readme.md +129 -0
  20. package/src/components/annotations.js +62 -0
  21. package/src/components/context_menu.js +73 -0
  22. package/src/components/draggable_points.js +114 -0
  23. package/src/components/graph_body.js +292 -0
  24. package/src/components/graph_title.js +16 -0
  25. package/src/components/options.js +111 -0
  26. package/src/components/percentile_button.js +72 -0
  27. package/src/components/range_graph.js +352 -0
  28. package/src/components/range_selection.js +175 -0
  29. package/src/components/range_selection_button.js +26 -0
  30. package/src/components/range_selection_button_base.js +51 -0
  31. package/src/components/series_key.js +235 -0
  32. package/src/components/series_key_axis_container.js +70 -0
  33. package/src/components/series_key_item.js +52 -0
  34. package/src/components/sidebar.js +76 -0
  35. package/src/components/tooltip.js +244 -0
  36. package/src/components/vertical_lines.js +70 -0
  37. package/src/components/x_axis.js +124 -0
  38. package/src/components/y_axis.js +239 -0
  39. package/src/eventable.js +65 -0
  40. package/src/grapher.js +367 -0
  41. package/src/grapher.scss +914 -0
  42. package/src/helpers/axis_sizes.js +2 -0
  43. package/src/helpers/binary_search.js +67 -0
  44. package/src/helpers/color_to_vector.js +35 -0
  45. package/src/helpers/colors.js +27 -0
  46. package/src/helpers/custom_prop_types.js +159 -0
  47. package/src/helpers/flatten_simple_data.js +81 -0
  48. package/src/helpers/format.js +233 -0
  49. package/src/helpers/generator_params_equal.js +10 -0
  50. package/src/helpers/name_for_series.js +16 -0
  51. package/src/helpers/place_grid.js +257 -0
  52. package/src/helpers/pyodide_ready.js +13 -0
  53. package/src/multigrapher.js +105 -0
  54. package/src/renderer/background.frag +7 -0
  55. package/src/renderer/background.vert +7 -0
  56. package/src/renderer/background_program.js +48 -0
  57. package/src/renderer/circle.frag +26 -0
  58. package/src/renderer/circle.vert +12 -0
  59. package/src/renderer/create_gl_program.js +36 -0
  60. package/src/renderer/draw_area.js +159 -0
  61. package/src/renderer/draw_background.js +15 -0
  62. package/src/renderer/draw_bars.js +80 -0
  63. package/src/renderer/draw_line.js +69 -0
  64. package/src/renderer/draw_zero_line.js +24 -0
  65. package/src/renderer/extract_vertices.js +137 -0
  66. package/src/renderer/graph_body_renderer.js +293 -0
  67. package/src/renderer/line.frag +51 -0
  68. package/src/renderer/line.vert +32 -0
  69. package/src/renderer/line_program.js +125 -0
  70. package/src/renderer/paths_from.js +72 -0
  71. package/src/renderer/scale_bounds.js +28 -0
  72. package/src/renderer/size_canvas.js +59 -0
  73. package/src/rust/Cargo.lock +233 -0
  74. package/src/rust/Cargo.toml +35 -0
  75. package/src/rust/pkg/grapher_rs.d.ts +42 -0
  76. package/src/rust/pkg/grapher_rs.js +351 -0
  77. package/src/rust/pkg/grapher_rs_bg.d.ts +11 -0
  78. package/src/rust/pkg/grapher_rs_bg.wasm +0 -0
  79. package/src/rust/pkg/index.js +342 -0
  80. package/src/rust/pkg/index_bg.wasm +0 -0
  81. package/src/rust/pkg/package.json +14 -0
  82. package/src/rust/src/extract_vertices.rs +83 -0
  83. package/src/rust/src/get_point_number.rs +50 -0
  84. package/src/rust/src/lib.rs +15 -0
  85. package/src/rust/src/selected_space_to_render_space.rs +131 -0
  86. package/src/state/average_loop_times.js +15 -0
  87. package/src/state/bound_calculator_from_selection.js +36 -0
  88. package/src/state/bound_calculators.js +41 -0
  89. package/src/state/calculate_annotations_state.js +59 -0
  90. package/src/state/calculate_data_bounds.js +104 -0
  91. package/src/state/calculate_tooltip_state.js +241 -0
  92. package/src/state/data_types.js +13 -0
  93. package/src/state/expand_bounds.js +58 -0
  94. package/src/state/find_matching_axis.js +31 -0
  95. package/src/state/get_default_bounds_calculator.js +15 -0
  96. package/src/state/hooks.js +164 -0
  97. package/src/state/infer_type.js +74 -0
  98. package/src/state/merge_bounds.js +64 -0
  99. package/src/state/multigraph_state_controller.js +334 -0
  100. package/src/state/selection_from_global_bounds.js +25 -0
  101. package/src/state/space_conversions/condense_data_space.js +115 -0
  102. package/src/state/space_conversions/data_space_to_selected_space.js +328 -0
  103. package/src/state/space_conversions/selected_space_to_background_space.js +144 -0
  104. package/src/state/space_conversions/selected_space_to_render_space.js +161 -0
  105. package/src/state/space_conversions/simple_series_to_data_space.js +229 -0
  106. package/src/state/state_controller.js +1770 -0
  107. package/src/state/sync_pool.js +101 -0
  108. package/test/setup.js +15 -0
  109. package/test/space_conversions/data_space_to_selected_space.test.js +434 -0
  110. package/webpack.dev.config.js +109 -0
  111. package/webpack.prod.config.js +60 -0
  112. package/webpack.test.config.js +59 -0
@@ -0,0 +1,125 @@
1
+ import lineFrag from './line.frag';
2
+ import lineVert from './line.vert';
3
+ import circleFrag from './circle.frag';
4
+ import circleVert from './circle.vert';
5
+ import colorToVector from '../helpers/color_to_vector';
6
+ import extractVertices from './extract_vertices';
7
+ import createGLProgram from './create_gl_program';
8
+ import {DPI_INCREASE} from './size_canvas';
9
+
10
+ export default class LineProgram {
11
+
12
+ constructor(gl) {
13
+ this._gl = gl;
14
+
15
+ this._program = createGLProgram(gl, lineVert, lineFrag);
16
+ this._circleProgram = createGLProgram(gl, circleVert, circleFrag);
17
+
18
+ this._positionBuffer = gl.createBuffer();
19
+ this._prevPositionBuffer = gl.createBuffer();
20
+ this._vertexBuffer = gl.createBuffer();
21
+ this._indexBuffer = gl.createBuffer();
22
+ this._individualPointBuffer = gl.createBuffer();
23
+
24
+ if (!gl.getExtension('OES_element_index_uint')) {
25
+ console.error('Your browser does not support OES_element_index_uint'); // eslint-disable-line no-console
26
+ }
27
+ }
28
+
29
+ dispose() {
30
+
31
+ }
32
+
33
+ clear() {
34
+ const gl = this._gl;
35
+ const width = gl.drawingBufferWidth;
36
+ const height = gl.drawingBufferHeight;
37
+
38
+ gl.clearColor(0, 0, 0, 0);
39
+ gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT);
40
+ gl.viewport(0, 0, width, height);
41
+ }
42
+
43
+ /**
44
+ * Draws the data on the canvas
45
+ * Assumes the data is in render space
46
+ *
47
+ * @param {{nullMask: Uint8Array, maxYValues: Float64Array, minYValues: Float64Array, yValues: Float64Array}} dataInRenderSpace - the data to render
48
+ * @param {Object} parameters - set of options
49
+ * @param {String} parameters.color - color of the line to draw
50
+ * @param {Number} [parameters.width] - line width
51
+ * @param {Number} [parameters.shadowBlur] - level to blur shadow to
52
+ * @param {String} [parameters.shadowColor] - color of the shadow
53
+ * @param {String} [parameters.dashed] - whether or not to make the line dashed
54
+ * @param {Array<Number>} [parameters.dashPattern] - dash array for the canvas
55
+ * @param {Boolean} [parameters.highlighted] - whether the line is highlighted or not
56
+ * @param {Boolean} [parameters.showIndividualPoints] - draw circles at each point
57
+ * @param {Function} [parameters.getIndividualPoints] - points to draw circles at. Only called when needed.
58
+ * @private
59
+ */
60
+ draw(dataInRenderSpace, parameters) {
61
+ const gl = this._gl;
62
+ const width = gl.drawingBufferWidth;
63
+ const height = gl.drawingBufferHeight;
64
+ gl.useProgram(this._program);
65
+
66
+ // gl.disable(gl.DEPTH_TEST);
67
+
68
+ const thickness = DPI_INCREASE*((parameters.width || 1) + (parameters.highlighted ? 2 : 0));
69
+ const shadowBlur = parameters.shadowBlur === undefined ? 2 : parameters.shadowBlur;
70
+ const shadowColor = parameters.shadowColor || 'black';
71
+ const dashed = parameters.dashed || false;
72
+ const dashPattern = parameters.dashPattern || [5, 5];
73
+
74
+ const {positions, prevPositions, vertices, indices} = extractVertices(dataInRenderSpace, { dashed, dashPattern });
75
+
76
+ const positionIndex = gl.getAttribLocation(this._program, 'position');
77
+ const prevPositionIndex = gl.getAttribLocation(this._program, 'prevPosition');
78
+ const vertexIndex = gl.getAttribLocation(this._program, 'vertex');
79
+
80
+ gl.enableVertexAttribArray(positionIndex);
81
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._positionBuffer);
82
+ gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW);
83
+ gl.vertexAttribPointer(positionIndex, 2, gl.FLOAT, false, 0, 0);
84
+
85
+ gl.enableVertexAttribArray(prevPositionIndex);
86
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._prevPositionBuffer);
87
+ gl.bufferData(gl.ARRAY_BUFFER, prevPositions, gl.STATIC_DRAW);
88
+ gl.vertexAttribPointer(prevPositionIndex, 2, gl.FLOAT, false, 0, 0);
89
+
90
+ gl.enableVertexAttribArray(vertexIndex);
91
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer);
92
+ gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
93
+ gl.vertexAttribPointer(vertexIndex, 1, gl.FLOAT, false, 0, 0);
94
+
95
+ gl.uniform1f(gl.getUniformLocation(this._program, 'width'), width);
96
+ gl.uniform1f(gl.getUniformLocation(this._program, 'height'), height);
97
+ gl.uniform1f(gl.getUniformLocation(this._program, 'thickness'), Math.max(thickness, 1)+shadowBlur);
98
+ gl.uniform1f(gl.getUniformLocation(this._program, 'shadowBlur'), shadowBlur);
99
+ gl.uniform4f(gl.getUniformLocation(this._program, 'color'), ...colorToVector(parameters.color));
100
+ gl.uniform4f(gl.getUniformLocation(this._program, 'shadowColor'), ...colorToVector(shadowColor));
101
+
102
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
103
+ gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
104
+ gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_INT, 0);
105
+
106
+ if (parameters.showIndividualPoints) {
107
+ gl.useProgram(this._circleProgram);
108
+
109
+ gl.uniform1f(gl.getUniformLocation(this._circleProgram, 'width'), width);
110
+ gl.uniform1f(gl.getUniformLocation(this._circleProgram, 'height'), height);
111
+ gl.uniform1f(gl.getUniformLocation(this._circleProgram, 'pointSize'), 2*(thickness+6));
112
+ gl.uniform4f(gl.getUniformLocation(this._circleProgram, 'color'), ...colorToVector(parameters.color));
113
+
114
+ const individualPoints = parameters.getIndividualPoints();
115
+
116
+ gl.enableVertexAttribArray(0);
117
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._individualPointBuffer);
118
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(individualPoints.flat()), gl.STATIC_DRAW);
119
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
120
+
121
+ gl.drawArrays(gl.POINTS, 0, individualPoints.length);
122
+ }
123
+ }
124
+
125
+ }
@@ -0,0 +1,72 @@
1
+ import {DPI_INCREASE} from './size_canvas';
2
+
3
+ /**
4
+ * Returns an array of contiguous paths from data in render space
5
+ *
6
+ * @param {{nullMask: Uint8Array, maxYValues: Float64Array, minYValues: Float64Array, yValues: Float64Array}} dataInRenderSpace
7
+ * @param {Object} options
8
+ * @param {Number} options.splitAtY - split the path whenever it's suddenly less or greater than this value
9
+ * @return {[[Number]]}
10
+ */
11
+ export default function pathsFrom(dataInRenderSpace, {splitAtY}={}) {
12
+ const paths = [];
13
+ let currentPath = [];
14
+ let previouslyDiscontinuous = true;
15
+
16
+ const { nullMask, maxYValues, minYValues, yValues } = dataInRenderSpace;
17
+
18
+ for (let i = 0; i < yValues.length; i++) {
19
+ const x = i*DPI_INCREASE;
20
+ const y = yValues[i];
21
+
22
+ if (nullMask[i] & 0b001) { // y null
23
+ if (!previouslyDiscontinuous) {
24
+ paths.push(currentPath);
25
+ currentPath = [];
26
+ }
27
+
28
+ previouslyDiscontinuous = true;
29
+ continue;
30
+ }
31
+
32
+ currentPath.push([x, y]);
33
+
34
+ const minY = minYValues[i];
35
+ const maxY = maxYValues[i];
36
+
37
+ if (minY !== maxY) {
38
+ if (!(nullMask[i] & 0b010)) {
39
+ currentPath.push([x, minY]);
40
+ }
41
+
42
+ if (!(nullMask[i] & 0b100)) {
43
+ currentPath.push([x, maxY]);
44
+ }
45
+ currentPath.push([x, y]);
46
+ }
47
+
48
+ previouslyDiscontinuous = false;
49
+
50
+ if (typeof splitAtY === 'number' && i > 0) {
51
+ const prevY = yValues[i-1];
52
+ const signFlipped = !(nullMask[i-1] & 0b001) && (prevY < splitAtY && y >= splitAtY) || (prevY > splitAtY && y <= splitAtY);
53
+
54
+ if (signFlipped) {
55
+ if (!previouslyDiscontinuous) {
56
+ paths.push(currentPath);
57
+ currentPath = [
58
+ [x, y]
59
+ ];
60
+ }
61
+
62
+ previouslyDiscontinuous = true;
63
+ }
64
+ }
65
+ }
66
+
67
+ if (!previouslyDiscontinuous) {
68
+ paths.push(currentPath);
69
+ }
70
+
71
+ return paths;
72
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Scales y min and max bounds according to linear or log
3
+ *
4
+ * @param {Number} minY
5
+ * @param {Number} maxY
6
+ * @param {'linear'|'log'} scale
7
+ * @return {{minY: Number, maxY: Number}}
8
+ */
9
+ export default function scaleBounds({ minY, maxY, scale }) {
10
+ if (scale === 'log') {
11
+ maxY = Math.log10(maxY);
12
+
13
+ if (minY <= 0) {
14
+ if (maxY > 0) {
15
+ minY = -maxY;
16
+ } else {
17
+ minY = 2*maxY;
18
+ }
19
+ } else {
20
+ minY = Math.log10(minY);
21
+ }
22
+ }
23
+
24
+ return {
25
+ minY,
26
+ maxY
27
+ };
28
+ }
@@ -0,0 +1,59 @@
1
+ export const DPI_INCREASE = 2;
2
+
3
+ /**
4
+ * Sizes the canvas such that rendering is pixel perfect
5
+ * Returns the sizing information
6
+ *
7
+ * @param {HTMLCanvasElement} canvas
8
+ * @param {CanvasRenderingContext2D} context
9
+ * @param {Boolean} reset - if true, will reset the canvas size before checking sizing
10
+ * @return {Promise<{boundingRect: DOMRect, pixelRatio: number, elementHeight: number, renderWidth: number, renderHeight: number, elementWidth: number}>}
11
+ */
12
+ export default async function sizeCanvas(canvas, context, {reset=true}={}) {
13
+ if (reset) {
14
+ canvas.width = '';
15
+ canvas.height = '';
16
+ canvas.style.width = '0';
17
+ canvas.style.height = '';
18
+
19
+ await new Promise((resolve) => requestAnimationFrame(resolve));
20
+ }
21
+
22
+ let boundingRect = canvas.parentNode.getBoundingClientRect();
23
+
24
+ while (boundingRect.width === 0) {
25
+ await new Promise((resolve) => requestAnimationFrame(resolve));
26
+ boundingRect = canvas.getBoundingClientRect();
27
+ }
28
+
29
+ const dpr = window.devicePixelRatio || 1;
30
+ const bsr = context.webkitBackingStorePixelRatio ||
31
+ context.mozBackingStorePixelRatio ||
32
+ context.msBackingStorePixelRatio ||
33
+ context.oBackingStorePixelRatio ||
34
+ context.backingStorePixelRatio || 1;
35
+
36
+ const pixelRatio = DPI_INCREASE*dpr / bsr;
37
+
38
+ const elementWidth = boundingRect.width;
39
+ const elementHeight = boundingRect.height;
40
+ const renderWidth = elementWidth * pixelRatio;
41
+ const renderHeight = elementHeight * pixelRatio;
42
+
43
+ canvas.width = renderWidth;
44
+ canvas.height = renderHeight;
45
+ canvas.style.width = `${elementWidth}px`;
46
+ canvas.style.height = `${elementHeight}px`;
47
+
48
+ // We could us this to make coordinates behave as if they weren't transformed if we wanted
49
+ // context.setTransform(this.pixelRatio, 0, 0, this.pixelRatio, 0, 0)
50
+
51
+ return {
52
+ pixelRatio,
53
+ elementWidth,
54
+ elementHeight,
55
+ renderWidth,
56
+ renderHeight,
57
+ boundingRect
58
+ };
59
+ }
@@ -0,0 +1,233 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ [[package]]
4
+ name = "bumpalo"
5
+ version = "3.2.0"
6
+ source = "registry+https://github.com/rust-lang/crates.io-index"
7
+ checksum = "1f359dc14ff8911330a51ef78022d376f25ed00248912803b58f00cb1c27f742"
8
+
9
+ [[package]]
10
+ name = "cfg-if"
11
+ version = "0.1.10"
12
+ source = "registry+https://github.com/rust-lang/crates.io-index"
13
+ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
14
+
15
+ [[package]]
16
+ name = "console_error_panic_hook"
17
+ version = "0.1.6"
18
+ source = "registry+https://github.com/rust-lang/crates.io-index"
19
+ checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
20
+ dependencies = [
21
+ "cfg-if",
22
+ "wasm-bindgen",
23
+ ]
24
+
25
+ [[package]]
26
+ name = "futures"
27
+ version = "0.1.29"
28
+ source = "registry+https://github.com/rust-lang/crates.io-index"
29
+ checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
30
+
31
+ [[package]]
32
+ name = "grapher-rs"
33
+ version = "0.1.0"
34
+ dependencies = [
35
+ "console_error_panic_hook",
36
+ "futures",
37
+ "js-sys",
38
+ "wasm-bindgen",
39
+ "wasm-bindgen-futures",
40
+ "wasm-bindgen-test",
41
+ "web-sys",
42
+ ]
43
+
44
+ [[package]]
45
+ name = "js-sys"
46
+ version = "0.3.36"
47
+ source = "registry+https://github.com/rust-lang/crates.io-index"
48
+ checksum = "1cb931d43e71f560c81badb0191596562bafad2be06a3f9025b845c847c60df5"
49
+ dependencies = [
50
+ "wasm-bindgen",
51
+ ]
52
+
53
+ [[package]]
54
+ name = "lazy_static"
55
+ version = "1.4.0"
56
+ source = "registry+https://github.com/rust-lang/crates.io-index"
57
+ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
58
+
59
+ [[package]]
60
+ name = "log"
61
+ version = "0.4.8"
62
+ source = "registry+https://github.com/rust-lang/crates.io-index"
63
+ checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
64
+ dependencies = [
65
+ "cfg-if",
66
+ ]
67
+
68
+ [[package]]
69
+ name = "proc-macro2"
70
+ version = "0.4.30"
71
+ source = "registry+https://github.com/rust-lang/crates.io-index"
72
+ checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
73
+ dependencies = [
74
+ "unicode-xid 0.1.0",
75
+ ]
76
+
77
+ [[package]]
78
+ name = "proc-macro2"
79
+ version = "1.0.9"
80
+ source = "registry+https://github.com/rust-lang/crates.io-index"
81
+ checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"
82
+ dependencies = [
83
+ "unicode-xid 0.2.0",
84
+ ]
85
+
86
+ [[package]]
87
+ name = "quote"
88
+ version = "0.6.13"
89
+ source = "registry+https://github.com/rust-lang/crates.io-index"
90
+ checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
91
+ dependencies = [
92
+ "proc-macro2 0.4.30",
93
+ ]
94
+
95
+ [[package]]
96
+ name = "quote"
97
+ version = "1.0.3"
98
+ source = "registry+https://github.com/rust-lang/crates.io-index"
99
+ checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
100
+ dependencies = [
101
+ "proc-macro2 1.0.9",
102
+ ]
103
+
104
+ [[package]]
105
+ name = "scoped-tls"
106
+ version = "1.0.0"
107
+ source = "registry+https://github.com/rust-lang/crates.io-index"
108
+ checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
109
+
110
+ [[package]]
111
+ name = "syn"
112
+ version = "1.0.16"
113
+ source = "registry+https://github.com/rust-lang/crates.io-index"
114
+ checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859"
115
+ dependencies = [
116
+ "proc-macro2 1.0.9",
117
+ "quote 1.0.3",
118
+ "unicode-xid 0.2.0",
119
+ ]
120
+
121
+ [[package]]
122
+ name = "unicode-xid"
123
+ version = "0.1.0"
124
+ source = "registry+https://github.com/rust-lang/crates.io-index"
125
+ checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
126
+
127
+ [[package]]
128
+ name = "unicode-xid"
129
+ version = "0.2.0"
130
+ source = "registry+https://github.com/rust-lang/crates.io-index"
131
+ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
132
+
133
+ [[package]]
134
+ name = "wasm-bindgen"
135
+ version = "0.2.59"
136
+ source = "registry+https://github.com/rust-lang/crates.io-index"
137
+ checksum = "3557c397ab5a8e347d434782bcd31fc1483d927a6826804cec05cc792ee2519d"
138
+ dependencies = [
139
+ "cfg-if",
140
+ "wasm-bindgen-macro",
141
+ ]
142
+
143
+ [[package]]
144
+ name = "wasm-bindgen-backend"
145
+ version = "0.2.59"
146
+ source = "registry+https://github.com/rust-lang/crates.io-index"
147
+ checksum = "e0da9c9a19850d3af6df1cb9574970b566d617ecfaf36eb0b706b6f3ef9bd2f8"
148
+ dependencies = [
149
+ "bumpalo",
150
+ "lazy_static",
151
+ "log",
152
+ "proc-macro2 1.0.9",
153
+ "quote 1.0.3",
154
+ "syn",
155
+ "wasm-bindgen-shared",
156
+ ]
157
+
158
+ [[package]]
159
+ name = "wasm-bindgen-futures"
160
+ version = "0.3.27"
161
+ source = "registry+https://github.com/rust-lang/crates.io-index"
162
+ checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c"
163
+ dependencies = [
164
+ "cfg-if",
165
+ "futures",
166
+ "js-sys",
167
+ "wasm-bindgen",
168
+ "web-sys",
169
+ ]
170
+
171
+ [[package]]
172
+ name = "wasm-bindgen-macro"
173
+ version = "0.2.59"
174
+ source = "registry+https://github.com/rust-lang/crates.io-index"
175
+ checksum = "0f6fde1d36e75a714b5fe0cffbb78978f222ea6baebb726af13c78869fdb4205"
176
+ dependencies = [
177
+ "quote 1.0.3",
178
+ "wasm-bindgen-macro-support",
179
+ ]
180
+
181
+ [[package]]
182
+ name = "wasm-bindgen-macro-support"
183
+ version = "0.2.59"
184
+ source = "registry+https://github.com/rust-lang/crates.io-index"
185
+ checksum = "25bda4168030a6412ea8a047e27238cadf56f0e53516e1e83fec0a8b7c786f6d"
186
+ dependencies = [
187
+ "proc-macro2 1.0.9",
188
+ "quote 1.0.3",
189
+ "syn",
190
+ "wasm-bindgen-backend",
191
+ "wasm-bindgen-shared",
192
+ ]
193
+
194
+ [[package]]
195
+ name = "wasm-bindgen-shared"
196
+ version = "0.2.59"
197
+ source = "registry+https://github.com/rust-lang/crates.io-index"
198
+ checksum = "fc9f36ad51f25b0219a3d4d13b90eb44cd075dff8b6280cca015775d7acaddd8"
199
+
200
+ [[package]]
201
+ name = "wasm-bindgen-test"
202
+ version = "0.2.50"
203
+ source = "registry+https://github.com/rust-lang/crates.io-index"
204
+ checksum = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1"
205
+ dependencies = [
206
+ "console_error_panic_hook",
207
+ "futures",
208
+ "js-sys",
209
+ "scoped-tls",
210
+ "wasm-bindgen",
211
+ "wasm-bindgen-futures",
212
+ "wasm-bindgen-test-macro",
213
+ ]
214
+
215
+ [[package]]
216
+ name = "wasm-bindgen-test-macro"
217
+ version = "0.2.50"
218
+ source = "registry+https://github.com/rust-lang/crates.io-index"
219
+ checksum = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5"
220
+ dependencies = [
221
+ "proc-macro2 0.4.30",
222
+ "quote 0.6.13",
223
+ ]
224
+
225
+ [[package]]
226
+ name = "web-sys"
227
+ version = "0.3.36"
228
+ source = "registry+https://github.com/rust-lang/crates.io-index"
229
+ checksum = "721c6263e2c66fd44501cc5efbfa2b7dfa775d13e4ea38c46299646ed1f9c70a"
230
+ dependencies = [
231
+ "js-sys",
232
+ "wasm-bindgen",
233
+ ]
@@ -0,0 +1,35 @@
1
+ [package]
2
+ name = "grapher-rs"
3
+ version = "0.1.0"
4
+ authors = ["Kai Marshland <kaimarshland@gmail.com>"]
5
+ edition = "2018"
6
+
7
+ [lib]
8
+ crate-type = ["cdylib"]
9
+
10
+ [profile.release]
11
+ lto = true
12
+
13
+ [features]
14
+
15
+ [dependencies]
16
+ wasm-bindgen = "0.2.45"
17
+ js-sys = "0.3.22"
18
+
19
+ [dependencies.web-sys]
20
+ version = "0.3.22"
21
+ features = ["console"]
22
+
23
+ # The `console_error_panic_hook` crate provides better debugging of panics by
24
+ # logging them with `console.error`. This is great for development, but requires
25
+ # all the `std::fmt` and `std::panicking` infrastructure, so it's only enabled
26
+ # in debug mode.
27
+ [target."cfg(debug_assertions)".dependencies]
28
+ console_error_panic_hook = "0.1.5"
29
+
30
+ # These crates are used for running unit tests.
31
+ [dev-dependencies]
32
+ wasm-bindgen-test = "0.2.45"
33
+ futures = "0.1.27"
34
+ wasm-bindgen-futures = "0.3.22"
35
+
@@ -0,0 +1,42 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {number} length
5
+ * @param {Float64Array} data
6
+ * @param {Uint8Array} data_null_mask
7
+ * @param {any} params
8
+ * @param {Uint8Array} null_mask
9
+ * @param {Float64Array} y_values
10
+ * @param {Float64Array} min_y_values
11
+ * @param {Float64Array} max_y_values
12
+ */
13
+ export function selected_space_to_render_space(length: number, data: Float64Array, data_null_mask: Uint8Array, params: any, null_mask: Uint8Array, y_values: Float64Array, min_y_values: Float64Array, max_y_values: Float64Array): void;
14
+ /**
15
+ * @param {number} dpi_increase
16
+ * @param {Uint8Array} null_mask
17
+ * @param {Float64Array} y_values
18
+ * @param {Float64Array} min_y_values
19
+ * @param {Float64Array} max_y_values
20
+ * @param {Float32Array} positions
21
+ * @param {Float32Array} prev_positions
22
+ * @param {Float32Array} vertices
23
+ * @param {Uint32Array} indices
24
+ * @param {boolean} dashed
25
+ * @param {number} dash0
26
+ * @param {number} dash1
27
+ */
28
+ export function extract_vertices(dpi_increase: number, null_mask: Uint8Array, y_values: Float64Array, min_y_values: Float64Array, max_y_values: Float64Array, positions: Float32Array, prev_positions: Float32Array, vertices: Float32Array, indices: Uint32Array, dashed: boolean, dash0: number, dash1: number): void;
29
+ /**
30
+ */
31
+ export function main_js(): void;
32
+ /**
33
+ * @param {Uint8Array} null_mask
34
+ * @param {Float64Array} y_values
35
+ * @param {Float64Array} min_y_values
36
+ * @param {Float64Array} max_y_values
37
+ * @param {boolean} dashed
38
+ * @param {number} dash0
39
+ * @param {number} dash1
40
+ * @returns {number}
41
+ */
42
+ export function get_point_number(null_mask: Uint8Array, y_values: Float64Array, min_y_values: Float64Array, max_y_values: Float64Array, dashed: boolean, dash0: number, dash1: number): number;