Chart.draw(); gives error d.toFixed is not a function?

TeeChart for JavaScript for the HTML5 Canvas
Post Reply
sct
Newbie
Newbie
Posts: 31
Joined: Tue Aug 06, 2013 12:00 am

Chart.draw(); gives error d.toFixed is not a function?

Post by sct » Fri Jul 11, 2014 1:35 pm

I have some code that worked with steema some time last year and I just updated to the saltest. Going through the code to make sure all is in order and ran in to this error. Here is my code leading up to the error. The very last line causes the error.

Code: Select all

         this.UIDiv.removeChild( this.canvas );
         this.canvas = document.createElement( 'canvas' );
         this.canvas.id = "canvas" + this.id;
         this.canvas.width = this.canvasData_width;
         this.canvas.height = this.canvasData_height;
         this.canvas.style.zIndex = this.canvasData_zIndex;
        // this.canvas.style.background = "#ffffff"
         this.UIDiv.appendChild( this.canvas );
         this.Chart1 = new Tee.Chart( "canvas" + this.id );

         this.annot = new Tee.Annotation( this.Chart1 );
         this.annot.position.x = 15;
         this.annot.position.y = 20;
         var anno = this.annot
         this.annot.mousemove = function () { this.text = ""; }

         if ( this.type == "Function" ) this.addData( this.Xdata, this.Ydata, .5, "ellipse" );
         else if ( this.type == "Table" )
         {
             for ( z = 0; z < this.Zdata.length;z++ )
             {
                 this.addData( this.Ydata, this.Zdata[z], .5, "ellipse" );
             }
         }
         //this.Chart1.legend.textStyle = "values"
         //this.Chart1.legend.legend_textstyle = "label"

         this.Chart1.tools.add( this.annot );
         this.Chart1.title.text = ""; 
         this.Chart1.axes.left.title.text = this.labelY; 
         this.Chart1.axes.bottom.title.text = this.labelX; 
         this.Chart1.tools.add( new Tee.DragTool( this.Chart1 ) ); alert( 5 )
         this.Chart1.draw();

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

Re: Chart.draw(); gives error d.toFixed is not a function?

Post by Yeray » Fri Jul 11, 2014 3:30 pm

Hello,

Could you please arrange a simple example we can run as-is to reproduce the problem here?
To attach an htm file you may have to zip it before.

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

sct
Newbie
Newbie
Posts: 31
Joined: Tue Aug 06, 2013 12:00 am

Re: Chart.draw(); gives error d.toFixed is not a function?

Post by sct » Fri Jul 11, 2014 4:12 pm

this seems to do it.
Attachments
point.zip
(1.75 KiB) Downloaded 947 times

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

Re: Chart.draw(); gives error d.toFixed is not a function?

Post by Yeray » Mon Jul 14, 2014 11:11 am

Hello,

It seems to crash because it expects the data to be doubles, not strings, when executing this line with d being the first value in the series "0":

Code: Select all

return d.toFixed(0);
I'm trying to identify what change in the sources affected this. Can you tell us in what version did that example work fine?
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

sct
Newbie
Newbie
Posts: 31
Joined: Tue Aug 06, 2013 12:00 am

Re: Chart.draw(); gives error d.toFixed is not a function?

Post by sct » Mon Jul 14, 2014 12:53 pm

could have something to do with this
(see number 2) "how to use an array without eval'ing it? "
http://www.teechart.net/support/viewtop ... 18&t=14255
I had issues with that before.

This is what I found in the read me
Release Notes 14th December 2012
TeeChart for JavaScript v1.4
Sourcecode version 2012.12.14.1.4

sct
Newbie
Newbie
Posts: 31
Joined: Tue Aug 06, 2013 12:00 am

Re: Chart.draw(); gives error d.toFixed is not a function?

Post by sct » Mon Jul 14, 2014 1:01 pm

I made it work with
this.addData( eval( "["+Xdata +"]"), eval( "["+Ydata+"]" ), .5, "ellipse" );
but not I get this error.
TypeError: text.split is not a function

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

Re: Chart.draw(); gives error d.toFixed is not a function?

Post by Yeray » Tue Jul 15, 2014 11:13 am

Hello,

If the input data is going to be in that format, what about calling addData without changing any type and doing the job inside it?
Ie:

Code: Select all

addData( Xdata, Ydata, .5, "ellipse" );

Code: Select all

         dat.data.values = eval("["+ydata+"]");
         dat.data.x = eval("["+xdata+"]");
         dat.data.labels = xdata;
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

sct
Newbie
Newbie
Posts: 31
Joined: Tue Aug 06, 2013 12:00 am

Re: Chart.draw(); gives error d.toFixed is not a function?

Post by sct » Tue Jul 15, 2014 12:46 pm

This works, will this be the best practices or would the API accept text at some point?

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

Re: Chart.draw(); gives error d.toFixed is not a function?

Post by Yeray » Tue Jul 15, 2014 3:17 pm

Hello,

I've added it to the wish list to be further investigated if we can implement some extra code to handle this situation:
http://bugs.teechart.net/show_bug.cgi?id=848

But in the meanwhile I'd consider the developer is the responsible to make sure data.x and data.values will receive arrays of numbers and data.labels will be an array of strings.
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

sct
Newbie
Newbie
Posts: 31
Joined: Tue Aug 06, 2013 12:00 am

Re: Chart.draw(); gives error d.toFixed is not a function?

Post by sct » Tue Jul 15, 2014 4:48 pm

great thx.

Post Reply