{"version":3,"file":"ValuationsChart-DM1cw6nh.js","sources":["../../../app/javascript/components/Valuations/ValuationsChart.tsx"],"sourcesContent":["import React, { memo } from 'react';\nimport PropTypes from 'prop-types';\nimport { Line } from '../../dashboards/components/common/chartjs-3';\nimport { FONT_FAMILY } from '../../dashboards/components/common/chartjs-3/constant';\n\ninterface IProps {\n data: any;\n labels: string[];\n minHeight: string;\n isEmbeded?: boolean;\n}\n\nconst getChartOptions = (isEmbeded: boolean) => ({\n responsive: true,\n maintainAspectRatio: false,\n plugins: {\n legend: {\n position: 'bottom',\n align: 'center',\n labels: {\n boxWidth: 8,\n pointStyleWidth: 6,\n usePointStyle: true,\n pointStyle: 'circle',\n font: {\n size: 13,\n family: FONT_FAMILY,\n },\n },\n },\n tooltip: {\n callbacks: {\n label(tooltipItem: any) {\n return `$${Number(tooltipItem.raw)\n .toFixed(0)\n .replace(/./g, (c, i, a) =>\n i > 0 && c !== '.' && (a.length - i) % 3 === 0 ? `,${c}` : c,\n )}`;\n },\n },\n },\n },\n scales: {\n yAxes: {\n title: {\n display: true,\n text: 'Post-money valuation',\n },\n ticks: {\n callback: (value: number) => {\n const mills = Math.round(value / 1000000);\n if (mills >= 1000) {\n return `$${Math.round(value / 1000000000.0).toFixed(0)}B`;\n }\n return `$${value / 1000000}M`;\n },\n },\n },\n xAxes: {\n ticks: {\n display: !isEmbeded,\n autoSkip: true,\n maxRotation: 0,\n minRotation: 0,\n },\n },\n },\n});\n\nconst getChartData = (labels: string[], data: any) => {\n const commonOptions = {\n cubicInterpolationMode: 'linear',\n tension: 0.4,\n spanGaps: true,\n };\n const skipped = (ctx: any, value: any) =>\n ctx.p0.skip || ctx.p1.skip ? value : undefined;\n\n const dataSets = [\n {\n label: '25th percentile',\n ...commonOptions,\n backgroundColor: 'rgba(255, 206, 86, 1)',\n borderColor: 'rgba(255, 206, 86, 1)',\n data: data[0.25] || [],\n order: 0,\n segment: {\n borderColor: (ctx) => skipped(ctx, 'rgb(255, 206, 86,0.2)'),\n borderDash: (ctx) => skipped(ctx, [6, 6]),\n },\n },\n {\n label: '50th',\n ...commonOptions,\n backgroundColor: 'rgba(54, 162, 235, 1)',\n borderColor: 'rgba(54, 162, 235, 1)',\n data: data[0.5] || [],\n order: 1,\n segment: {\n borderColor: (ctx) => skipped(ctx, 'rgb(54, 162, 235,0.2)'),\n borderDash: (ctx) => skipped(ctx, [6, 6]),\n },\n },\n {\n label: '75th',\n ...commonOptions,\n backgroundColor: 'rgba(75, 192, 192, 1)',\n borderColor: 'rgba(75, 192, 192, 1)',\n data: data[0.75] || [],\n order: 2,\n segment: {\n borderColor: (ctx) => skipped(ctx, 'rgb(75, 192, 192,0.2)'),\n borderDash: (ctx) => skipped(ctx, [6, 6]),\n },\n },\n {\n label: '90th',\n ...commonOptions,\n backgroundColor: 'rgba(153, 102, 255, 1)',\n borderColor: 'rgba(153, 102, 255, 1)',\n data: data[0.9] || [],\n order: 3,\n segment: {\n borderColor: (ctx) => skipped(ctx, 'rgb(153, 102, 255,0.2)'),\n borderDash: (ctx) => skipped(ctx, [6, 6]),\n },\n },\n {\n label: '95th',\n ...commonOptions,\n backgroundColor: 'rgba(255, 159, 64, 1)',\n borderColor: 'rgba(255, 159, 64, 1)',\n data: data[0.95] || [],\n order: 4,\n segment: {\n borderColor: (ctx) => skipped(ctx, 'rgb(255, 159, 64,0.2)'),\n borderDash: (ctx) => skipped(ctx, [6, 6]),\n },\n },\n ];\n\n return {\n labels,\n datasets: dataSets.filter((n) => n.data.length > 0),\n };\n};\n\nconst ValuationsLineChart = (props: IProps) => {\n const { labels, data, minHeight, isEmbeded } = props;\n const chartData = getChartData(labels, data);\n const options = getChartOptions(isEmbeded);\n\n return (\n \n \n \n );\n};\n\nValuationsLineChart.propTypes = {\n data: PropTypes.object.isRequired,\n labels: PropTypes.array.isRequired,\n isEmbeded: PropTypes.bool,\n};\n\nValuationsLineChart.defaultProps = {\n isEmbeded: false,\n};\n\nexport default memo(ValuationsLineChart);\n"],"names":["getChartOptions","isEmbeded","FONT_FAMILY","tooltipItem","c","i","a","value","getChartData","labels","data","commonOptions","skipped","ctx","dataSets","n","ValuationsLineChart","props","minHeight","chartData","options","jsx","Line","PropTypes","memo"],"mappings":"uIAYA,MAAMA,EAAmBC,IAAwB,CAC/C,WAAY,GACZ,oBAAqB,GACrB,QAAS,CACP,OAAQ,CACN,SAAU,SACV,MAAO,SACP,OAAQ,CACN,SAAU,EACV,gBAAiB,EACjB,cAAe,GACf,WAAY,SACZ,KAAM,CACJ,KAAM,GACN,OAAQC,CACV,CACF,CACF,EACA,QAAS,CACP,UAAW,CACT,MAAMC,EAAkB,CACtB,MAAO,IAAI,OAAOA,EAAY,GAAG,EAC9B,QAAQ,CAAC,EACT,QAAQ,KAAM,CAACC,EAAGC,EAAGC,IACpBD,EAAI,GAAKD,IAAM,MAAQE,EAAE,OAASD,GAAK,IAAM,EAAI,IAAID,CAAC,GAAKA,CAC5D,CAAA,EACL,CACF,CACF,CACF,EACA,OAAQ,CACN,MAAO,CACL,MAAO,CACL,QAAS,GACT,KAAM,sBACR,EACA,MAAO,CACL,SAAWG,GACK,KAAK,MAAMA,EAAQ,GAAO,GAC3B,IACJ,IAAI,KAAK,MAAMA,EAAQ,GAAY,EAAE,QAAQ,CAAC,CAAC,IAEjD,IAAIA,EAAQ,GAAO,GAE9B,CACF,EACA,MAAO,CACL,MAAO,CACL,QAAS,CAACN,EACV,SAAU,GACV,YAAa,EACb,YAAa,CACf,CACF,CACF,CACF,GAEMO,EAAe,CAACC,EAAkBC,IAAc,CACpD,MAAMC,EAAgB,CACpB,uBAAwB,SACxB,QAAS,GACT,SAAU,EAAA,EAENC,EAAU,CAACC,EAAUN,IACzBM,EAAI,GAAG,MAAQA,EAAI,GAAG,KAAON,EAAQ,OAEjCO,EAAW,CACf,CACE,MAAO,kBACP,GAAGH,EACH,gBAAiB,wBACjB,YAAa,wBACb,KAAMD,EAAK,GAAI,GAAK,CAAC,EACrB,MAAO,EACP,QAAS,CACP,YAAcG,G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