|
<< Click to Display Table of Contents >> Navigation: Forum > Chart.js + Template |
11-06-2020, 12:13 PM:
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],
11-06-2020, 05:40 PM:
(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.