MCPcopy
hub / github.com/chartbrew/chartbrew / getConfiguration

Method getConfiguration

server/charts/MatrixChart.js:12–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10 }
11
12 getConfiguration() {
13 // Only the first dataset (CDC) is rendered
14 const firstConfig = this.chart.ChartDatasetConfigs?.[0] || {};
15 const datasetColor = firstConfig?.datasetColor || "#3b82f6";
16
17 // Process raw axisData to build matrix points
18 const labels = this.axisData?.x || [];
19 const values = (this.axisData.y && this.axisData.y[0]) || [];
20 const dayLabels = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
21 const dataMap = new Map(); // Use Map to store data by date string
22
23 // First pass: collect all data points
24 for (let i = 0; i < labels.length; i++) {
25 const label = labels[i];
26 // Try strict with known format first
27 let m = this.moment(label, this.dateFormat, true);
28 // Fallbacks if label has no year (e.g., "May 20")
29 if (!m || !m.isValid()) {
30 const tryYearFormat = "YYYY MMM D";
31 m = this.moment(`${this.moment().year()} ${label}`, tryYearFormat, false);
32 if (!m.isValid()) {
33 m = this.moment(label, "MMM D", false);
34 }
35 }
36 if (!m || !m.isValid()) {
37 continue; // oxlint-disable-line no-continue
38 }
39
40 const dateOnly = m.format("YYYY-MM-DD");
41 const vNum = Number(`${values[i]}`.toString().replace(/,/g, ""));
42 const v = Number.isNaN(vNum) ? 0 : vNum;
43
44 dataMap.set(dateOnly, v);
45 }
46
47 // Use computed date range from AxisChart (respects currentEndDate),
48 // otherwise fall back to chart dates or data range
49 let minDate;
50 let maxDate;
51
52 if (this.startDate && this.endDate) {
53 // Use the computed dates passed from AxisChart
54 minDate = this.startDate.clone();
55 maxDate = this.endDate.clone();
56 } else if (this.chart.startDate && this.chart.endDate) {
57 // Fallback to chart's original dates
58 minDate = this.moment(this.chart.startDate).startOf("day");
59 maxDate = this.moment(this.chart.endDate).endOf("day");
60 } else if (labels.length > 0) {
61 // Fallback: use data range
62 for (let i = 0; i < labels.length; i++) {
63 const label = labels[i];
64 let m = this.moment(label, this.dateFormat, true);
65 if (!m || !m.isValid()) {
66 const tryYearFormat = "YYYY MMM D";
67 m = this.moment(`${this.moment().year()} ${label}`, tryYearFormat, false);
68 if (!m.isValid()) {
69 m = this.moment(label, "MMM D", false);

Callers

nothing calls this directly

Calls 2

setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected