@antv/t8
Version:
T8 is a text visualization solution for unstructured data within the AntV technology stack, and it is a declarative JSON Schema syntax that can be used to describe the content of data interpretation reports.
41 lines (37 loc) • 1.64 kB
JavaScript
;
var createEntityPhraseFactory = require('../createEntityPhraseFactory.js');
require('preact/jsx-runtime');
require('tslib');
require('preact/hooks');
require('../../charts/line/useLineCompute.js');
var index = require('../../charts/proportion/index.js');
var preact = require('preact');
var createInlineDocument = require('../utils/createInlineDocument.js');
var isType = require('../../utils/isType.js');
require('clarinet');
var defaultProportionDescriptor = {
render: function (value, _a) {
var origin = _a.origin;
var chartElement = document.createElement('span');
preact.render(preact.h(index.Proportion, { data: getProportionNumber(value, origin) }), chartElement);
return createInlineDocument.createInlineDocument(chartElement, value, 'suffix');
},
tooltip: {
title: function (value, metadata) { return (isType.isNumber(metadata.origin) ? "".concat(metadata.origin) : null); },
},
};
var createProportion = createEntityPhraseFactory.createEntityPhraseFactory('proportion', defaultProportionDescriptor);
/** text & entity */
var isNaN = function (v) { return Number.isNaN(v); };
function getProportionNumber(text, value) {
if (value && !isNaN(value))
return value;
if (text === null || text === void 0 ? void 0 : text.endsWith('%')) {
var percentageValue = text === null || text === void 0 ? void 0 : text.replace(/%$/, '');
if (!isNaN(Number(percentageValue)))
return Number(percentageValue) / 100;
}
return NaN;
}
exports.createProportion = createProportion;
//# sourceMappingURL=createProportion.js.map