How to get multiple dimensions in Bar chart - SAPUI5 VizFrame - charts

I am new to SAPUI5, I am trying to get multiple dimensions in Bar chart using VizFrame. I need chart to be displayed like the below image:
Please check my code.

I think you are looking for Bar graph to show the Amount vs Days.
Here is the working link.
I have updated _setupChart methods as below.
_setupChart: function() {
var oVizFrame = this.getView().byId("idVizFrame");
oVizFrame.setModel(new JSONModel('./data.json'));
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions: [{
name: "Days",
value: "{Days}"
}],
measures: [{
name: "Amount",
value: "{Amount}"
}],
data: {
path: "/dueDays"
}
});
oVizFrame.setDataset(oDataset);
oVizFrame.setVizType('bar');
var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
"uid": "valueAxis",
"type": "Measure",
"values": ["Amount"]
});
var feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
"uid": "categoryAxis",
"type": "Dimension",
"values": ["Days"]
});
oVizFrame.addFeed(feedValueAxis);
oVizFrame.addFeed(feedCategoryAxis);
}
And also i have updated the data json as below
{
"dueDays": [{
"Days": "Current",
"Amount": "44334.00"
}, {
"Days": "1 to 30",
"Amount": "53454.00"
}, {
"Days": "31 to 60",
"Amount": "34443.65"
}, {
"Days": "61 to 90",
"Amount": "65554.43"
}, {
"Days": "91 to 120",
"Amount": "43524.00"
},{
"Days": "121 to 150",
"Amount": "54554.00"
}, {
"Days": "151 to 180",
"Amount": "43324.00"
}, {
"Days": "Above 180",
"Amount": "54355"
}]
}

Thanks for your work & time !! .. I have made it using setVizProperties > plotArea > dataPointStyle > rules .. This is the updated link.

Related

How to create a variable recurring payment in paypal in node.js

I've signed up to a paypal business account. I've been trying to create a variable recurring payment using paypal. But with no luck. I could not find any working code that can accomplish this.
Things I've tried:
Subscriptions: I've checkout subscriptions too but subscriptions seem to be having fixed amount.
Paypal-rest-sdk: Paypal rest sdk won't let me change the payment_definitions most probably because it is just creating a standard subscription and not a variable one
(async function() {
const paypal = require("paypal-rest-sdk");
paypal.configure({
'mode': 'sandbox', //sandbox or live
'client_id': process.env.PAYPAL_CLIENT_ID,
'client_secret': process.env.PAYPAL_SECRET_KEY
});
var billingPlanAttributes = {
"description": "Create Plan for Regular",
"merchant_preferences": {
"auto_bill_amount": "yes",
"cancel_url": "http://www.cancel.com",
"initial_fail_amount_action": "continue",
"max_fail_attempts": "1",
"return_url": "http://www.success.com",
"setup_fee": {
"currency": "USD",
"value": "25"
}
},
"name": "Testing1-Regular1",
"payment_definitions": [
{
"amount": {
"currency": "USD",
"value": "100"
},
"charge_models": [
{
"amount": {
"currency": "USD",
"value": "10.60"
},
"type": "SHIPPING"
},
{
"amount": {
"currency": "USD",
"value": "20"
},
"type": "TAX"
}
],
"cycles": "0",
"frequency": "MONTH",
"frequency_interval": "1",
"name": "Regular 1",
"type": "REGULAR"
}
],
"type": "INFINITE"
};
const createdBillingPlan = await new Promise((resolve, reject) => {
paypal.billingPlan.create(billingPlanAttributes, function (error, createdBillingPlan) {
if (error) {
reject(error);
} else {
resolve(createdBillingPlan)
}
});
});
// update
var billing_plan_update_attributes = [
{
"op": "replace",
"path": "/",
"value": {
"payment_definitions": [
{
...createdBillingPlan.payment_definitions[0],
"amount": {
"currency": "INR",
"value": 100
}
}
]
}
}
];
console.log(billing_plan_update_attributes);
paypal.billingPlan.update(createdBillingPlan.id, billing_plan_update_attributes, function (error, response) {
if (error) {
console.log(error.response);
throw error;
} else {
paypal.billingPlan.get(createdBillingPlan.id, function (error, updatedBillingPlan) {
if (error) {
console.log(error.response);
throw error;
} else {
console.log(JSON.stringify(updatedBillingPlan));
}
});
}
});
})();
Above code throws
{ name: 'BUSINESS_VALIDATION_ERROR',
details:
[ { field: 'payment_definitions',
issue: 'patch is not supported for this field.' } ],
message: 'Validation Error.',
information_link:
'https://developer.paypal.com/docs/api/payments.billing-plans#errors',
debug_id: 'someid',
httpStatusCode: 400 }
Some links I've found interesting are:
https://www.paypal-community.com/t5/Merchant-services-Archive/Subscription-with-variable-amount-per-month/td-p/49864
https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECRecurringPayments/#
If some one could help me with some working code that creates a new recurring payment subscription / plan I'd really appreciate it.
No, you are wrong subscriptions are not fixed price. There is an option like seat-based pricing in subscriptions. All you need to do is modify your JSON when you creating a plan. Here is an example plan JSON for 1 USD base price.
{
"product_id": "PROD-60L70341GH758414Y",
"name": "Basic Plan",
"description": "Basic plan",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 1,
"total_cycles": 12,
"pricing_scheme": {
"fixed_price": {
"value": "1",
"currency_code": "USD"
}
}
}
],
"payment_preferences": {
"service_type": "PREPAID",
"auto_bill_outstanding": true,
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"quantity_supported": true
}
The most important part in here is quantity_supported": true, it indicates that you can give quantity property when creating a subscription. Lets say you want to create a subscription with 12 USD then all you need to do is give quantity as 12. When creating a subscription your JSON may like this
'plan_id': 'P-6AG14992W7150444HLUYGM5I',
'quantity': "12"
Hope it helps.

