Believe in yourself
To display two Morris charts in separate div elements, you can stack them on top of each other and make the top div's background-color transparent.
<div class="row">
<div class="col-sm-12">
<div id="ContractorChart" style="z-index:0;position:fixed;width:80%;height:60vh">
</div>
<div id="ContractorChart2" style="z-index:100;position:fixed;background-color:transparent;width:80%;height:60vh"> </div>
</div>
</div>
Scrip Code for Morris Chart
ChartShowLine();
ChartShowBar();
function ChartShowLine() {
$("#FirstElement").empty();
$(function () {
new Morris.Line({
element: 'FirstElement',
parseTime: false,
lineWidth: 4,
trendLine: false,
pointSize: 2,
xLabelAngle: 90,
dataLabels: false,
resize: true,
data: [
@foreach (var item in Model.ToList())
{
@*@:{ Week: "@(Convert.ToInt32(item.ContractorsWeek.Replace('W',' ')))", Plan_Cu: "@(item.Plan_Cu)", Plan_We: "@(item.Plan_We)", Prog_Cu: "@(item.Prog_Cu)", Prog_We: "@(item.Prog_We)" },*@
@:{ Week: "@(Convert.ToInt32(item.ContractorsWeek.Replace('W',' ')))", Plan_Cu: "@(Math.Round(item.Plan_Cu.Value,2))", Prog_Cu: "@(Math.Round(item.Prog_Cu.Value,2))" },
}
],
xkey: ['Week'],
ykeys: ['Plan_Cu', 'Prog_Cu'],
labels: [['Prog_Cu'], ['Plan_Cu']]
});
});
}
function ChartShowBar() {
$("#SecondElement").empty();
$(function () {
new Morris.Bar({
element: 'SecondElement',
parseTime: false,
lineWidth: 4,
trendLine: false,
pointSize: 2,
xLabelAngle: 90,
axes: false,
grid:false,
dataLabels: false,
resize: true,
data: [
@foreach (var item in Model.ToList())
{
@*@:{ Week: "@(Convert.ToInt32(item.ContractorsWeek.Replace('W',' ')))", Plan_Cu: "@(item.Plan_Cu)", Plan_We: "@(item.Plan_We)", Prog_Cu: "@(item.Prog_Cu)", Prog_We: "@(item.Prog_We)" },*@
@:{ Week: "@(Convert.ToInt32(item.ContractorsWeek.Replace('W',' ')))", Plan_We: "@(Math.Round(item.Plan_We.Value,2))", Prog_We: "@(Math.Round(item.Prog_We.Value,2))" },
}
],
xkey: ['Week'],
ykeys: ['Plan_We', 'Prog_We'],
labels: [['Prog_We'], ['Plan_We']]
});
});
}
</script>