UNPKG

@antv/t8

Version:

T8 is a text visualization solution for unstructured data within the AntV technology stack, and it is a declarative T8 markdown syntax that can be used to describe the content of data interpretation reports.

30 lines (27 loc) 1.22 kB
import '../utils/selection.js'; import { arc } from '../utils/paths.js'; import { createSvg } from '../utils/createSvg.js'; import { getElementFontSize } from '../../utils/getElementFontSize.js'; // Background color for the unfilled portion of the circle var PROPORTION_SHADOW_COLOR = '#CDDDFD'; // Fill color for the proportion segment var PROPORTION_FILL_COLOR = '#3471F9'; /** * Renders a circular proportion indicator */ var renderProportionChart = function (container, config, paragraphType, themeSeedToken) { var _a = config.data, data = _a === void 0 ? 0 : _a; var chartSize = getElementFontSize(paragraphType, themeSeedToken); var proportion = Math.max(0, Math.min(1, data)); // Clamp between 0 and 1 var r = chartSize / 2; var svg = createSvg(container, chartSize, chartSize); // Background circle svg.append('circle').attr('cx', r).attr('cy', r).attr('r', r).attr('fill', PROPORTION_SHADOW_COLOR); // Full circle // Arc segment var endAngle = proportion * 2 * Math.PI; var arcPath = arc(r)(r, r, endAngle); svg.append('path').attr('d', arcPath).attr('fill', PROPORTION_FILL_COLOR); }; export { renderProportionChart }; //# sourceMappingURL=index.js.map