Anonymous
Цвета всплывающей подсказки ChartJS не отображают правильный цвет
Сообщение
Anonymous » 28 ноя 2024, 19:32
Эта диаграмма создана с помощью ChartJS. До сих пор мне это удавалось, но при добавлении дополнительных данных, например двух строк... Всплывающая подсказка теряет цвета. Я говорю о белых полях слева от значений:
[img]
https://i.sstatic .net/dWRlk.png[/img]
Как видите, здесь 2 строки. Один для заработка и один для депозитов. Депозит находится внизу, а заработок вверху. Почему белый квадрат белый? Она должна быть такой же, как линия?
Вот мой код:
Диаграмма:
Код: Выделить всё
var ctx = document.getElementById('orders_graph').getContext('2d');
var Order_chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line',
// The data for our dataset
data: {
labels: [], // months
datasets: [{
label: 'Fortjenelse',
data: []
}]
},
// Configuration options go here
options:
{
responsive: true,
hover: {
mode: 'index',
intersect: false
},
spanGaps: true,
legend: {
display: false
},
tooltips: {
mode: 'index',
intersect: false,
callbacks: {
label: function(tooltipItem) {
return ' '+tooltipItem.yLabel+' DKK';
}
}
},
layout: {
// padding: { left: 0, right: 0, top: 10, bottom: 30}
},
scales:{
xAxes: [{
display: true //this will remove all the x-axis grid lines
}],
yAxes: [{
display: true, //this will remove all the x-axis grid lines
stacked: false,
ticks: {
beginAtZero: true
},
}],
}
}
});
Передача данных на диаграмму:
Код: Выделить всё
Order_chart.data.labels = order_array_parent_index;
Order_chart.data.datasets = [{
// Fortjenelse med renter
label: 'Profit',
data: order_array_parent,
fill: false,
lineTension: 0,
backgroundColor: [
'rgba(113, 217, 98, 0.2)',
],
borderColor: [
'rgba(113, 217, 98, 1)',
],
},
{
// Deposited amount
label: 'Deposit',
data: order_array_parent_deposits,
fill: false,
lineTension: 0,
backgroundColor: [
'rgba(255, 223, 82, 0.2)',
],
borderColor: [
'rgba(255, 223, 82, 1)',
],
},
]
Order_chart.update();
Есть идеи, как решить эту проблему?
Подробнее здесь:
https://stackoverflow.com/questions/615 ... rect-color
1732811563
Anonymous
Эта диаграмма создана с помощью ChartJS. До сих пор мне это удавалось, но при добавлении дополнительных данных, например двух строк... Всплывающая подсказка теряет цвета. Я говорю о белых полях слева от значений: [img]https://i.sstatic .net/dWRlk.png[/img] Как видите, здесь 2 строки. Один для заработка и один для депозитов. Депозит находится внизу, а заработок вверху. Почему белый квадрат белый? Она должна быть такой же, как линия? Вот мой код: Диаграмма: [code]var ctx = document.getElementById('orders_graph').getContext('2d'); var Order_chart = new Chart(ctx, { // The type of chart we want to create type: 'line', // The data for our dataset data: { labels: [], // months datasets: [{ label: 'Fortjenelse', data: [] }] }, // Configuration options go here options: { responsive: true, hover: { mode: 'index', intersect: false }, spanGaps: true, legend: { display: false }, tooltips: { mode: 'index', intersect: false, callbacks: { label: function(tooltipItem) { return ' '+tooltipItem.yLabel+' DKK'; } } }, layout: { // padding: { left: 0, right: 0, top: 10, bottom: 30} }, scales:{ xAxes: [{ display: true //this will remove all the x-axis grid lines }], yAxes: [{ display: true, //this will remove all the x-axis grid lines stacked: false, ticks: { beginAtZero: true }, }], } } }); [/code] Передача данных на диаграмму: [code]Order_chart.data.labels = order_array_parent_index; Order_chart.data.datasets = [{ // Fortjenelse med renter label: 'Profit', data: order_array_parent, fill: false, lineTension: 0, backgroundColor: [ 'rgba(113, 217, 98, 0.2)', ], borderColor: [ 'rgba(113, 217, 98, 1)', ], }, { // Deposited amount label: 'Deposit', data: order_array_parent_deposits, fill: false, lineTension: 0, backgroundColor: [ 'rgba(255, 223, 82, 0.2)', ], borderColor: [ 'rgba(255, 223, 82, 1)', ], }, ] Order_chart.update(); [/code] Есть идеи, как решить эту проблему? Подробнее здесь: [url]https://stackoverflow.com/questions/61516968/chartjs-hover-tooltip-colors-not-showing-their-correct-color[/url]