Not able to display div inside bootstrap Modal












0















I have bootstrap 4 modal and inside the Modal body, trying to display a containing a bar chart. Below is the code



<!-- Modal body -->
<div class="modal-body">
Modal body..
<!--Markup to display graph-->
<div id="chart1" style="margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div


when I am keeping "chart1" outside of Modal body, I can see chart displayed whereas same is not happening when its inside body of Modal. Modal is displayed on click of a below button



<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px;  margin-top:20px; display:none" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" onclick="BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd'])">Analyze & Predict</button>


What's wrong with above code?



Tried to add code in fiddle
http://jsfiddle.net/r2sd5b0y/










share|improve this question

























  • can you show your fiddle.

    – Negi Rox
    Nov 26 '18 at 6:22











  • @NegiRox I will make one and show. what portion of code are you looking for?

    – RAM
    Nov 26 '18 at 6:23













  • @RAM I'm pretty sure you asked this yesterday also, and as I said yesterday, You have to provide us with a working example of the problem you are facing.

    – Carsten Løvbo Andersen
    Nov 26 '18 at 6:29











  • Try to initialize BarChart after modal open

    – Nidhi
    Nov 26 '18 at 6:45











  • @Nidhi How to do that? Do we have an event for Modal open..Thanks

    – RAM
    Nov 26 '18 at 8:11
















0















I have bootstrap 4 modal and inside the Modal body, trying to display a containing a bar chart. Below is the code



<!-- Modal body -->
<div class="modal-body">
Modal body..
<!--Markup to display graph-->
<div id="chart1" style="margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div


when I am keeping "chart1" outside of Modal body, I can see chart displayed whereas same is not happening when its inside body of Modal. Modal is displayed on click of a below button



<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px;  margin-top:20px; display:none" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" onclick="BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd'])">Analyze & Predict</button>


What's wrong with above code?



Tried to add code in fiddle
http://jsfiddle.net/r2sd5b0y/










share|improve this question

























  • can you show your fiddle.

    – Negi Rox
    Nov 26 '18 at 6:22











  • @NegiRox I will make one and show. what portion of code are you looking for?

    – RAM
    Nov 26 '18 at 6:23













  • @RAM I'm pretty sure you asked this yesterday also, and as I said yesterday, You have to provide us with a working example of the problem you are facing.

    – Carsten Løvbo Andersen
    Nov 26 '18 at 6:29











  • Try to initialize BarChart after modal open

    – Nidhi
    Nov 26 '18 at 6:45











  • @Nidhi How to do that? Do we have an event for Modal open..Thanks

    – RAM
    Nov 26 '18 at 8:11














0












0








0








I have bootstrap 4 modal and inside the Modal body, trying to display a containing a bar chart. Below is the code



<!-- Modal body -->
<div class="modal-body">
Modal body..
<!--Markup to display graph-->
<div id="chart1" style="margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div


when I am keeping "chart1" outside of Modal body, I can see chart displayed whereas same is not happening when its inside body of Modal. Modal is displayed on click of a below button



<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px;  margin-top:20px; display:none" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" onclick="BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd'])">Analyze & Predict</button>


What's wrong with above code?



Tried to add code in fiddle
http://jsfiddle.net/r2sd5b0y/










share|improve this question
















I have bootstrap 4 modal and inside the Modal body, trying to display a containing a bar chart. Below is the code



<!-- Modal body -->
<div class="modal-body">
Modal body..
<!--Markup to display graph-->
<div id="chart1" style="margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div


when I am keeping "chart1" outside of Modal body, I can see chart displayed whereas same is not happening when its inside body of Modal. Modal is displayed on click of a below button



<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px;  margin-top:20px; display:none" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" onclick="BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd'])">Analyze & Predict</button>


What's wrong with above code?



Tried to add code in fiddle
http://jsfiddle.net/r2sd5b0y/







javascript jquery html twitter-bootstrap bootstrap-modal






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 9:21







RAM

















asked Nov 26 '18 at 6:19









RAMRAM

256




256













  • can you show your fiddle.

    – Negi Rox
    Nov 26 '18 at 6:22











  • @NegiRox I will make one and show. what portion of code are you looking for?

    – RAM
    Nov 26 '18 at 6:23













  • @RAM I'm pretty sure you asked this yesterday also, and as I said yesterday, You have to provide us with a working example of the problem you are facing.

    – Carsten Løvbo Andersen
    Nov 26 '18 at 6:29











  • Try to initialize BarChart after modal open

    – Nidhi
    Nov 26 '18 at 6:45











  • @Nidhi How to do that? Do we have an event for Modal open..Thanks

    – RAM
    Nov 26 '18 at 8:11



















  • can you show your fiddle.

    – Negi Rox
    Nov 26 '18 at 6:22











  • @NegiRox I will make one and show. what portion of code are you looking for?

    – RAM
    Nov 26 '18 at 6:23













  • @RAM I'm pretty sure you asked this yesterday also, and as I said yesterday, You have to provide us with a working example of the problem you are facing.

    – Carsten Løvbo Andersen
    Nov 26 '18 at 6:29











  • Try to initialize BarChart after modal open

    – Nidhi
    Nov 26 '18 at 6:45











  • @Nidhi How to do that? Do we have an event for Modal open..Thanks

    – RAM
    Nov 26 '18 at 8:11

















can you show your fiddle.

– Negi Rox
Nov 26 '18 at 6:22





can you show your fiddle.

– Negi Rox
Nov 26 '18 at 6:22













@NegiRox I will make one and show. what portion of code are you looking for?

– RAM
Nov 26 '18 at 6:23







@NegiRox I will make one and show. what portion of code are you looking for?

– RAM
Nov 26 '18 at 6:23















@RAM I'm pretty sure you asked this yesterday also, and as I said yesterday, You have to provide us with a working example of the problem you are facing.

– Carsten Løvbo Andersen
Nov 26 '18 at 6:29





@RAM I'm pretty sure you asked this yesterday also, and as I said yesterday, You have to provide us with a working example of the problem you are facing.

– Carsten Løvbo Andersen
Nov 26 '18 at 6:29













Try to initialize BarChart after modal open

– Nidhi
Nov 26 '18 at 6:45





Try to initialize BarChart after modal open

– Nidhi
Nov 26 '18 at 6:45













@Nidhi How to do that? Do we have an event for Modal open..Thanks

– RAM
Nov 26 '18 at 8:11





@Nidhi How to do that? Do we have an event for Modal open..Thanks

– RAM
Nov 26 '18 at 8:11












1 Answer
1






active

oldest

votes


















1














I have removed onClick from a button and call BarChartAjax on shown.bs.modal in js



$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})


Here chart displayed when modal open but I think there is some issue with an array you passed to BarChartAjax function so that chart is not displaying correctly so check your values you passed to function






function DisplayBarChart(data) {
//debugger;
var array = data.split("-");
var s1 = array[0].split(',').map(function (el) { return +el; });
var ticks = array[1].split(',');
$.jqplot.config.enablePlugins = true;
console.log(s1);
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: { show: true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
highlighter: { show: false }
});

$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info1').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data);
}
);
}

function BarChartAjax(xdata, ydata) {
var dataToSend = JSON.stringify({ 'GraphData': xdata + "-" + ydata });
DisplayBarChart(dataToSend);
}

$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.barRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.categoryAxisRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.pointLabels.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>


<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px; margin-top:20px;" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" >Analyze & Predict</button>


<div class="modal fade" id="graphicalModal">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body" id="graphicalModalBody">
Modal body..
<div id="chart1" style=" margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div>

<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>








share|improve this answer
























  • Perfect. Thanks a ton!!

    – RAM
    Nov 26 '18 at 9:55











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475663%2fnot-able-to-display-div-inside-bootstrap-modal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I have removed onClick from a button and call BarChartAjax on shown.bs.modal in js



$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})


Here chart displayed when modal open but I think there is some issue with an array you passed to BarChartAjax function so that chart is not displaying correctly so check your values you passed to function






function DisplayBarChart(data) {
//debugger;
var array = data.split("-");
var s1 = array[0].split(',').map(function (el) { return +el; });
var ticks = array[1].split(',');
$.jqplot.config.enablePlugins = true;
console.log(s1);
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: { show: true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
highlighter: { show: false }
});

$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info1').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data);
}
);
}

function BarChartAjax(xdata, ydata) {
var dataToSend = JSON.stringify({ 'GraphData': xdata + "-" + ydata });
DisplayBarChart(dataToSend);
}

$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.barRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.categoryAxisRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.pointLabels.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>


<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px; margin-top:20px;" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" >Analyze & Predict</button>


<div class="modal fade" id="graphicalModal">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body" id="graphicalModalBody">
Modal body..
<div id="chart1" style=" margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div>

<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>








share|improve this answer
























  • Perfect. Thanks a ton!!

    – RAM
    Nov 26 '18 at 9:55
















1














I have removed onClick from a button and call BarChartAjax on shown.bs.modal in js



$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})


Here chart displayed when modal open but I think there is some issue with an array you passed to BarChartAjax function so that chart is not displaying correctly so check your values you passed to function






function DisplayBarChart(data) {
//debugger;
var array = data.split("-");
var s1 = array[0].split(',').map(function (el) { return +el; });
var ticks = array[1].split(',');
$.jqplot.config.enablePlugins = true;
console.log(s1);
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: { show: true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
highlighter: { show: false }
});

$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info1').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data);
}
);
}

function BarChartAjax(xdata, ydata) {
var dataToSend = JSON.stringify({ 'GraphData': xdata + "-" + ydata });
DisplayBarChart(dataToSend);
}

$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.barRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.categoryAxisRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.pointLabels.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>


<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px; margin-top:20px;" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" >Analyze & Predict</button>


<div class="modal fade" id="graphicalModal">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body" id="graphicalModalBody">
Modal body..
<div id="chart1" style=" margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div>

<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>








