Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export default function DefaultChart(props: ChartProps) {
<canvas
ref={mergeRefs(props.ref, (el) => setCanvasRef(el))}
height={merged.height}
width={merged.width}>
width={merged.width}
{...merged.extraCanvasAttributes}>
{merged.fallback}
</canvas>
)
Expand Down
12 changes: 11 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Ref } from '@solid-primitives/refs'
import type { ChartData, ChartOptions, Plugin, ChartTypeRegistry } from 'chart.js'
import type { JSXElement } from 'solid-js'
import type { JSXElement, JSX } from 'solid-js'

/**
* Chart props
Expand Down Expand Up @@ -52,4 +52,14 @@ export interface ChartProps {
* @default null
*/
ref?: Ref<HTMLCanvasElement | null>
/**
* Extra attributes to be forwarded directly to the canvas
*
* For example for setting the `id`, `role`, or `aria-label`.
*
* This can be used for any attribute except `width` and `height`,
* which can be set directly.
* @default {}
*/
extraCanvasAttributes?: Omit<JSX.CanvasHTMLAttributes<HTMLCanvasElement>, 'width' | 'height'>
}