cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

select point on chart and retrieve more than just data

Former Member
0 Likes
345


var ShiftChart = document.FR_Runtime_ShiftHistory.getChartObject();

var selDate = ShiftChart.getYDataValueAt(1,ShiftChart.getLastSelectedPoint());

alert(selDate);

When dealing with a grid I can find the select cell value of column 1 or whatever column. How can I do the same thing by using a chart? In this example, I select the pen at a point on the chart and it gives me the data for it. I would like extract other values that identify that point like Date and Line. How can I do this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi xMII_Training!

You can take advantage of the "Datalink" mappings in the Display Templates. Map columns from the query into the Datalink field (many if needed). Then through the JS method:

document.iChart.getChartObject().getDatalinkValue(PENNUMBER,POINTNUMBER,ATTRIBUTE)

You can grab whatever datalink value you need.

Former Member
0 Likes

var test = ShiftChart.getDatalinkValue(1,getLastSelectedPoint(),ATTRIBUTE);

I guess I do not know what needs to go in the ATTRIBUTE section. I tried putting the column number, but I got an error stating an object is needed. I am going to try and see if I can get this one, but any help from you would be appreciated.

Former Member
0 Likes

Attribute references one of the datalink columns. So if "Line" is a datalink column in the display template, you could do:

var test = ShiftChart.getDatalinkValue(1,getLastSelectedPoint(),"Line") - I think.

Former Member
0 Likes

Then my attribut would be nLINE. I tried it with and without quotes and I still get the "object expected" error on that line of code.

Former Member
0 Likes

Ah! I see the problem. Replace


var test = ShiftChart.getDatalinkValue(1,getLastSelectedPoint(),ATTRIBUTE);

with


var selPoint = ShiftChart.getLastSelectedPoint();
var test = ShiftChart.getDatalinkValue(1,selPoint,"nLine");

Former Member
0 Likes

Assuming the ShiftChart variable points to something like:

document.myApplet.getChartObject(); (The Chart Object of an Applet)

Former Member
0 Likes

Here's the latest error

Error: java.lang.Exception: java.lang.NumberFormatException: For input string: "nLINE"

Error points to this line of code

var test = ShiftChart.getDatalinkValue(1,selPoint,"nLINE");

This is what I have...


var ShiftChart = document.FR_Runtime_ShiftHistory.getChartObject();
var selPoint = ShiftChart.getLastSelectedPoint();
var test = ShiftChart.getDatalinkValue(1,selPoint,"nLINE");
alert(test);

Answers (3)

Answers (3)

Former Member
0 Likes

Are you able to submit a request through the SAP Support Portal? This may be you best option if you are stuck.

Diana Hoppe

Former Member
0 Likes

Think of the Datalink attributes as being stored in an array; the first datalink value would be stored at index 1, the second at index 2, etc. Look at how you set up your datalinks in you display template. If "nLine" is the second one in the list, try using an index value of 2 as the function argument for the attribute. Do an alert and you should see what the value is - if the datalink is an integer value, you should get back an integer value. If the datalink is a string value, you should get back a string value.

Diana Hoppe

Former Member
0 Likes

I used your suggestion and "nLINE" is the 2nd column. So I replaced it with the number 2. I did the alert and I got no data in the pop up window. Now according to you, this means the data is not an integer. I know that nLINE in my database is an INT. So what could be the problem and what is the next step.

In my applet this is my param

<param name="ChartSelectionEvent" value="DrillDown">

Here is the function



function DrillDown()
{
			
	//set up aliases for easy reference
	var ShiftChart = document.FR_Runtime_ShiftHistory.getChartObject();

	var selPoint = ShiftChart.getLastSelectedPoint();
	var test = ShiftChart.getDatalinkValue(1,selPoint,1);
	alert(test);
}

Former Member
0 Likes

I have been running some tests - I have a display template with 3 datalink values set up. Datalink values 1 and 3, named ProductID and CategoryID are integer values. Datalink value 2, named ProductName contains a string value. When I use the function:

var myData = chartObj.getDatalinkValue(1, 1, 1);

alert(myData);

I get back the correct ProductId integer value of 1.

chartObj.getDatalinkValue(1, 1, 2); returns the correct string value "Chai"

and

chartObj.getDatalinkValue(1, 1, 3); returns the correct CategoryID integer value of 1.

I'm not sure why you are having difficulty - are you linking the columns correctly in your Display template on the Data Mapping tab to the Datalink Columns box?

Diana

Former Member
0 Likes

Is there a way to see all of the data in the array using an alert instead of right clicking the chart and selecting details. This way I can see what data I have available?

This is my function...


function DrillDown()
{
			
	//set up aliases for easy reference
	var ShiftChart = document.FR_Runtime_ShiftHistory.getChartObject();

	var selPoint = ShiftChart.getLastSelectedPoint();
	var test = ShiftChart.getDatalinkValue(1,selPoint,1);
	alert(selpoint);
	//alert(test);

}

Former Member
0 Likes

You would need to set up variables for each datalink and do the function call for each one, and then concatenate the variables together in the alert. Are you making any progress?

Diana

Former Member
0 Likes

I am making absolutely no progress. I have three threads that all tie in with this same irpt and I can not seem to inch forward with any of them.

Former Member
0 Likes

Hi xMII Training,

According to the Help Documentation for the getDatalinkValue(int TagNumber, int PointNumber, int AttributeIndex) the Attribute argument needs to be an integer value, so if "nLine" is the name of the attribute, this will not work, you need an integer value.

Diana Hoppe

Former Member
0 Likes

nLINE is an INT. So what should I do next?

Message was edited by:

xMII_Training