Apply repository-wide ESLint auto-fix formatting pass
Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
<template>
|
||||
<Chart type="line" :data="primeVueSetDataState" :options="primeVueSetOptionsState" class="h-96" />
|
||||
<Chart
|
||||
type="line"
|
||||
:data="primeVueSetDataState"
|
||||
:options="primeVueSetOptionsState"
|
||||
class="h-96"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -14,66 +19,66 @@
|
||||
* occurrence data with Chart.js bar charts.
|
||||
*/
|
||||
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ref, onMounted } from "vue";
|
||||
import {
|
||||
setTimeStringFormatBaseOnTimeDifference,
|
||||
mapTimestampToAxisTicksByFormat,
|
||||
} from '@/module/timeLabel.js';
|
||||
} from "@/module/timeLabel.js";
|
||||
|
||||
const knownScaleLineChartOptions = {
|
||||
x: {
|
||||
type: 'time',
|
||||
const knownScaleLineChartOptions = {
|
||||
x: {
|
||||
type: "time",
|
||||
title: {
|
||||
display: true,
|
||||
color: '#334155',
|
||||
font: {
|
||||
display: true,
|
||||
color: "#334155",
|
||||
font: {
|
||||
size: 12,
|
||||
lineHeight: 2
|
||||
}
|
||||
lineHeight: 2,
|
||||
},
|
||||
},
|
||||
time: {
|
||||
displayFormats: {
|
||||
second: 'h:mm:ss', // ex: 1:11:11
|
||||
minute: 'M/d h:mm', // ex: 1/1 1:11
|
||||
hour: 'M/d h:mm', // ex: 1/1 1:11
|
||||
day: 'M/d h', // ex: 1/1 1
|
||||
month: 'y/M/d', // ex: 1911/1/1
|
||||
},
|
||||
displayFormats: {
|
||||
second: "h:mm:ss", // ex: 1:11:11
|
||||
minute: "M/d h:mm", // ex: 1/1 1:11
|
||||
hour: "M/d h:mm", // ex: 1/1 1:11
|
||||
day: "M/d h", // ex: 1/1 1
|
||||
month: "y/M/d", // ex: 1911/1/1
|
||||
},
|
||||
},
|
||||
ticks: {
|
||||
display: true,
|
||||
maxRotation: 0, // Do not rotate labels (range: 0~50)
|
||||
color: '#64748b',
|
||||
source: 'labels', // Dynamically display label count proportionally
|
||||
display: true,
|
||||
maxRotation: 0, // Do not rotate labels (range: 0~50)
|
||||
color: "#64748b",
|
||||
source: "labels", // Dynamically display label count proportionally
|
||||
},
|
||||
border: {
|
||||
color: '#64748b',
|
||||
color: "#64748b",
|
||||
},
|
||||
grid: {
|
||||
tickLength: 0, // Prevent grid lines from extending beyond the axis
|
||||
}
|
||||
},
|
||||
y: {
|
||||
tickLength: 0, // Prevent grid lines from extending beyond the axis
|
||||
},
|
||||
},
|
||||
y: {
|
||||
beginAtZero: true, // Scale includes 0
|
||||
title: {
|
||||
display: true,
|
||||
color: '#334155',
|
||||
font: {
|
||||
display: true,
|
||||
color: "#334155",
|
||||
font: {
|
||||
size: 12,
|
||||
lineHeight: 2
|
||||
lineHeight: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
ticks:{
|
||||
color: '#64748b',
|
||||
padding: 8,
|
||||
ticks: {
|
||||
color: "#64748b",
|
||||
padding: 8,
|
||||
},
|
||||
grid: {
|
||||
color: '#64748b',
|
||||
color: "#64748b",
|
||||
},
|
||||
border: {
|
||||
display: false, // Hide the extra border line on the left side
|
||||
display: false, // Hide the extra border line on the left side
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const props = defineProps({
|
||||
@@ -93,8 +98,8 @@ const props = defineProps({
|
||||
|
||||
const primeVueSetDataState = ref(null);
|
||||
const primeVueSetOptionsState = ref(null);
|
||||
const colorPrimary = ref('#0099FF');
|
||||
const colorSecondary = ref('#FFAA44');
|
||||
const colorPrimary = ref("#0099FF");
|
||||
const colorSecondary = ref("#FFAA44");
|
||||
|
||||
/**
|
||||
* Compare page and Performance have this same function.
|
||||
@@ -103,13 +108,15 @@ const colorSecondary = ref('#FFAA44');
|
||||
* @param customizeOptions.content
|
||||
* @param customizeOptions.ticksOfXAxis
|
||||
*/
|
||||
const getCustomizedScaleOption = (whichScaleObj, {customizeOptions: {
|
||||
content,
|
||||
ticksOfXAxis,
|
||||
},
|
||||
}) => {
|
||||
const getCustomizedScaleOption = (
|
||||
whichScaleObj,
|
||||
{ customizeOptions: { content, ticksOfXAxis } },
|
||||
) => {
|
||||
let resultScaleObj;
|
||||
resultScaleObj = customizeScaleChartOptionTitleByContent(whichScaleObj, content);
|
||||
resultScaleObj = customizeScaleChartOptionTitleByContent(
|
||||
whichScaleObj,
|
||||
content,
|
||||
);
|
||||
resultScaleObj = customizeScaleChartOptionTicks(resultScaleObj, ticksOfXAxis);
|
||||
return resultScaleObj;
|
||||
};
|
||||
@@ -125,14 +132,14 @@ const customizeScaleChartOptionTicks = (scaleObjectToAlter, ticksOfXAxis) => {
|
||||
...scaleObjectToAlter,
|
||||
x: {
|
||||
...scaleObjectToAlter.x,
|
||||
ticks: {
|
||||
...scaleObjectToAlter.x.ticks,
|
||||
callback: function(value, index) {
|
||||
// Customize x-axis time ticks based on different intervals
|
||||
return ticksOfXAxis[index];
|
||||
},
|
||||
ticks: {
|
||||
...scaleObjectToAlter.x.ticks,
|
||||
callback: function (value, index) {
|
||||
// Customize x-axis time ticks based on different intervals
|
||||
return ticksOfXAxis[index];
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -154,21 +161,21 @@ const customizeScaleChartOptionTitleByContent = (whichScaleObj, content) => {
|
||||
|
||||
return {
|
||||
...whichScaleObj,
|
||||
x: {
|
||||
...whichScaleObj.x,
|
||||
title: {
|
||||
...whichScaleObj.x.title,
|
||||
text: content.x
|
||||
}
|
||||
x: {
|
||||
...whichScaleObj.x,
|
||||
title: {
|
||||
...whichScaleObj.x.title,
|
||||
text: content.x,
|
||||
},
|
||||
y: {
|
||||
...whichScaleObj.y,
|
||||
title: {
|
||||
...whichScaleObj.y.title,
|
||||
text: content.y
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
y: {
|
||||
...whichScaleObj.y,
|
||||
title: {
|
||||
...whichScaleObj.y.title,
|
||||
text: content.y,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -190,7 +197,7 @@ const getLineChartPrimeVueSetting = (chartData, content, pageName) => {
|
||||
|
||||
// Consider the dimension of chartData.data
|
||||
// When handling the Compare page case
|
||||
if(pageName === "Compare"){
|
||||
if (pageName === "Compare") {
|
||||
datasetsPrimary = chartData.data[0].data;
|
||||
datasetsSecondary = chartData.data[1].data;
|
||||
|
||||
@@ -210,9 +217,9 @@ const getLineChartPrimeVueSetting = (chartData, content, pageName) => {
|
||||
tension: 0, // Bezier curve tension
|
||||
borderColor: colorSecondary,
|
||||
pointBackgroundColor: colorSecondary,
|
||||
}
|
||||
},
|
||||
];
|
||||
xData = chartData.data[0].data.map(item => new Date(item.x).getTime());
|
||||
xData = chartData.data[0].data.map((item) => new Date(item.x).getTime());
|
||||
} else {
|
||||
datasets = chartData.data;
|
||||
datasetsArr = [
|
||||
@@ -221,23 +228,25 @@ const getLineChartPrimeVueSetting = (chartData, content, pageName) => {
|
||||
data: datasets,
|
||||
fill: false,
|
||||
tension: 0, // Bezier curve tension
|
||||
borderColor: '#0099FF',
|
||||
}
|
||||
borderColor: "#0099FF",
|
||||
},
|
||||
];
|
||||
xData = chartData.data.map(item => new Date(item.x).getTime());
|
||||
xData = chartData.data.map((item) => new Date(item.x).getTime());
|
||||
}
|
||||
|
||||
|
||||
// Customize X axis ticks due to different differences between min and max of data group
|
||||
// Compare page and Performance page share the same logic
|
||||
const formatToSet = setTimeStringFormatBaseOnTimeDifference(minX, maxX);
|
||||
const ticksOfXAxis = mapTimestampToAxisTicksByFormat(xData, formatToSet);
|
||||
const customizedScaleOption = getCustomizedScaleOption(
|
||||
knownScaleLineChartOptions, {
|
||||
knownScaleLineChartOptions,
|
||||
{
|
||||
customizeOptions: {
|
||||
content, ticksOfXAxis,
|
||||
}
|
||||
});
|
||||
content,
|
||||
ticksOfXAxis,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
primeVueSetData = {
|
||||
labels: xData,
|
||||
@@ -251,20 +260,20 @@ const getLineChartPrimeVueSetting = (chartData, content, pageName) => {
|
||||
top: 16,
|
||||
left: 8,
|
||||
right: 8,
|
||||
}
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
legend: false, // Legend
|
||||
tooltip: {
|
||||
displayColors: true,
|
||||
titleFont: {weight: 'normal'},
|
||||
titleFont: { weight: "normal" },
|
||||
callbacks: {
|
||||
label: function(tooltipItem) {
|
||||
// Get the data
|
||||
const label = tooltipItem.dataset.label || '';
|
||||
label: function (tooltipItem) {
|
||||
// Get the data
|
||||
const label = tooltipItem.dataset.label || "";
|
||||
|
||||
// Build the tooltip label with dataset color indicator
|
||||
return `${label}: ${tooltipItem.parsed.y}`; // Use Unicode block to represent color
|
||||
// Build the tooltip label with dataset color indicator
|
||||
return `${label}: ${tooltipItem.parsed.y}`; // Use Unicode block to represent color
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user