Я пытаюсь создать модал, используя javascript, но когда я добавляю диаграмму canvasjs внутри этой модальной ширины тела диаграммы холста, это не 100%.
Вы можете видеть то, что я вижу на этом изображении:
![enter image description here](https://i.stack.imgur.com/b7P45.png)
Я использую этот код внутри JavaScript:
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
Я использую этот код для инициализации диаграммы:
let chart = new CanvasJS.Chart("chartContainer1", {
animationEnabled: true,
exportEnabled: true,
title: {
text: "Basic Column Chart in Angular"
},
data: [{
type: "column",
dataPoints: [
{ y: 71, label: "Apple" },
{ y: 55, label: "Mango" },
{ y: 50, label: "Orange" },
{ y: 65, label: "Banana" },
{ y: 95, label: "Pineapple" },
{ y: 68, label: "Pears" },
{ y: 28, label: "Grapes" },
{ y: 34, label: "Lychee" },
{ y: 14, label: "Jackfruit" }
]
}]
});
chart.render();
Я пытаюсь сделать это в JavaScript, я не знаю, что мне нужно делать.Я хотел бы понять, почему это происходит.