Anonymous
Показать фон изображения пузырьков chart.js
Сообщение
Anonymous » 18 май 2025, 06:14
Я хочу добавить пузырьковую диаграмму, используя chart.js в свой проект, и я пытаюсь показать фон Image (формат PNG) пузырьков chart.js, как Blow Image, я уже видел эту тему, но не работаю для меня ... Я попробовал этот код и не получил результата. Помогите.
Код: Выделить всё
Users
[list]
[*][url=#][/url]
[*][url=#][/url]
[/list]
if ($('#chart_6').length > 0) {
var BehpardakhtIcon = new Image();
BehpardakhtIcon.src = "~/images/Behpardakht.png";
BehpardakhtIcon.width = 22;
BehpardakhtIcon.height = 22;
var BehsazanIcon = new Image();
BehsazanIcon.src = "~/images/Behsazan.png";
BehsazanIcon.width = 22;
BehsazanIcon.height = 22;
const data = {
datasets: [{
data: [
{ x: 30, y: 50, r: 15 }
],
borderWidth: 2,
pointStyle: BehpardakhtIcon,
label: 'Company1',
hoverBorderWidth: 3,
}],
};
const config = {
type: 'bubble',
data: data,
options: {
scales: {
x: {
title: {
display: true,
text: 'x'
}
},
y: {
title: {
display: true,
text: 'y'
}
},
},
plugins: {
tooltip: { intersect: true },
afterUpdate: function (chart, options) {
chart.getDatasetMeta(0).data.forEach((d, i) => {
d._model.pointStyle = BehpardakhtIcon;
})
}
},
},
};
const myBubbleChart =
new Chart(document.getElementById('chart_6'), config);
}
Также мне нужно знать, где я могу загрузить плагины chart.js и как их использовать?
Подробнее здесь:
https://stackoverflow.com/questions/796 ... js-bubbles
1747538054
Anonymous
Я хочу добавить пузырьковую диаграмму, используя chart.js в свой проект, и я пытаюсь показать фон Image (формат PNG) пузырьков chart.js, как Blow Image, я уже видел эту тему, но не работаю для меня ... Я попробовал этот код и не получил результата. Помогите.[code] Users [list] [*][url=#][/url] [*][url=#][/url] [/list] if ($('#chart_6').length > 0) { var BehpardakhtIcon = new Image(); BehpardakhtIcon.src = "~/images/Behpardakht.png"; BehpardakhtIcon.width = 22; BehpardakhtIcon.height = 22; var BehsazanIcon = new Image(); BehsazanIcon.src = "~/images/Behsazan.png"; BehsazanIcon.width = 22; BehsazanIcon.height = 22; const data = { datasets: [{ data: [ { x: 30, y: 50, r: 15 } ], borderWidth: 2, pointStyle: BehpardakhtIcon, label: 'Company1', hoverBorderWidth: 3, }], }; const config = { type: 'bubble', data: data, options: { scales: { x: { title: { display: true, text: 'x' } }, y: { title: { display: true, text: 'y' } }, }, plugins: { tooltip: { intersect: true }, afterUpdate: function (chart, options) { chart.getDatasetMeta(0).data.forEach((d, i) => { d._model.pointStyle = BehpardakhtIcon; }) } }, }, }; const myBubbleChart = new Chart(document.getElementById('chart_6'), config); } [/code] Также мне нужно знать, где я могу загрузить плагины chart.js и как их использовать? Подробнее здесь: [url]https://stackoverflow.com/questions/79626614/show-image-background-of-chart-js-bubbles[/url]