Can't get Service Alerts Protobuff to include header_text or description_text using Python gtfs_realtime_pb2 module

We are having difficulty adding header_text and description_text to a Service Alerts protobuff file. We are attempting to match the example shown on this page here.
https://developers.google.com/transit/gtfs-realtime/examples/alerts
Our data starts in the following dictionary:
alerts_dict = {
"header": {
"gtfs_realtime_version": "1",
"timestamp": "1543318671",
"incrementality": "FULL_DATASET"
},
"entity": [{
"497": {
"active_period": [{
"start": 1525320000,
"end": 1546315200
}],
"url": "http://www.capmetro.org/planner",
"effect": 4,
"header_text": "South 183: Airport",
"informed_entity": [{
"route_type": "3",
"route_id": "17",
"trip": "",
"stop_id": "3304"
}, {
"route_type": "3",
"route_id": "350",
"trip": "",
"stop_id": "3304"
}],
"description_text": "Stop closed temporarily",
"cause": 2
},
"460": {
"active_period": [{
"start": 1519876800,
"end": 1546315200
}],
"url": "http://www.capmetro.org/planner",
"effect": 4,
"header_text": "Ave F / Duval Detour",
"informed_entity": [{
"route_type": "3",
"route_id": "7",
"trip": "",
"stop_id": "1167"
}, {
"route_type": "3",
"route_id": "7",
"trip": "",
"stop_id": "1268"
}],
"description_text": "Stop closed temporarily",
"cause": 2
}
}]
}
Our Python code is as follows:
newfeed = gtfs_realtime_pb2.FeedMessage()
newfeedheader = newfeed.header
newfeedheader.gtfs_realtime_version = '2.0'
for alert_id, alert_dict in alerts_dict["entity"][0].iteritems():
print(alert_id)
print(alert_dict)
newentity = newfeed.entity.add()
newalert = newentity.alert
newentity.id = str(alert_id)
newtimerange = newalert.active_period.add()
newtimerange.end = alert_dict['active_period'][0]['end']
newtimerange.start = alert_dict['active_period'][0]['start']
for informed in alert_dict['informed_entity']:
newentityselector = newalert.informed_entity.add()
newentityselector.route_id = informed['route_id']
newentityselector.route_type = int(informed['route_type'])
newentityselector.stop_id = informed['stop_id']
print(alert_dict['description_text'])
newdescription = newalert.header_text
newdescription = alert_dict['description_text']
newalert.cause = alert_dict['cause']
newalert.effect = alert_dict['effect']
pb_feed = newfeed.SerializeToString()
with open("servicealerts.pb", 'wb') as fout:
fout.write(pb_feed)
The frustrating part is that we don't receive any sort of error message. Everything appears to run properly but the resulting pb file doesn't contain the new header_text or description_text items.
We are able to read the pb file using the following code:
feed = gtfs_realtime_pb2.FeedMessage()
response = open("servicealerts.pb")
feed.ParseFromString(response.read())
print(feed)
We truly appreciate any help that anyone can offer in pointing us in the right direction of figuring this out.
I was able to find the answer. This Python Notebook showed that by properly formatting the dictionary the PB could be generated with a few of lines of code.
from google.transit import gtfs_realtime_pb2
from google.protobuf.json_format import MessageToDict
newfeed = gtfs_realtime_pb2.FeedMessage()
ParseDict(alerts_dict, newfeed)
pb_feed = newfeed.SerializeToString()
with open("servicealerts.pb", 'wb') as fout:
fout.write(pb_feed)
All I had to do was format by dictionary properly.
if ALERT_GROUP_ID not in entity_dict.keys():
entity_dict[ALERT_GROUP_ID] = {"id": ALERT_GROUP_ID,
"alert":{
"active_period": [{
"start": int(START_TIME),
"end": int(END_TIME)
}],
"cause": cause_dict.get(CAUSE, ""),
"effect": effect_dict.get(EFFECT),
"url": {
"translation": [{
"text": URL,
"language": "en"
}]
},
"header_text": {
"translation": [{
"text": HEADER_TEXT,
"language": "en"
}]
},
"informed_entity": [{
'route_id': ROUTE_ID,
'route_type': ROUTE_TYPE,
'trip': TRIP,
'stop_id': STOP_ID
}],
"description_text": {
"translation": [{
"text": "Stop closed temporarily",
"language": "en"
}]
},
},
}
# print(entity_dict[ALERT_GROUP_ID]["alert"]['informed_entity'])
else:
entity_dict[ALERT_GROUP_ID]["alert"]['informed_entity'].append({
'route_id': ROUTE_ID,
'route_type': ROUTE_TYPE,
'trip': TRIP,
'stop_id': STOP_ID
})