share|improve this answer
























  • Perfect. Thanks a ton!!

    – RAM
    Nov 26 '18 at 9:55














1












1








1







I have removed onClick from a button and call BarChartAjax on shown.bs.modal in js



$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})


Here chart displayed when modal open but I think there is some issue with an array you passed to BarChartAjax function so that chart is not displaying correctly so check your values you passed to function






function DisplayBarChart(data) {
//debugger;
var array = data.split("-");
var s1 = array[0].split(',').map(function (el) { return +el; });
var ticks = array[1].split(',');
$.jqplot.config.enablePlugins = true;
console.log(s1);
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: { show: true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
highlighter: { show: false }
});

$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info1').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data);
}
);
}

function BarChartAjax(xdata, ydata) {
var dataToSend = JSON.stringify({ 'GraphData': xdata + "-" + ydata });
DisplayBarChart(dataToSend);
}

$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.barRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.categoryAxisRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.pointLabels.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>


<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px; margin-top:20px;" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" >Analyze & Predict</button>


<div class="modal fade" id="graphicalModal">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body" id="graphicalModalBody">
Modal body..
<div id="chart1" style=" margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div>

<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>








share|improve this answer













I have removed onClick from a button and call BarChartAjax on shown.bs.modal in js



$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})


Here chart displayed when modal open but I think there is some issue with an array you passed to BarChartAjax function so that chart is not displaying correctly so check your values you passed to function






function DisplayBarChart(data) {
//debugger;
var array = data.split("-");
var s1 = array[0].split(',').map(function (el) { return +el; });
var ticks = array[1].split(',');
$.jqplot.config.enablePlugins = true;
console.log(s1);
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: { show: true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
highlighter: { show: false }
});

$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info1').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data);
}
);
}

function BarChartAjax(xdata, ydata) {
var dataToSend = JSON.stringify({ 'GraphData': xdata + "-" + ydata });
DisplayBarChart(dataToSend);
}

$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.barRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.categoryAxisRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.pointLabels.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>


<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px; margin-top:20px;" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" >Analyze & Predict</button>


<div class="modal fade" id="graphicalModal">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body" id="graphicalModalBody">
Modal body..
<div id="chart1" style=" margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div>

<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>








function DisplayBarChart(data) {
//debugger;
var array = data.split("-");
var s1 = array[0].split(',').map(function (el) { return +el; });
var ticks = array[1].split(',');
$.jqplot.config.enablePlugins = true;
console.log(s1);
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: { show: true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
highlighter: { show: false }
});

$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info1').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data);
}
);
}

function BarChartAjax(xdata, ydata) {
var dataToSend = JSON.stringify({ 'GraphData': xdata + "-" + ydata });
DisplayBarChart(dataToSend);
}

$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.barRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.categoryAxisRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.pointLabels.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>


<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px; margin-top:20px;" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" >Analyze & Predict</button>


<div class="modal fade" id="graphicalModal">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body" id="graphicalModalBody">
Modal body..
<div id="chart1" style=" margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div>

<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>





function DisplayBarChart(data) {
//debugger;
var array = data.split("-");
var s1 = array[0].split(',').map(function (el) { return +el; });
var ticks = array[1].split(',');
$.jqplot.config.enablePlugins = true;
console.log(s1);
plot1 = $.jqplot('chart1', [s1], {
// Only animate if we're not using excanvas (not in IE 7 or IE 8)..
animate: !$.jqplot.use_excanvas,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: { show: true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks
}
},
highlighter: { show: false }
});

$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#info1').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data);
}
);
}

function BarChartAjax(xdata, ydata) {
var dataToSend = JSON.stringify({ 'GraphData': xdata + "-" + ydata });
DisplayBarChart(dataToSend);
}

$('#graphicalModal').on('shown.bs.modal', function () {
BarChartAjax('2, 4, 5, 6', ['a', 'b', 'c', 'd']);
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.barRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.categoryAxisRenderer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.pointLabels.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>


<button type="submit" class="btn btn-primary mb-2" style=" margin-left:30px; margin-top:20px;" id="analyzeAndPredict" data-toggle="modal" data-target="#graphicalModal" >Analyze & Predict</button>


<div class="modal fade" id="graphicalModal">
<div class="modal-dialog">
<div class="modal-content">

<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- Modal body -->
<div class="modal-body" id="graphicalModalBody">
Modal body..
<div id="chart1" style=" margin-top: 20px; margin-left: 20px; width: 300px; height: 300px;"></div>
</div>

<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 26 '18 at 9:54









NidhiNidhi

1,2381518




1,2381518













  • Perfect. Thanks a ton!!

    – RAM
    Nov 26 '18 at 9:55



















  • Perfect. Thanks a ton!!

    – RAM
    Nov 26 '18 at 9:55

















Perfect. Thanks a ton!!

– RAM
Nov 26 '18 at 9:55





Perfect. Thanks a ton!!

– RAM
Nov 26 '18 at 9:55




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475663%2fnot-able-to-display-div-inside-bootstrap-modal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen