on ‎2014 May 06 2:49 PM
Hi experts,
I am facing problem with ui5 bar chart. i am not able to get the selected data set index of selected bar on the chart.
I am using below method, but not getting any result from this method.
ObjectName.getChartObject().getSelectedDataSetIndices()
please suggest any methods are avaliable to get selected index?
Thanks & Regards
Venkat
Request clarification before answering.
Hello Everyone,
I have now updated my SAP MII patch to SAP UI5 version 1.20.4. Now I am getting my chart as shown in figure below.
Now I want to get the selected point x axis value, yaxis value and corresponding legend name of selected point. I am getting x axis value but not yaxis value and corresponding legend name.
Regards,
Venkat.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Venkat,
You can get the legend index and y-value by using the below code in the event handler that you have registered for ChartSelectionEvent:
var meaureIndex = event.srcElement.__data__.ctx.path.mi + 1;
alert(meaureIndex); //hack for getting legend index
var selPoint = c.getChartObject().getSelectedPoint();
alert(selPoint); //selected bar index
var yValue = c.getChartObject().getYDataValueAt(meaureIndex,selPoint);
alert(yValue);
Using the legend index you should be able to get the legend name.
Please note that parts of the above code for getting legend index is a hack (not in i5Chart documentation/reference)
Hope this helps!
Regards,
Ria
Hi Venkat,
If what you need is the index of the selected bar, then try this:
ObjectName.getChartObject().getSelectedPoint()
getSelectedDataSetIndices() - returns the dataset(legend) item index for the selected bar and for using this method you would have to register for chartSelectionEventHandler.
Regards,
Ria
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ria,
I tried with ObjectName.getChartObject().getSelectedPoint() method, getting index of data set point but I need the dataset(legend) item index and i registered chartSelectionEventHandler event and calling getSelectedDataSetIndices() method even though i am not getting any result from this method.
I am using following code to register event and calling Method.
chartobj.registerChartSelectionEventHandler(fnOnSelectChart);
function fnOnSelectChart()
{
alert(chartobj.getChartObject().getSelectedDataSetIndices());
alert(chartobj.getChartObject().getSelectedDataSetNames());
}
Regards
venkat
Hi Venkat,
Is it that the function fnOnSelectChart is getting called and the alerts do not return anything?
I tried the same, I get empty alerts- those methods returns the indices and names respectively of the legend items on selection of legend items. Sorry for the incorrect information in the earlier post.
If possible, can you please post a screenshot of the bar chart that is rendered and the expected value on selection of a bar - just to better understand your scenario.
Regards,
Ria
| 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.