Atozed Forums
Chart.js + Template - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Chart.js + Template (/thread-2102.html)



Chart.js + Template - matija - 11-06-2020

I use intraweb with a HTML template (Bootstrap).
Does anyone have experience with this component chartjs.org?

How to fill chart.js with label and data?

Something from code:
Code:
datasets: [{
            label: '# Years',
            data: [2020, 2019, 2018],



RE: Chart.js + Template - ioan - 11-06-2020

(11-06-2020, 12:13 PM)matija Wrote: Something from code:
Code:
datasets: [{
            label: '# Years',
            data: [2020, 2019, 2018],


The easiest way is to use TIWTemplateProcessorHTML with OnUnknownTag event.
In your template you replace "data: [2020, 2019, 2018]" with {$_MYDATA_$} for example and then in TIWTemplateProcessorHTML.OnUnknownTag event you do something like:


Code:
procedure TYourForm.IWTemplateProcessorHTML1UnknownTag(const AName: string; var VValue: string);
begin
  if SameText(AName, '_MYDATA_') then
  begin
    VValue := 'data: [2020, 2019, 2018]'; //<-- you get the values from your db here
  end;
end;

Another way would be to use Custom Content Handlers.