修复图表横轴时间标签不完整:用tickLabels替代index取模过滤
This commit is contained in:
@@ -79,7 +79,7 @@ export function DetailMiniTemperatureChart({ detail }: { detail: CityDetail }) {
|
||||
return {
|
||||
data: {
|
||||
datasets,
|
||||
labels: chartData.times,
|
||||
labels: chartData.tickLabels,
|
||||
},
|
||||
options: {
|
||||
interaction: { intersect: false, mode: "index" },
|
||||
@@ -98,13 +98,8 @@ export function DetailMiniTemperatureChart({ detail }: { detail: CityDetail }) {
|
||||
x: {
|
||||
grid: { color: "rgba(255,255,255,0.03)" },
|
||||
ticks: {
|
||||
callback: (value, index) =>
|
||||
typeof index === "number" && index % 4 === 0
|
||||
? String(value)
|
||||
: "",
|
||||
color: "#6B7A90",
|
||||
font: { size: 10 },
|
||||
maxTicksLimit: 6,
|
||||
maxRotation: 0,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -154,7 +154,7 @@ export const AiCityTemperatureChart = memo(function AiCityTemperatureChart({ det
|
||||
return {
|
||||
data: {
|
||||
datasets,
|
||||
labels: chartData.times,
|
||||
labels: chartData.tickLabels,
|
||||
},
|
||||
options: {
|
||||
animation: false,
|
||||
@@ -174,13 +174,8 @@ export const AiCityTemperatureChart = memo(function AiCityTemperatureChart({ det
|
||||
x: {
|
||||
grid: { color: "rgba(159, 178, 199, 0.08)" },
|
||||
ticks: {
|
||||
callback: (value, index) =>
|
||||
typeof index === "number" && index % 3 === 0
|
||||
? String(value)
|
||||
: "",
|
||||
color: "#6B7A90",
|
||||
font: { size: 10 },
|
||||
maxTicksLimit: 8,
|
||||
maxRotation: 0,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user