Skip to content

Instantly share code, notes, and snippets.

@jebeck
jebeck / README.md
Last active February 18, 2024 20:32
Curved Text in SVG

Curved Text in SVG

Curved text in SVG isn't too hard, as long as you understand how to define different kinds of curved <path> elements in SVG. When you have a curved <path> defined in a <defs> elements (usually just inside your root <svg>), to make the text inside a <text> element follow that <path>, all that's required is to insert a <textPath> inside the <text>, with an xlink:href attribute that links to the id of the defined <path>. The actual text for display also gets added inside the <textPath>, like so:

<text>
  <textPath xlink:href="#yourPath">
    Your text
  </textPath>
@jebeck
jebeck / README.md
Last active May 30, 2023 05:03
SVG foreignObject tooltips in D3

SVG foreignObject tooltips in D3

Just a little proof-of-concept here - using an SVG <foreignObject> element as a container for a tooltip that can involve handy HTML features like text-wrapping and (semi-)dynamic sizing.

Gotchas so far:

  • Like an <svg> element, a <foreignObject> element needs a width and a height in order to be rendered.

  • However, specifying width and/or height can be delayed. Here I specify a width (foWidth) of 300px, then find the height of the contained <div> using getBoundingClientRect() and use that to specify the height of the containing <foreignObject>.

@jebeck
jebeck / infinite.js
Last active July 15, 2022 01:10
infinite interactivity with Inquirer and RxJS's Subject
// run with `node infinite.js` in node v4.x+
// must have Inquirer installed (`npm install inquirer`)
const inquirer = require('inquirer');
const Rx = require('rx');
const prompts = new Rx.Subject();
function makePrompt(msg) {
return {
@jebeck
jebeck / CDT all about D3 time scales.png
Last active June 2, 2022 02:21
all about D3 time scales
CDT all about D3 time scales.png
@jebeck
jebeck / README.md
Last active September 18, 2020 04:55
Dexcom .csv merge

Dexcom .csv merge

A simple tool to merge several Dexcom Studio .csv/.txt export files into a single file.

NB: Now being further developed in iPancreas-dexcom.

import { useEffect } from 'react';
export function makeGetAudioCtxSingleton() {
let ctx;
function createAudioCtx() {
return new AudioContext();
}
return () => {
@jebeck
jebeck / .gitignore
Last active November 14, 2019 01:33 — forked from devgru/.gitignore
RGB, HSL and LAB color spaces
.idea
bower_components
@jebeck
jebeck / simple.js
Created February 6, 2017 00:56
very simple Inquirer.js example
// run with `node simple.js` in node v4.x+
// must have Inquirer installed (`npm install inquirer`)
const inquirer = require('inquirer');
inquirer.prompt([{
name: 'name',
type: 'input',
message: 'What\'s your name?',
}, {
@jebeck
jebeck / Nodebook Bug.ipynb
Last active April 24, 2018 06:04
nodebook bug
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am jebeck on github.
  • I am jebeck (https://keybase.io/jebeck) on keybase.
  • I have a public key ASB1y_DGvqatJbSUze2jdOqUjNyAn9t4CA7va8xx0p3YIAo

To claim this, I am signing this object: