UNPKG

@mozaic-ds/chart

Version:

<p align="center"> <img alt="ADEO Design system - Chart library" src="./.storybook/assets/adeo-design-system-chart-banner.svg" /> </p>

33 lines (30 loc) 746 B
export default function () { function getPatternCanvas( pattern: CanvasPattern, width = 50, height = 50 ): HTMLCanvasElement { const canvas: HTMLCanvasElement = document.createElement('canvas'); const ctx: CanvasRenderingContext2D | null = canvas.getContext('2d'); if (!ctx) { return canvas; } canvas.width = width; canvas.height = height; ctx.fillStyle = pattern; ctx.fillRect(0, 0, width, height); return canvas; } function getPatternIndexWithShift( dataSetIndex: number, patternShifting?: number ) { return ( (patternShifting ? dataSetIndex + patternShifting : dataSetIndex) % 6 ); } return { getPatternCanvas, getPatternIndexWithShift }; }