Chartjs-Meteor with Chart js cannot read property ‘getContext’ of null only AFTER new document in collection?

0👍

After many hours of banging my head against a brick wall, I finally realized that the helper function in the html creating the chart div was the problem.

Right below the html shown above I had:

{{#if chartExists}}
        <div class="chrtDiv">
            <canvas id="twChart" class="img-responsive"></canvas>
        </div>
        {{else}}
            <div>
                <h2> <img src="dunno.png" class="img-responsive" alt=""> No data...</h2>
            </div>
        {{/if}}

The “chartExists” helper was just checking to see if there was any Results documents available via the find() filters “season” and “slate”. I tried to be cute there by showing a gif in the event there was no data for the chart. not sure why exactly… I tried setting a session var with the resulting dataset used to populate the chart and have the helper check for that, but that didn’t work either.

I also put the canvas in the “else” section of the html but that also failed. Somehow that helper won’t let that canvas render…

Leave a comment