export function chartRem(res) { let docEl = document.documentElement, clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth; if (! clientWidth) return; let chartRem = 100 * (clientWidth / 1920); return res*chartRem; }Copy the code

Import {chartRem} from ‘./lib/utils’

Then set the pixel to 12px at 1920 screen width to pass in 0.12

ClientWidth / 1920 = 2 at 3840px; It’s 10020.12, so the final return at 3840 is 2 pixels of 1920.

Legend: {left: chartRem(2.7), itemWidth: chartRem(0.08), itemHeight: chartRem(0.08), itemGap: {fontSize: chartRem(0.12),}},Copy the code