Scriptcase line chart Y- axis scale issue

Anyone knows how to adjust the y axis in a line chart in scriptcase?
The image below shows the problem:
Instead of starting at 0 and finishing at 1k, I would like Scriptcase to auto adjust the Y axis scale - perhaps going from 840 to 1k.
I have looked for this option but can not find any answer to it.
thanks,
You can explicitly set y-axis min and max value using yAxisMinValue and yAxisMaxValue attribute at the chart object level for example :
"chart": {
"yAxisMinValue":"840",
"yAxisMaxValue":"1000"
}
For details please check this snippet -
FusionCharts.ready(function() {
var visitChart = new FusionCharts({
type: 'line',
renderAt: 'chart-container',
width: '700',
height: '400',
dataFormat: 'json',
dataSource: {
"chart": {
"yAxisMinValue":"840",
"yAxisMaxValue":"1000"
},
"data": [{
"label": "Mon",
"value": "899"
},
{
"label": "Tue",
"value": "952"
},
{
"label": "Wed",
"value": "963"
},
{
"label": "Thu",
"value": "874"
},
{
"label": "Fri",
"value": "862"
},
{
"label": "Sat",
"value": "906"
},
{
"label": "Sun",
"value": "999"
}
]
}
});
visitChart.render();
});

Country dimension in Analytics Reporting API v4

