Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
133
rated 0 times [  139] [ 6]  / answers: 1 / hits: 9946  / 10 Years ago, tue, july 29, 2014, 12:00:00

Initially I put all AmChart configs in AmCharts.ready is everything worked fine.



<script src=amcharts/amcharts.js type=text/javascript></script>
<script src=amcharts/serial.js type=text/javascript></script>
<script>
AmCharts.ready(function() {
console.log(this works);
/* Other configs */
})
</script>


Somehow it stops working when I introduce RequireJS as instructed in amCharts meets requireJS. Whatever code inside AmChart.ready's callback will not be executed. (Oddly it was executed one time during the debugging)


More From » requirejs

 Answers
4

After a few tests I realized AmChart.ready only pushes the callback into the onReadyArray which is later popped for execution after the window.load/onload event. In other words, if AmChart is loaded after window.onload event, AmChart.ready is useless. My workaround is as followed:



<script>
configChart = function() {
/* Create charts stuff */
};
if (AmCharts.isReady) {
configChart();
} else {
AmCharts.ready(configChart);
}
</script>

[#43519] Monday, July 28, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
agustindejonm

Total Points: 738
Total Questions: 84
Total Answers: 84

Location: Northern Ireland
Member since Mon, Nov 14, 2022
2 Years ago
agustindejonm questions
Fri, Jun 25, 21, 00:00, 3 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
Sat, May 16, 20, 00:00, 4 Years ago
;