Reputation: 2119
Screenshots below :
Single Pie Chart - No problems
On addition of another chart, there are these data-set loading problems, it shows 5 fields in each chart instead of 3 and 2 respectively
HTML Code (please click Above Link for CSS & JS Code)
<main>
<section>
<div class="pieID pie"></div>
<ul class="pieID legend">
<li><em>Humans</em><span>718</span></li>
<li><em>Dogs</em><span>531</span></li>
<li><em>Cats</em><span>868</span></li>
</ul>
</section>
<!-- Un-commenting Below brings erro in first pie chart, how can i get to charts on same page? Thanks -->
<section>
<div class="pieID pie"></div>
<ul class="pieID legend">
<li><em>Slugs</em><span>344</span></li>
<li><em>Aliens</em><span>1145</span></li>
</ul>
</section>
</main>
Upvotes: 1
Views: 737
Reputation: 141
You're almost right, just remember to use unique identifiers for your elements Add ids for your elements:
<main>
<section>
<div class="pieID pie" id="pie1"></div>
<ul class="pieID legend" id="legend1">
<li><em>Humans</em><span>718</span></li>
<li><em>Dogs</em><span>531</span></li>
<li><em>Cats</em><span>868</span></li>
</ul>
</section>
<section>
<div class="pieID pie" id="pie2"></div>
<ul class="pieID legend" id="legend2">
<li><em>Slugs</em><span>344</span></li>
<li><em>Aliens</em><span>1145</span></li>
</ul>
</section>
</main>
Call the creation function like
createPie("#legend1", "#pie1");
createPie("#legend2", "#pie2");
Upvotes: 2