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