I want to get a report from Google Analytics v4 for pageviews by country. Since my website is targeting a specific region, I'm filtering by countries I'm most interested in using ga:countryIsoCode dimension so I don't have to type complete country name in the filter.
Now I'd be also interested in getting pageviews for all other countries combined into 'other' entry. What would be the easiest way to achieve that?
I've tried dynamic segments so far adding ga:segment to dimensions and a NOT filter in the segment with the same rule I used for filtering counties (except ga:countryIsoCode isn't allowed in segments, so I used ga:country). This produced 3 rows of data with each of three countries appearing along with 'other' every time.
I'd appreciate an advice on this as it seems like a common use case to me. Thanks in advance!
I was able to achieve that by using segments. This approach doesn't allow to batch requests though unless all of them have the same segment definition. Also, there're limitations on the number of segments to include in the report request. Very surprised this functionality is so hard to achieve. For interested, there's an example request:
{
"reportRequests": [{
"viewId": "ga:XXXXXXXXX",
"dateRanges": [{
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD"
}],
"metrics": [{
"expression": "ga:pageviews"
}, {
"expression": "ga:sessions"
}],
"dimensions": [{
"name": "ga:segment"
}],
"segments": [{
"dynamicSegment": {
"name": "Other",
"sessionSegment": {
"segmentFilters": [{
"not": "True",
"simpleSegment": {
"orFiltersForSegment": [{
"segmentFilterClauses": [{
"dimensionFilter": {
"dimensionName": "ga:country",
"operator": "IN_LIST",
"expressions": ["United States", "United Kingdom"]
}
}]
}]
}
}]
}
}
},
{
"dynamicSegment": {
"name": "United States",
"sessionSegment": {
"segmentFilters": [{
"simpleSegment": {
"orFiltersForSegment": [{
"segmentFilterClauses": [{
"dimensionFilter": {
"dimensionName": "ga:country",
"operator": "EXACT",
"expressions": "United States"
}
}]
}]
}
}]
}
}
},
{
"dynamicSegment": {
"name": "United Kingdom",
"sessionSegment": {
"segmentFilters": [{
"simpleSegment": {
"orFiltersForSegment": [{
"segmentFilterClauses": [{
"dimensionFilter": {
"dimensionName": "ga:country",
"operator": "EXACT",
"expressions": "United Kingdom"
}
}]
}]
}
}]
}
}
}],
'hideTotals': 'true',
'hideValueRanges': 'true'
}]
}

how to code sap.m.sample.ListGrouping by using js view in openui5

hi i need List grouping control by using js view.but openui5 provides code by using xml view.
https://openui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.ListGrouping/preview
how to convert this code into js view and how to make ListGrouping able to selection for both element level and group level and change this as dropdown box
List.view.xml
<mvc:View
controllerName="sap.m.sample.ListGrouping.List"
xmlns:l="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<List
items="{
path: '/ProductCollection',
sorter: {
path: 'SupplierName',
descending: false,
group: true
},
groupHeaderFactory: '.getGroupHeader'
}"
headerText="Products" >
<StandardListItem
title="{Name}"
description="{ProductId}"
icon="{ProductPicUrl}"
iconDensityAware="false"
iconInset="false" />
</List>
</mvc:View>
List.controller.js
sap.ui.define([
'jquery.sap.global',
'sap/m/GroupHeaderListItem',
'sap/ui/core/mvc/Controller',
'sap/ui/model/json/JSONModel'
], function(jQuery, GroupHeaderListItem, Controller, JSONModel) {
"use strict";
var ListController = Controller.extend("sap.m.sample.ListGrouping.List", {
onInit : function (evt) {
// set explored app's demo model on this sample
var oModel = new JSONModel(jQuery.sap.getModulePath("sap.ui.demo.mock", "/products.json"));
this.getView().setModel(oModel);
},
getGroupHeader: function (oGroup){
return new GroupHeaderListItem( {
title: oGroup.key,
upperCase: false
} );
}
});
return ListController;
});
how to write the same code by using js view
I have tried like as follows, but i am getting Error: Missing template or factory function for aggregation items of Element sap.m.List#__list0 !
List.view.js
sap.ui.jsview("oui5mvc.List", {
getControllerName : function() {
return "oui5mvc.List";
},
createContent : function(oController) {
odbbshiftGlobalId = this.getId();
var oMyFlexbox = new sap.m.FlexBox({
items: [
oList = new sap.m.List({
width: '500px',
group: true,
groupHeaderFactory: '.getGroupHeader',
items: [
]
}),
]
});
oMyFlexbox.placeAt(this.getId()).addStyleClass("tes");
}
});
List.controller.js
sap.ui.controller("oui5mvc.List", {
onInit: function() {
var data = {
"ProductCollection": [
{
"ProductId": "1239102",
"Name": "Power Projector 4713",
"Category": "Projector",
"SupplierName": "Titanium",
"Description": "A very powerful projector with special features for Internet usability, USB",
"WeightMeasure": 1467,
"WeightUnit": "g",
"Price": 856.49,
"CurrencyCode": "EUR",
"Status": "Available",
"Quantity": 3,
"UoM": "PC",
"Width": 51,
"Depth": 42,
"Height": 18,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-6100.jpg"
},
{
"ProductId": "2212-121-828",
"Name": "Gladiator MX",
"Category": "Graphics Card",
"SupplierName": "Technocom",
"Description": "Gladiator MX: DDR2 RoHS 128MB Supporting 512MB Clock rate: 350 MHz Memory Clock: 533 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 32-bit Highlighted Features: DVI Out, TV Out , HDTV",
"WeightMeasure": 321,
"WeightUnit": "g",
"Price": 81.7,
"CurrencyCode": "EUR",
"Status": "Discontinued",
"Quantity": 10,
"UoM": "PC",
"Width": 34,
"Depth": 14,
"Height": 2,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-1071.jpg"
},
{
"ProductId": "K47322.1",
"Name": "Hurricane GX",
"Category": "Graphics Card",
"SupplierName": "Red Point Stores",
"Description": "Hurricane GX: DDR2 RoHS 512MB Supporting 1024MB Clock rate: 550 MHz Memory Clock: 933 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 64-bit Highlighted Features: DVI Out, TV-In, TV-Out, HDTV",
"WeightMeasure": 588,
"WeightUnit": "g",
"Price": 219,
"CurrencyCode": "EUR",
"Status": "Out of Stock",
"Quantity": 25,
"UoM": "PC",
"Width": 34,
"Depth": 14,
"Height": 2,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-1072.jpg"
},
],
"ProductCollectionStats": {
"Counts": {
"Total": 14,
"Weight": {
"Ok": 7,
"Heavy": 5,
"Overweight": 2
}
},
"Groups": {
"Category": {
"Projector": 1,
"Graphics Card": 2,
"Accessory": 4,
"Printer": 2,
"Monitor": 3,
"Laptop": 1,
"Keyboard": 1
},
"SupplierName": {
"Titanium": 3,
"Technocom": 3,
"Red Point Stores": 5,
"Very Best Screens": 3
}
},
"Filters": [
{
"type": "Category",
"values": [
{
"text": "Projector",
"data": 1
},
{
"text": "Graphics Card",
"data": 2
},
{
"text": "Accessory",
"data": 4
},
{
"text": "Printer",
"data": 2
},
{
"text": "Monitor",
"data": 3
},
{
"text": "Laptop",
"data": 1
},
{
"text": "Keyboard",
"data": 1
}
]
},
{
"type": "SupplierName",
"values": [
{
"text": "Titanium",
"data": 3
},
{
"text": "Technocom",
"data": 3
},
{
"text": "Red Point Stores",
"data": 5
},
{
"text": "Very Best Screens",
"data": 3
}
]
}
]
}
};
var oTemplate11 = new sap.m.StandardListItem({title : "{Name}"});
oList.setModel(new sap.ui.model.json.JSONModel(data));
oList.bindItems("/ProductCollection");
oList.placeAt('content');
},
getGroupHeader: function (oGroup){
return new sap.m.GroupHeaderListItem( {
title: oGroup.key,
upperCase: false
});
},
});
Your call to bind items to the list is not entirely correct.
The method takes an object with binding information as parameter instead of just the path to the model property. See the documentation for bindItems and bindAggregation in general.
In your case it should look like
oList.bindItems({
path: "/ProductCollection",
template: new sap.m.StandardListItem({
title: "{Name}",
description: "{ProductId}",
icon: "{ProductPicUrl}"
})
});