Jump to content
Software FX Community

Accessing chart data in Javascript


MJ27
 Share

Recommended Posts

 Hi All,

I am trying to access the chart data in javascript on clinet.  At the server I have create a table with 3 columns:

1. valueofX

2. valueofY

3. Timedata

I have associated this table with the chart:

Chart.DataSource = dtTable;

 

The column are mapped as follows:

 Chart.DataSourceSettings.Fields.Add(new FieldMap("valueofX", FieldUsage.XValue));

Chart.DataSourceSettings.Fields.Add(new FieldMap("valueofY", FieldUsage.Value));

Chart.DataSourceSettings.Fields.Add(new FieldMap("Timedata", FieldUsage.NotUsed));

Please note that I dont want the chart to use the data passed in"Timedata" column, hence i have assigned the field usage as'FieldUsage.NotUsed'.

 

I have a link on each data point, when i click on this link a 'UserCommand'  event is generate on client. This event pass the following parameters "obj, args". 

I can access the X and Y values for the chart using

obj.Data.X.Item(<series>,<point>)

obj.Data.Y.Item(<series>,<point>) 

 

How can I access the data in "Timedata" column on client side.

Any help would be highly appreciated.

 

Thanks,

MJ

 

 

Link to comment
Share on other sites

 You can't access what you pass to the chart as NotUsed. But I might have a little work around that might work for you. In the BubbleChart sample (that comes with the installer), the "Symbol" column is passed as Label. Then, on a foreach loop passed to array of strings and the labels are cleared. Maybe you could do something similar, but instead of passing the values to a array of strings you could use the Tag property of Point. Then access it in obj.Point.Item(<point>).Tag.

Let me know if that works for you.

post-6009-13922409743729_thumb.jpg

Link to comment
Share on other sites

  • 2 weeks later...

 You can't access what you pass to the chart as NotUsed. But I might have a little work around that might work for you. In the BubbleChart sample (that comes with the installer), the "Symbol" column is passed as Label. Then, on a foreach loop passed to array of strings and the labels are cleared. Maybe you could do something similar, but instead of passing the values to a array of strings you could use the Tag property of Point. Then access it in obj.Point.Item(<point>).Tag.

Let me know if that works for you.


Thanks AndreG for your reply.

I am getting the following property as 'undefined' error when accessing it in javascript.

obj.Points.Item(0,0).Tag is undefined.

 

How should I access this property.

 

However I can access another property

obj.Points.Items(0,0).Volume

Order of execution:

1. Assign data to chart from a datatable.

  •   data table columns are mapped using the FieldMaps

2. assign value to each Chart.Point[0,0].Tag 

3. Draw chart.

 

Thanks,

MJ

Link to comment
Share on other sites

 Working for me. How did u pass the data to Tag?

  Chart.DataSourceSettings.Fields.Add(new FieldMap("valueofX", FieldUsage.XValue));   Chart.DataSourceSettings.Fields.Add(new FieldMap("valueofY", FieldUsage.Value));   Chart.DataSourceSettings.Fields.Add(new FieldMap("Timedata", FieldUsage.Label));   Chart1.DataSource = table1;   int i = 0;   foreach (string tag in Chart1.AxisX.Labels)   {   Chart1.Points[0, i].Tag = tag;   i++;   }   Chart1.AxisX.Labels.Clear();

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
Reply to this topic...

×   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.

 Share

×
×
  • Create New...