UNPKG

n8n-editor-ui

Version:

Workflow Editor UI for n8n

54 lines (53 loc) 2.07 kB
import { C as computed, Gt as unref, P as defineComponent, T as createBlock, et as openBlock } from "./vue.runtime.esm-bundler-tP5dCd7J.js"; import { C as useCssVar, gt as useI18n } from "./_MapCache-B159LOu5.js"; import "./CalendarDate-DxkU3CHY.js"; import "./merge-BArJwbQo.js"; import "./dateformat-CMLc6OKJ.js"; import { a as INSIGHTS_UNIT_MAPPING, t as GRANULARITY_DATE_FORMAT_MASK } from "./insights.constants-BoP_B6zb.js"; import { o as transformInsightsFailureRate } from "./insights.utils-DKMDXq77.js"; import "./chart-DnsWbmwc.js"; import { t as smartDecimal } from "./smartDecimal-Bnk1P3MO.js"; import { t as Bar } from "./dist-BbucLhyg.js"; import { t as generateBarChartOptions } from "./chartjs.utils-lBxrB8jU.js"; var InsightsChartFailureRate_default = /* @__PURE__ */ defineComponent({ __name: "InsightsChartFailureRate", props: { data: {}, type: {}, granularity: {}, startDate: {}, endDate: {} }, setup(__props) { const props = __props; const i18n = useI18n(); const colorPrimary = useCssVar("--color--primary", document.body); const chartOptions = computed(() => generateBarChartOptions({ plugins: { tooltip: { callbacks: { label: (context) => { return `${context.dataset.label ?? ""} ${smartDecimal(context.parsed.y)}${INSIGHTS_UNIT_MAPPING[props.type](context.parsed.y)}`; } } } } })); const chartData = computed(() => { const labels = []; const data = []; for (const entry of props.data) { labels.push(GRANULARITY_DATE_FORMAT_MASK[props.granularity](entry.date)); data.push(transformInsightsFailureRate(entry.values.failureRate)); } return { labels, datasets: [{ label: i18n.baseText("insights.banner.title.failureRate"), data, backgroundColor: colorPrimary.value }] }; }); return (_ctx, _cache) => { return openBlock(), createBlock(unref(Bar), { "data-test-id": "insights-chart-failure-rate", data: chartData.value, options: chartOptions.value }, null, 8, ["data", "options"]); }; } }); export { InsightsChartFailureRate_default as default };