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.

45 lines (42 loc) 1.63 kB
import { getElementFontSize } from '../../utils/getElementFontSize.js'; import '../utils/selection.js'; import { scaleLinear } from '../utils/scales.js'; import 'tslib'; import { createSvg } from '../utils/createSvg.js'; import { SCALE_ADJUST, LINE_STROKE_COLOR, HIGHLIGHT_COLOR } from '../utils/const.js'; var ANOMALY_WIDTH = 1; var ANOMALY_HEIGHT = 12; var renderAnomalyChart = function (container, config, paragraphType, themeSeedToken) { var _a = config.data, data = _a === void 0 ? [] : _a; if (!data.length) return; var chartSize = getElementFontSize(paragraphType, themeSeedToken); var height = chartSize; var width = Math.max(chartSize * 2, data.length * 2); var svg = createSvg(container, width, height); var xScale = scaleLinear([0, data.length - 1], [SCALE_ADJUST, width - SCALE_ADJUST]); var centerY = height / 2; svg .append('line') .attr('x1', SCALE_ADJUST) .attr('y1', centerY) .attr('x2', width - SCALE_ADJUST) .attr('y2', centerY) .attr('stroke', LINE_STROKE_COLOR) .attr('stroke-width', 1); data.forEach(function (value, index) { var x = xScale(index); if (value !== 0) { svg .append('line') .attr('x1', x) .attr('y1', centerY - ANOMALY_HEIGHT / 2) .attr('x2', x) .attr('y2', centerY + ANOMALY_HEIGHT / 2) .attr('stroke', HIGHLIGHT_COLOR) .attr('stroke-width', ANOMALY_WIDTH); } }); }; export { renderAnomalyChart }; //# sourceMappingURL=index.js.map