<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Chart.js - difficulty populating arrays from dataset]]></title><description><![CDATA[<p>Hi all ... I am trying to use chart.js in my report and am having difficulty populating the arrays for labels and data.  Additionally, when I hard-code the arrays the chart runs, but not to completion.</p>
<p>I thought I could just use a handlebars <code>#each</code> statement to populate the arrays, but that doesn't appear to be the case, and examples of how to do this are sparse and don't appear to fit my use case, which is primarily doing this in the designer so I can just call the render from node.  Seems a lot of examples are doing things like calling <code>handlebars.compile</code> and using JQuery ... not necessarily the solution I'm after unless it's the ONLY one.</p>
<p>Here's a snippet of my code between the script tags</p>
<pre><code class="language-//">        let customersArr = [];
//        let customersDataArr = [51, 325402, 524, 23565];
        let customersDataArr = [];
        {{#each smsMain.data}}
            customersArr.push({{this.company}});
            customersDataArr.push({{this.deliveredCount}})
        {{/each}}

        new Chart(&quot;CustomerSummary&quot;, {
            type: &quot;bar&quot;,
            data: {
</code></pre>
<p>Here is a link to my playground example - <a href="https://playground.jsreport.net/w/dqueubed/vkEiLVmu" rel="nofollow">https://playground.jsreport.net/w/dqueubed/vkEiLVmu</a></p>
<p>As always, thanks for much for your assist!</p>
<pre><code> - Roger</code></pre>
]]></description><link>https://forum.jsreport.net/topic/2818/chart-js-difficulty-populating-arrays-from-dataset</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 13:09:59 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/2818.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Jun 2023 18:34:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Chart.js - difficulty populating arrays from dataset on Invalid Date]]></title><description><![CDATA[<p>Hi all ... I am trying to use chart.js in my report and am having difficulty populating the arrays for labels and data.  Additionally, when I hard-code the arrays the chart runs, but not to completion.</p>
<p>I thought I could just use a handlebars <code>#each</code> statement to populate the arrays, but that doesn't appear to be the case, and examples of how to do this are sparse and don't appear to fit my use case, which is primarily doing this in the designer so I can just call the render from node.  Seems a lot of examples are doing things like calling <code>handlebars.compile</code> and using JQuery ... not necessarily the solution I'm after unless it's the ONLY one.</p>
<p>Here's a snippet of my code between the script tags</p>
<pre><code class="language-//">        let customersArr = [];
//        let customersDataArr = [51, 325402, 524, 23565];
        let customersDataArr = [];
        {{#each smsMain.data}}
            customersArr.push({{this.company}});
            customersDataArr.push({{this.deliveredCount}})
        {{/each}}

        new Chart(&quot;CustomerSummary&quot;, {
            type: &quot;bar&quot;,
            data: {
</code></pre>
<p>Here is a link to my playground example - <a href="https://playground.jsreport.net/w/dqueubed/vkEiLVmu" rel="nofollow">https://playground.jsreport.net/w/dqueubed/vkEiLVmu</a></p>
<p>As always, thanks for much for your assist!</p>
<pre><code> - Roger</code></pre>
]]></description><link>https://forum.jsreport.net/post/12186</link><guid isPermaLink="true">https://forum.jsreport.net/post/12186</guid><dc:creator><![CDATA[dqueubed]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Chart.js - difficulty populating arrays from dataset on Invalid Date]]></title><description><![CDATA[<p>This problem can be solved using jsreport <code>toJS</code> helper.<br />
<a href="https://jsreport.net/learn/templating-engines#tojs-data-" rel="nofollow">https://jsreport.net/learn/templating-engines#tojs-data-</a></p>
<p>The same problem described here<br />
<a href="https://forum.jsreport.net/topic/2590/chart-js-in-pdf-file/2">https://forum.jsreport.net/topic/2590/chart-js-in-pdf-file/2</a><br />
<a href="https://jsreport.net/blog/using-input-data-in-html-page-inline-javascript" rel="nofollow">https://jsreport.net/blog/using-input-data-in-html-page-inline-javascript</a></p>
]]></description><link>https://forum.jsreport.net/post/12187</link><guid isPermaLink="true">https://forum.jsreport.net/post/12187</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Chart.js - difficulty populating arrays from dataset on Invalid Date]]></title><description><![CDATA[<p>Thanks <a class="plugin-mentions-a" href="https://forum.jsreport.net/uid/2">@jan_blaha</a>  ... I'll pour over these and see what I can find.  Always much appreciated :-)</p>
]]></description><link>https://forum.jsreport.net/post/12189</link><guid isPermaLink="true">https://forum.jsreport.net/post/12189</guid><dc:creator><![CDATA[dqueubed]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Chart.js - difficulty populating arrays from dataset on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="https://forum.jsreport.net/uid/2">@jan_blaha</a>  ... just a quick follow up, this worked great</p>
<pre><code>        let customersArr = [{{#each smsMain.data}}&quot;{{this.company}}&quot;,{{/each}}];
        let customersDataArr = [{{#each smsMain.data}}{{this.deliveredCount}},{{/each}}];
</code></pre>
<p>As you can see, for the string array I had to force quotation marks and commas, but after that, everything worked great!</p>
<p><img src="/uploads/files/1686150620763-upload-f8dfbe40-4a99-4cd2-bc82-2623f497ba27-resized.png" alt="0_1686150619460_upload-f8dfbe40-4a99-4cd2-bc82-2623f497ba27" class="img-responsive img-markdown" /></p>
<p>As always, you guys are right on the money with your solutions.  Can't thank you guys enough, and I'm certain I'll have more.  :-)</p>
]]></description><link>https://forum.jsreport.net/post/12193</link><guid isPermaLink="true">https://forum.jsreport.net/post/12193</guid><dc:creator><![CDATA[dqueubed]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Chart.js - difficulty populating arrays from dataset on Invalid Date]]></title><description><![CDATA[<blockquote>
<p>As you can see, for the string array I had to force quotation marks and commas, but after that, everything worked great!</p>
</blockquote>
<p>There are some string chars that can break your code. Therefore <code>toJS</code> helper is recommended.</p>
<blockquote>
<p>As always, you guys are right on the money with your solutions. Can't thank you guys enough, and I'm certain I'll have more. :-)</p>
</blockquote>
<p>You are more than welcome.</p>
]]></description><link>https://forum.jsreport.net/post/12194</link><guid isPermaLink="true">https://forum.jsreport.net/post/12194</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>