on ‎2007 Mar 29 2:24 PM
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?
Request clarification before answering.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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);
Are you able to submit a request through the SAP Support Portal? This may be you best option if you are stuck.
Diana Hoppe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
}
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
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);
}
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.