Good Afternnon,
Hi, i am new to coding and learning online for home project.
I am using Apexchart for showing data for duration. i made 4 div base on duration data. After selecting the duration from dropdown, i need to hide all div except selected div. I tried using show and hide and its partially working. Say i first i select "Last Month" its shows right div, then i select "Current Month" it hide Last month div and show Current month div. But when i reselect "Last Month" div not shown with chart.
is there is any alternative where i can show div with animation in better way.
Thanks in Advance
code
<div id="totalMilksaleChartfor7days"></div>
<div id="totalMilksaleChartcurrentmonth" style="display:none"></div>
<div id="totalMilksaleChartlastmonth" style="display:none"></div>
<div id="totalMilksaleChart" style="display:none"></div>
var durationget = duration;
if (durationget == "currentmonth") {
$("#totalMilksaleChartcurrentmonth").show();
$("#totalMilksaleChartfor7days").hide();
$("#totalMilksaleChartlastmonth").hide();
$("#totalMilksaleChart").hide();
} else if (durationget == "lastmonth") {
$("#totalMilksaleChartlastmonth").show();
$("#totalMilksaleChartfor7days").hide();
$("#totalMilksaleChartcurrentmonth").hide();
$("#totalMilksaleChart").hide();
} else if (durationget == "currentyear") {
$("#totalMilksaleChart").show();
$("#totalMilksaleChartfor7days").hide();
$("#totalMilksaleChartlastmonth").hide();
$("#totalMilksaleChartcurrentmonth").hide();
} else {
$("#totalMilksaleChartfor7days").show();
$("#totalMilksaleChartlastmonth").hide();
$("#totalMilksaleChartcurrentmonth").hide();
$("#totalMilksaleChart").hide();
}
2
Answers
I cant think why it wouldn’t work, seams simple enough:
ApexCharts provides an API that allows you to update the chart data dynamically.