切换到深色模式时,如何在图表的浅色模式下更改线条 colored颜色 ?你能帮我做这个吗?
Here are the colors I use now:
This is how I need to change colors when I switch to dark mode:
我的chartjs图表位于下面的codepen链接中:
// bar chart start
var chartData = {
labels: ['Ocak', 'Şubat','Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],
datasets: [{
label: "Yatırımlar",
backgroundColor: "#1355FF",
borderWidth: 0,
borderRadius: 5,
data: [20423,40123,60313,80412,40414,1932,40131,10124,30578,50421,60124,14512]
}, {
label: "Çekimler",
backgroundColor: "#57D3DD",
borderRadius: 5,
borderWidth: 0,
data: [60732,30125,20712,50252,30689,50234,20464,30123,10245,15123,40126,60126]
},
]
};
let value = 80000;
var ctx = document.getElementById('barChart');
var myBarChart = new Chart(ctx, {
type: "bar",
data: chartData,
drawBorder:false,
options: {
responsive:true,
maintainAspectRatio: false,
scales: {
x: {
title: {
display: false
},
grid: {
display:false
},
ticks: {
color: "#718096"
}
},
y: {
title: {
display: false
},
min: 0,
max: 80000,
ticks: {
stepSize: 20000,
color: "#718096",
callback: function(value, index, values) {
return value * 0.001 + " K";
}
},
grid: {
color: '#EDF2F7'
}
}
},
plugins: {
legend: {
position:"top",
labels: {
font: {
size: 12,
weight: 500
},
color: "#2D3748",
boxWidth: 8,
boxHeight:8,
usePointStyle: true,
pointStyle: "circle"
}
}
}
}
});
// bar chart end
.container {
max-width:1200px;
width:100%;
margin:0 auto;
}
<div class="container">
<canvas id="barChart" width="400" height="240"></canvas>
</div>
<input type="checkbox" name="chartChange" id="chartChange">
<label for="chartChange">Click to change chart color text</label>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>