Jump to content
JChartFX Community
  • 0

Trouble passing data from asp.net to jchartfx


DeeJay

Question

Hi, 

 I am getting some data from excel worksheet; converting to json;  then saving it as a hiddenfield value. 

On client side, I am getting the value of the hiddenfield and passing to jchartfx. 

I seem to have an error everytime I do this.

 

If I take the data out of the hiddenfield and write it out as a string in the jquery code, it works just fine.

   var PriceData = $('#hidPriceChart').val(); // does not work

// the following works if I take the value from hidPRiceChart and set it manually. 
var PriceData = [{ "Commodity""CPO MDEX FUTURES""MKT_Price": 1009.3500780459954 }, { "Commodity""CPO MAL Physicals""MKT_Price": 975.99999999999989 }, { "Commodity""ROL MAL Physicals""MKT_Price": 1008.7500000000001 }, { "Commodity""SB CBOT Call""MKT_Price": 24.020566370720026 }, { "Commodity""SBM CBOT FUTURES""MKT_Price": 526.8994283471892 }, { "Commodity""SBO CBOT FUTURES""MKT_Price": 1177.092511013223 }, { "Commodity""CRUDE NYMEX Put""MKT_Price": 45.37689167750014 }, { "Commodity""HO NYMEX FUTURES""MKT_Price": 860.37383177569916 }, { "Commodity""GO ICE FUTURES""MKT_Price": 874 }];
 chart1.setDataSource(PriceData); // it fails at this line.

 Can anyone tell me what I am doing wrong? 

 

TestChartFXLayoutError.zip

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I suspect when you do PriceData = $("#hidPriceChart").val() you might be getting a string instead of an array of javascript objects, if this is so, you might need to use eval() to get the data as an array of objects.

Note that when you manually hardcode var priceData = [{..}], the priceData variable will hold an array of objects so if you do alert(priceData) javascript should tell you object or array or something like that as opossed to a string.

Another option would be to change your ASP.NET code so that it generates the client code that declares var priceData=[{... instead of using a hidden field.

Regards, 

JuanC 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...