observablehq

Zoomable sunburst chart shows only two layers of the hierarchy at a time in React JS

淺唱寂寞╮ 提交于 2021-02-11 12:51:30
问题 I have tried many ways to convert this:- https://observablehq.com/@d3/zoomable-sunburst into react as it's majorly using observable and runtime . That is not being converted to React. It's using some helper.js as well in this. Code is here https://observablehq.com/@d3/zoomable-sunburst Is there any idea that anyone can give or any suggestion to do it. Thanks in advance 回答1: The op has reached to Observablehq forum. Here are some insights on the answer for the problem in case you need help

Zoomable sunburst chart shows only two layers of the hierarchy at a time in React JS

一世执手 提交于 2021-02-11 12:51:11
问题 I have tried many ways to convert this:- https://observablehq.com/@d3/zoomable-sunburst into react as it's majorly using observable and runtime . That is not being converted to React. It's using some helper.js as well in this. Code is here https://observablehq.com/@d3/zoomable-sunburst Is there any idea that anyone can give or any suggestion to do it. Thanks in advance 回答1: The op has reached to Observablehq forum. Here are some insights on the answer for the problem in case you need help

Adding img.crossOrigin = “*” interferes with img.complete

假装没事ソ 提交于 2021-01-29 05:20:05
问题 I have a function that reads map tile images. I want to keep track of whether or not a certain image has already been cached. I'm using this function from this thread: function is_cached(src) { var image = new Image(); image.src = src; return image.complete; } This was working great. But then I needed to do some image processing. In order to copy the image data to a canvas and process it pixel by pixel, I need to use CanvasRenderingContext2D.drawImage(image, 0, 0) . But it bugs me with a

Tick text/variable labels not wrapping in d3 bar chart

房东的猫 提交于 2021-01-28 10:59:21
问题 I'm trying apply line wrapping to long variable labels along the x-axis in a d3 bar chart. Here's an my chart in an Observable notebook: https://observablehq.com/@unfpamaldives/figure4 I've attempted to apply a solution from this block, consisting essentially of the following: function wrap(text, width) { text.each(function() { var text = d3.select(this), words = text.text().split(/\s+/).reverse(), word, line = [], lineNumber = 0, lineHeight = 1.1, // ems y = text.attr("y"), dy = parseFloat

How to show demo with HTML and JavaScript (D3.js) on GitHub for every commit

余生长醉 提交于 2021-01-27 18:43:07
问题 I'm developing application that uses D3.js to showing some visualizations. How can I show preview of HTML file (that uses JS) on GitHub? I need demo for every commits (historical), not only for latest version. I generate static version of my application to HTML+JS with bundled JSON data and linked D3.js library from CDN, so I need only to serve HTML+JS. No backend. GitHub Pages My first thought is using GitHub Pages (it's popular answers #1, #2) . It is good, but with this I can show demo

How to run a D3 example

倾然丶 夕夏残阳落幕 提交于 2020-07-22 09:28:25
问题 For example https://observablehq.com/@d3/zoomable-treemap If you paste the fragments of script into a <script> tag in a HTML file the (obviously) it doesn't work. How are you supposed to run these things? And what the heck is italic f ? Why are no statements terminated with a semicolon and why are things declared without var ? Surely this cannot possibly work? <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <!-- Load d3.js --> <script src="https://d3js.org/d3.v4.js"></script> </head>

D3 example from Observable on my wordpress site

蓝咒 提交于 2020-06-01 05:53:05
问题 Thank you very much for the help in advance. I am trying to add this Sankey Diagram on my wordpress site. https://observablehq.com/@d3/sankey-diagram I am having a hard time. I downloaded the JS code, pasted it on my wordpress site, but it gives me a lot of errors Uncaught SyntaxError: Unexpected token 'export' Is the first error from the browser. This is the code I downloaded below: <script src="https://d3js.org/d3.v5.js"></script> <script> // https://observablehq.com/@d3/sankey-diagram@273

Legend not appearing when using document.createElement('canvas')

只愿长相守 提交于 2020-03-03 07:31:27
问题 I followed this Observable post to easily create a legend. Since the line DOM.canvas(1, n) in the ramp works only on Observable, I replaced it with document.createElement("canvas") and also modified the SVG so that it's appended to the main div tag. These changed do not cause any errors however the problem is that the legend is not displayed even though the legend SVG is present in the raw HTML. Here's the link to a JSFiddle. Any guidance would be greatly appreciated. 回答1: The canvas is being

Legend not appearing when using document.createElement('canvas')

▼魔方 西西 提交于 2020-03-03 07:31:08
问题 I followed this Observable post to easily create a legend. Since the line DOM.canvas(1, n) in the ramp works only on Observable, I replaced it with document.createElement("canvas") and also modified the SVG so that it's appended to the main div tag. These changed do not cause any errors however the problem is that the legend is not displayed even though the legend SVG is present in the raw HTML. Here's the link to a JSFiddle. Any guidance would be greatly appreciated. 回答1: The canvas is being