xiaohongshu
xiaohongshu
Create D3 questions with double number lines showing proportional relationships. Students complete missing values on parallel number lines.
Full skill instructions
Use this skill when creating questions where students:
Perfect for:
Not suitable for:
Copy these from .claude/skills/question-types/:
implement-double-number-line-question/snippets/double-number-line.js → Complete double number line implementationsnippets/cards/standard-card.js → createStandardCard()snippets/cards/explanation-card.js → createExplanationCard() - For student explanationscat courses/IM-8th-Grade/modules/Unit-3/assignments/117-Equivalent-Ratios/questions/02/attachments/chart.js
function createDefaultState() {
return {
dnl1: "", // First blank on top number line
dnl2: "", // Second blank on top number line
dnl3: "", // First blank on bottom number line
dnl4: "", // Second blank on bottom number line
finalAnswer: "" // Optional: answer based on the number lines
};
}
Inline the complete double-number-line.js snippet into your chart.js file.
function buildLayout(d3, containerSelector) {
const container = d3.select(containerSelector);
container.html("");
// Create double number line
const dnlInputs = createDoubleNumberLine(container, {
svgWidth: 700,
svgHeight: 200,
topLabel: "Days",
bottomLabel: "Pies",
topValues: ["0", "3", "6", "9", null, null],
bottomValues: ["0", "8", "16", "24", null, null],
inputPositions: {
top: [{ index: 4, key: "dnl1" }, { index: 5, key: "dnl2" }],
bottom: [{ index: 4, key: "dnl3" }, { index: 5, key: "dnl4" }]
}
});
// Store for interactivity control
window.dnlInputs = dnlInputs;
}
function setInteractivity(enabled) {
if (window.dnlInputs) {
window.dnlInputs.setInteractivity(enabled);
}
}
{
svgWidth: 700, // SVG width (default: 700)
svgHeight: 200, // SVG height (default: 200)
lineY1: 60, // Top line Y position (default: 60)
lineY2: 140, // Bottom line Y position (default: 140)
lineStartX: 50, // Line start X (default: 50)
lineEndX: 650, // Line end X (default: 650)
tickLength: 10, // Tick mark length (default: 10)
topLabel: "Days", // Top line label
bottomLabel: "Pies", // Bottom line label
numPositions: 6 // Number of tick marks (default: 6)
}
{
topValues: ["0", "3", "6", "9", null, null], // null = input box
bottomValues: ["0", "8", "16", "24", null, null],
inputPositions: {
top: [
{ index: 4, key: "dnl1" }, // Position 4, state key "dnl1"
{ index: 5, key: "dnl2" } // Position 5, state key "dnl2"
],
bottom: [
{ index: 4, key: "dnl3" },
{ index: 5, key: "dnl4" }
]
}
}
The snippet uses SVG foreignObject for input positioning. This is the ONLY reliable method.
✅ Correct: Uses same coordinate system as SVG text labels ✅ Correct: Direct SVG coordinates with centering formula ✅ Correct: Perfect alignment with tick marks
❌ Wrong: Div overlay with percentage positioning ❌ Wrong: Mixing coordinate systems
For an input of width W and height H, to center it on SVG coordinate (x, y):
.attr("x", x - W/2) // Subtract half the width
.attr("y", y - H/2) // Subtract half the height
Example:
{
numPositions: 8, // 8 ticks instead of 6
topValues: ["0", "2", "4", "6", null, null, "14", "16"],
bottomValues: ["0", "5", "10", "15", null, null, "35", "40"]
}
{
topValues: ["0", "3", null, null, "12", null],
inputPositions: {
top: [
{ index: 2, key: "dnl1" },
{ index: 3, key: "dnl2" },
{ index: 5, key: "dnl3" }
],
bottom: [
{ index: 2, key: "dnl4" },
{ index: 3, key: "dnl5" },
{ index: 5, key: "dnl6" }
]
}
}
Many double number line questions include a table showing the relationship first:
// Before creating the double number line
const tableCard = createStandardCard(container, {
title: "Ratio Table",
content: tableHtml
});
// Then create the double number line
const dnlInputs = createDoubleNumberLine(container, config);
double-number-line.js snippet into chart.js❌ Use div overlay with percentage positioning ❌ Mix coordinate systems (SVG and CSS percentages) ❌ Hardcode pixel positions without centering formula ❌ Use transform: translate() for positioning inputs ❌ Forget to subtract half width/height for centering
✅ Always use SVG foreignObject for input positioning ✅ Use same coordinate system as SVG text labels ✅ Apply centering formula: x - width/2, y - height/2 ✅ Position inputs at tick mark X-coordinates ✅ Test alignment in actual browser ✅ Document Y-coordinate choices for maintainability
courses/IM-8th-Grade/modules/Unit-3/assignments/117-Equivalent-Ratios/questions/02/attachments/chart.js
This example includes:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience