I have to make a vendor comparison line graph. it is supposed to create series based on the vendor number it gets from the OData service. here is what I've been trying (it worked with a static json file but wont work with a odata service)
XML
<chart:Line id="idVendorCompareGraph" width="100%" height="100%"></chart:Line>
JS
var that = this; var sServiceUrl = "/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV"; var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true); var oVendorCompareGraph = that.getView().byId("idVendorCompareGraph"); var vendorCompare = "/VendorComparisonSet?$filter=Plant eq '3621' and Material eq '000000000000200000'"; oModel.setUseBatch(false); oModel.read(vendorCompare, { success: function(oData, response) { if (oData.results !== "undefined" || oData.results !== null) { var UsageModel = new sap.ui.model.json.JSONModel({ "VCdata": oData.results }); } var oDim = { dimensions: [{ axis: 1, name: "Month", value: "{Month}" }, { axis: 2, name: "Vendor", value: "{Vendor}" }], measures: [{ group: 1, name: "NetPrice", value: "{NetPrice}" }, { group: 2, name: "Quantity", value: "{Quantity}" }], data: { path: "VCdata" } }; var oDataset = new sap.viz.core.FlattenedDataset(oDim); oDataset.setModel(UsageModel); oVendorCompareGraph.setDataset(oDataset); alert("success"); }, error: function(error) { var message = "Error"; sap.m.MessageBox.show(message, sap.m.MessageBox.Icon.ERROR, "Error"); } });
OData
{ "d" : { "results" : [ { "__metadata" : { "id" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900147',Material='200000',Plant='')", "uri" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900147',Material='200000',Plant='')", "type" : "AAG362.MM_PURCHASE_APPROVAL_SRV.VendorComparison" }, "Vendor" : "900147", "Material" : "200000", "Plant" : "", "Month" : "201710", "Count" : 1, "Quantity" : "0.00", "NetPrice" : "115.00", "AvgPrice" : "115.00", "AvgQty" : "0.00", "PlanPrice1" : "0.00", "PlanPrice2" : "0.00" }, { "__metadata" : { "id" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900147',Material='200000',Plant='')", "uri" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900147',Material='200000',Plant='')", "type" : "AAG362.MM_PURCHASE_APPROVAL_SRV.VendorComparison" }, "Vendor" : "900147", "Material" : "200000", "Plant" : "", "Month" : "201711", "Count" : 1, "Quantity" : "0.00", "NetPrice" : "58.30", "AvgPrice" : "58.30", "AvgQty" : "0.00", "PlanPrice1" : "0.00", "PlanPrice2" : "0.00" }, { "__metadata" : { "id" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900173',Material='200000',Plant='')", "uri" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900173',Material='200000',Plant='')", "type" : "AAG362.MM_PURCHASE_APPROVAL_SRV.VendorComparison" }, "Vendor" : "900173", "Material" : "200000", "Plant" : "", "Month" : "201710", "Count" : 1, "Quantity" : "1.00", "NetPrice" : "100.00", "AvgPrice" : "100.00", "AvgQty" : "1.00", "PlanPrice1" : "0.00", "PlanPrice2" : "0.00" }, { "__metadata" : { "id" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900177',Material='200000',Plant='')", "uri" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900177',Material='200000',Plant='')", "type" : "AAG362.MM_PURCHASE_APPROVAL_SRV.VendorComparison" }, "Vendor" : "900177", "Material" : "200000", "Plant" : "", "Month" : "201709", "Count" : 1, "Quantity" : "100.00", "NetPrice" : "0.00", "AvgPrice" : "0.00", "AvgQty" : "100.00", "PlanPrice1" : "0.00", "PlanPrice2" : "0.00" }, { "__metadata" : { "id" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900201',Material='200000',Plant='')", "uri" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900201',Material='200000',Plant='')", "type" : "AAG362.MM_PURCHASE_APPROVAL_SRV.VendorComparison" }, "Vendor" : "900201", "Material" : "200000", "Plant" : "", "Month" : "201712", "Count" : 1, "Quantity" : "0.00", "NetPrice" : "1000.00", "AvgPrice" : "1000.00", "AvgQty" : "0.00", "PlanPrice1" : "0.00", "PlanPrice2" : "0.00" }, { "__metadata" : { "id" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900201',Material='200000',Plant='')", "uri" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900201',Material='200000',Plant='')", "type" : "AAG362.MM_PURCHASE_APPROVAL_SRV.VendorComparison" }, "Vendor" : "900201", "Material" : "200000", "Plant" : "", "Month" : "201801", "Count" : 1, "Quantity" : "0.00", "NetPrice" : "5000.00", "AvgPrice" : "5000.00", "AvgQty" : "0.00", "PlanPrice1" : "0.00", "PlanPrice2" : "0.00" }, { "__metadata" : { "id" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900234',Material='200000',Plant='')", "uri" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900234',Material='200000',Plant='')", "type" : "AAG362.MM_PURCHASE_APPROVAL_SRV.VendorComparison" }, "Vendor" : "900234", "Material" : "200000", "Plant" : "", "Month" : "201711", "Count" : 1, "Quantity" : "0.00", "NetPrice" : "35.00", "AvgPrice" : "35.00", "AvgQty" : "0.00", "PlanPrice1" : "0.00", "PlanPrice2" : "0.00" }, { "__metadata" : { "id" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900235',Material='200000',Plant='')", "uri" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900235',Material='200000',Plant='')", "type" : "AAG362.MM_PURCHASE_APPROVAL_SRV.VendorComparison" }, "Vendor" : "900235", "Material" : "200000", "Plant" : "", "Month" : "201711", "Count" : 1, "Quantity" : "0.00", "NetPrice" : "36.00", "AvgPrice" : "36.00", "AvgQty" : "0.00", "PlanPrice1" : "0.00", "PlanPrice2" : "0.00" }, { "__metadata" : { "id" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900236',Material='200000',Plant='')", "uri" : "http://elagwci1d.nat.tds.rz:8000/sap/opu/odata/AAG362/MM_PURCHASE_APPROVAL_SRV/VendorComparisonSet(Vendor='900236',Material='200000',Plant='')", "type" : "AAG362.MM_PURCHASE_APPROVAL_SRV.VendorComparison" }, "Vendor" : "900236", "Material" : "200000", "Plant" : "", "Month" : "201711", "Count" : 1, "Quantity" : "0.00", "NetPrice" : "36.00", "AvgPrice" : "36.00", "AvgQty" : "0.00", "PlanPrice1" : "0.00", "PlanPrice2" : "0.00" } ] } }
What am I doing wrong?? please help...