Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Chart.js + Template
#1
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],
Reply
#2
(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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)