Page 1 of 1

Export as HTML5 JScript

Posted: Tue Sep 13, 2016 8:21 am
by 16578476
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?

Re: Export as HTML5 JScript

Posted: Wed Sep 14, 2016 10:38 am
by yeray
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';

Re: Export as HTML5 JScript

Posted: Wed Sep 14, 2016 7:03 pm
by 16578476
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?

Re: Export as HTML5 JScript

Posted: Thu Sep 15, 2016 7:51 am
by yeray
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.

Re: Export as HTML5 JScript

Posted: Thu Sep 15, 2016 1:48 pm
by 16578476
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.

Re: Export as HTML5 JScript

Posted: Fri Sep 16, 2016 8:55 am
by yeray
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