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.

32 lines (28 loc) 1.29 kB
'use strict'; require('../utils/selection.js'); var paths = require('../utils/paths.js'); var createSvg = require('../utils/createSvg.js'); var getElementFontSize = require('../../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.getElementFontSize(paragraphType, themeSeedToken); var proportion = Math.max(0, Math.min(1, data)); // Clamp between 0 and 1 var r = chartSize / 2; var svg = createSvg.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 = paths.arc(r)(r, r, endAngle); svg.append('path').attr('d', arcPath).attr('fill', PROPORTION_FILL_COLOR); }; exports.renderProportionChart = renderProportionChart; //# sourceMappingURL=index.js.map