Export as HTML5 JScript

TeeChart for JavaScript for the HTML5 Canvas
Post Reply
Menant.D
Newbie
Newbie
Posts: 19
Joined: Mon Jun 06, 2016 12:00 am

Export as HTML5 JScript

Post by Menant.D » Tue Sep 13, 2016 8:21 am

Hi,
I've a problem to export from VCL to HTML JScript.
When I don't use automatique increment, the labels of Bottom Axis are not visible.
You can find the application in attachement.
Is there a common code between VCL Export HTML5 JSCript and JSCript component?
Attachments
ExportHtml5.zip
(53.1 KiB) Downloaded 959 times

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Export as HTML5 JScript

Post by Yeray » Wed Sep 14, 2016 10:38 am

Hello,

I could reproduce the problem, so I added a ticket in the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1630

I also fixed it for the next maintenance release.
Since you own the sources, you can apply the fix by changing the following lines in the EmitAxis method in TeeJavaScript.pas:

Code: Select all

    procedure EmitAxis(Tag:String; const Axis:TChartAxis);
//...

    begin
      if not TChartAccess(Chart).CalcIsAxisVisible(Axis) then
         Exit;

      if Minify then NewLocalVar(Tag);

      if not TChartAccess(Chart).CalcIsAxisVisible(Axis) then
         AddScript(Tag+'.visible='+ToBool(False)+';');

      if Axis.Inverted then
         AddScript(Tag+'.inverted='+ToBool(True)+';');

      if Axis.Logarithmic then
         AddScript(Tag+'.log='+ToBool(True)+';');

      if Axis.Increment<>0 then
         AddScript(Tag+'.increment='+FloatToStr(Axis.Increment)+';');
For these:

Code: Select all

    procedure EmitAxis(Tag:String; const Axis:TChartAxis);
//...
    var tmpS: string;
    begin
      if not TChartAccess(Chart).CalcIsAxisVisible(Axis) then
         Exit;

      if Minify then NewLocalVar(Tag);

      if not TChartAccess(Chart).CalcIsAxisVisible(Axis) then
         AddScript(Tag+'.visible='+ToBool(False)+';');

      if Axis.Inverted then
         AddScript(Tag+'.inverted='+ToBool(True)+';');

      if Axis.Logarithmic then
         AddScript(Tag+'.log='+ToBool(True)+';');

      if Axis.Increment<>0 then
         if Axis.IsDateTime then
            AddScript(Tag+'.increment='+FloatToStr(86400000*Axis.Increment)+';')
         else
            AddScript(Tag+'.increment='+FloatToStr(Axis.Increment)+';');

      if Axis.IsDateTime then
      begin
        tmpS:=LowerCase(Axis.DateTimeFormat);
        tmpS:=StringReplace(tmpS, 'n', 'M', [rfReplaceAll]);
        AddScript(Tag+'.labels.dateFormat="'+tmpS+'";');
      end;
Also note in your bottom axis I see you've set DateTimeFormat as 'dd/MM/yyyy HH:MM' but the character to represent minutes is "n" in delphi, while "m" is used for months (reference here). So I'd change it for this:

Code: Select all

  Chart1.Axes.Bottom.DateTimeFormat:='dd/MM/yyyy HH:nn';
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Menant.D
Newbie
Newbie
Posts: 19
Joined: Mon Jun 06, 2016 12:00 am

Re: Export as HTML5 JScript

Post by Menant.D » Wed Sep 14, 2016 7:03 pm

Hi,

thank you very much for the patch!
It works better now!

Would-it possible like in vcl chart to limit automaticaly the number of legend displayed?
Attachments
ChartWeb.png
ChartWeb.png (43.18 KiB) Viewed 15723 times
ChartVcl.png
ChartVcl.png (13.84 KiB) Viewed 15724 times

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Export as HTML5 JScript

Post by Yeray » Thu Sep 15, 2016 7:51 am

Hello,
Menant.D wrote:Would-it possible like in vcl chart to limit automaticaly the number of legend displayed?
This seems to be the bottom axis labels, not the legend.
There may be some difference on how both versions handle the increment in the axis. Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Menant.D
Newbie
Newbie
Posts: 19
Joined: Mon Jun 06, 2016 12:00 am

Re: Export as HTML5 JScript

Post by Menant.D » Thu Sep 15, 2016 1:48 pm

You're right, it concern labels of bottom Axe.
The difference is where we put an increment(one day for example) in automatic increment.
You can see it in the project join.
Attachments
ExportHtml5_2.zip
(56.84 KiB) Downloaded 936 times

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Export as HTML5 JScript

Post by Yeray » Fri Sep 16, 2016 8:55 am

Hello,

This is because the increment property in TeeChart HTML5 is a bit different than in TeeChart VCL.
I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1632
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply