MAIDR Documentation - v3.65.0
    Preparing search index...

    Module adapters/d3

    MAIDR D3.js Binder

    Provides functions to extract data from D3.js-rendered SVG charts and convert them to the MAIDR JSON schema for accessible, non-visual chart interaction.

    D3.js is the most widely used low-level SVG-based data visualization library on the web. This binder bridges D3 charts to MAIDR's accessibility features including audio sonification, text descriptions, braille output, and keyboard navigation.

    D3.js binds data to DOM elements via the __data__ property during .data() joins. The binder functions query the SVG for chart elements using CSS selectors and extract the bound data to generate the MAIDR schema.

    <script src="maidr/dist/d3.js"></script>
    <script>
    // After D3 renders the chart: the binder writes the `maidr-data`
    // attribute for you by default (pass `autoApply: false` to opt out).
    maidrD3.bindD3Bar(svgElement, {
    selector: 'rect.bar',
    title: 'My Chart',
    axes: { x: 'Category', y: 'Value' },
    });
    </script>
    import { bindD3Bar } from 'maidr/d3';

    const result = bindD3Bar(svgElement, {
    selector: 'rect.bar',
    title: 'My Chart',
    axes: { x: 'Category', y: 'Value' },
    });
    import { Maidr } from 'maidr/react';
    import { bindD3Bar } from 'maidr/d3';

    function AccessibleBarChart() {
    const svgRef = useRef(null);
    const [maidrData, setMaidrData] = useState(null);

    useEffect(() => {
    // After D3 renders into svgRef.current:
    const result = bindD3Bar(svgRef.current, { ... });
    setMaidrData(result.maidr);
    }, []);

    return maidrData ? (
    <Maidr data={maidrData}>
    <svg ref={svgRef}>...</svg>
    </Maidr>
    ) : <svg ref={svgRef} />;
    }

    References

    MaidrData → Maidr
    MaidrLayer → MaidrLayer
    MaidrSubplot → MaidrSubplot
    Orientation → Orientation
    TraceType → TraceType
    bindD3Bar → bindD3Bar
    bindD3Box → bindD3Box
    bindD3Candlestick → bindD3Candlestick
    bindD3Heatmap → bindD3Heatmap
    bindD3Histogram → bindD3Histogram
    bindD3Line → bindD3Line
    bindD3Scatter → bindD3Scatter
    bindD3Segmented → bindD3Segmented
    bindD3Smooth → bindD3Smooth
    D3BarConfig → D3BarConfig
    D3BinderConfig → D3BinderConfig
    D3BinderResult → D3BinderResult
    D3BoxConfig → D3BoxConfig
    D3CandlestickConfig → D3CandlestickConfig
    D3HeatmapConfig → D3HeatmapConfig
    D3HistogramConfig → D3HistogramConfig
    D3LineConfig → D3LineConfig
    D3ScatterConfig → D3ScatterConfig
    D3SegmentedConfig → D3SegmentedConfig
    D3SmoothConfig → D3SmoothConfig
    DataAccessor → DataAccessor
    SegmentedTraceType → SegmentedTraceType