my element bootstrap is kura_s and my modal body :
<div class="modal-body">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div id="line-chart" style="height: 300px;width:700px;">
</div>
</div>
</div>
</div>
js
$('#kurva_s').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
// Button that triggered the modal
var id_spk = button.data('whatever');
$(function () {
$('#line-chart').empty();
var data = [
{"m":"2022-01-15","r":0,"p":13.33},
{"m":"2022-01-22","r":10,"p":60},
{"m":"2022-01-29","r":15,"p":100},
{"m":"2022-02-05","r":35,"p":100},
{"m":"2022-02-12","r":50,"p":100},
{"m":"2022-02-19","r":55,"p":100}
];
var chart = Morris.Line({
element: 'line-chart',
data: data, // Set initial data (ideally you would provide an array of default data)
xkey: 'm', // Set the key for X-axis
ykeys: ['r','p'], // Set the key for Y-axis
labels: ['Real','Plan'], // Set the label when bar is rolled over
stacked: true,
barGap:10,
barSizeRatio:1,
});
});
});
like the image that I pinned, morris jus can't be full even though I have set the width manually. Has anyone experienced like me. ?
Going with the example fiddle you posted in the comments, it would appear that the problem occurs when initializing the graph before the modal is open. If you were to change your logic a bit, and initialize the graph on modal opening, the problem would be solved.
Please see the following reworking of your example fiddle.
This is the key part.
This tells your graph to:
This will also allow you to work with dynamic data (if you ever encounter a need for that) - if your data comes from an API call, for example, or you're getting it from an AJAX call to your backend, or the data needs to be graphed based on what was selected before opening the modal, etc.