How to present AmpieChart tilte in two line - java

I want Slice title in two line such as Czech Republic I need
Czech
Republic
I have tried but it seems to be not working in my case. I have small space to display chart
var chart = AmCharts.makeChart("chartdiv", {
"type": "pie",
"theme": "none",
"legend": {
"markerType": "circle",
"position": "right",
"marginRight": 80,
"autoMargins": false
},
"dataProvider": [{
"country": "Czech Republic",
"litres": 256.9
}, {
"country": "Ireland",
"litres": 131.1
}, {
"country": "Germany",
"litres": 115.8
}, {
"country": "Australia",
"litres": 109.9
}, {
"country": "Austria",
"litres": 108.3
}, {
"country": "UK",
"litres": 65
}, {
"country": "Belgium",
"litres": 40
}],
"valueField": "litres",
"titleField": "country",
"titleField": "country"
"balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>",
"exportConfig": {
"menuTop":"0px",
"menuItems": [{
"icon": '/lib/3/images/export.png',
"format": 'png'
}]
}
});

You can either define the line break in your data-provider like this:
"dataProvider": [{
"country": "Czech<br>Republic",
"litres": 256.9
}
or you just could get the labels inside the pie using the labeladius-property:
"labelRadius": -35
You can play around with the labelRadius in this JSFiddle and see how it works.Docs for this is here.

Related

Updating elements in a Map which has immutable objects

I have a Java Map which is deserialized into immutable objects from a json similar to below and has multiple levels of nesting. I have a second Map containing alternate values for some of the strings. The second map has the value appended to the key for the nested levels to differentiate between different elements in an array. I would like to replace the values in the first map using the values found in the second map. Are there any suggestions for the approach that could used to solve the below?
{
"product": "Internet",
"version": 3.1,
"releaseDate": "2014-06-25T00:00:00.000Z",
"person": {
"id": 12345,
"name": "John Doe",
"phones": {
"home": "800-123-4567",
"mobile": "877-123-1234"
},
"email": [
"jd#example.com",
"jd#example.org"
],
"dateOfBirth": "1980-01-02T00:00:00.000Z",
"registered": true,
"emergencyContacts": [
{
"name": "Jane Doe",
"phone": "888-555-1212",
"relationship": "spouse"
},
{
"name": "Justin Doe",
"phone": "877-123-1212",
"relationship": "parent"
}
]
}
}
Map containing alternate values
{
"product": "Strong Internet",
"person.name=John Doe" : "Barry Richards",
"person.emergencyContacts.name=Jane Doe" : "Jane Richards"
}
Resulting Map
{
"product": "Strong Internet",
"version": 3.1,
"releaseDate": "2014-06-25T00:00:00.000Z",
"person": {
"id": 12345,
"name": "Barry Richards",
"phones": {
"home": "800-123-4567",
"mobile": "877-123-1234"
},
"email": [
"jd#example.com",
"jd#example.org"
],
"dateOfBirth": "1980-01-02T00:00:00.000Z",
"registered": true,
"emergencyContacts": [
{
"name": "Jane Richards",
"phone": "888-555-1212",
"relationship": "spouse"
},
{
"name": "Justin Doe",
"phone": "877-123-1212",
"relationship": "parent"
}
]
}
}

Is there a way to use aggregation function to search for two fields for MongoDB/Java

What i would like to do is get all countries that have a region or subregion equal to "Southern Asia". Is there a function to perform compare both region and subregion to the string "Southern Asia"? I tried using filter but that didnt work out for me. The code below works fine to find regions that are equal to "Souther Asia"
Bson match = match(eq("region", "Southern Asia"));
This is an example of the json Data:
{
"_id": {
"$oid": "60c25ff18d787ab8bb976a6b"
},
"name": "Afghanistan",
"topLevelDomain": [
".af"
],
"alpha2Code": "AF",
"alpha3Code": "AFG",
"callingCodes": [
"93"
],
"capital": "Kabul",
"altSpellings": [
"AF",
"Afġānistān"
],
"region": "Asia",
"subregion": "Southern Asia",
"population": {
"$numberDouble": "27657145.0"
},
"latlng": [
{
"$numberDouble": "33.0"
},
{
"$numberDouble": "65.0"
}
],
"demonym": "Afghan",
"area": {
"$numberDouble": "652230.0"
},
"gini": {
"$numberDouble": "27.8"
},
"timezones": [
"UTC+04:30"
],
"borders": [
"IRN",
"PAK",
"TKM",
"UZB",
"TJK",
"CHN"
],
"nativeName": "افغانستان",
"numericCode": "004",
"currencies": [
{
"code": "AFN",
"name": "Afghan afghani",
"symbol": "؋"
}
],
"languages": [
{
"iso639_1": "ps",
"iso639_2": "pus",
"name": "Pashto",
"nativeName": "پښتو"
},
{
"iso639_1": "uz",
"iso639_2": "uzb",
"name": "Uzbek",
"nativeName": "Oʻzbek"
},
{
"iso639_1": "tk",
"iso639_2": "tuk",
"name": "Turkmen",
"nativeName": "Türkmen"
}
],
"translations": {
"de": "Afghanistan",
"es": "Afganistán",
"fr": "Afghanistan",
"ja": "アフガニスタン",
"it": "Afghanistan",
"br": "Afeganistão",
"pt": "Afeganistão",
"nl": "Afghanistan",
"hr": "Afganistan",
"fa": "افغانستان"
},
"flag": "https://restcountries.eu/data/afg.svg",
"regionalBlocs": [
{
"acronym": "SAARC",
"name": "South Asian Association for Regional Cooperation",
"otherAcronyms": [],
"otherNames": []
}
],
"cioc": "AFG"
}
Use the or filter like this:
Bson match = match(or(eq("region", "Southern Asia"), eq("subregion", "Southern Asia")));

How to get sale ID from the new Paypal Sync Api

I'm using the new Paypal Sync Api to get all transactions in a period of time. I need to be able to refund them too.
As all our transactions are always sales I need the sale ID to refund a transaction as stated in https://developer.paypal.com/docs/integration/direct/payments/refund-payments/#set-up-your-development-environment
Unfortunately I can not find anything in the transactions response which can be used as a sale ID
{
"transaction_details": [
{
"transaction_info": {
"paypal_account_id": "6EN7PS8P9DV6J",
"transaction_id": "05P62542TL3758730",
"transaction_event_code": "T0006",
"transaction_initiation_date": "2019-07-04T12:49:55+0000",
"transaction_updated_date": "2019-07-04T12:53:09+0000",
"transaction_amount": {
"currency_code": "USD",
"value": "10.00"
},
"fee_amount": {
"currency_code": "USD",
"value": "-0.49"
},
"transaction_status": "S",
"ending_balance": {
"currency_code": "USD",
"value": "0.00"
},
"available_balance": {
"currency_code": "USD",
"value": "0.00"
},
"protection_eligibility": "01"
},
"payer_info": {
"account_id": "6EN7PS8P9DV6J",
"email_address": "paypaltester3#test.de",
"address_status": "Y",
"payer_status": "Y",
"payer_name": {
"given_name": "Tester Three",
"surname": "Tester Three",
"alternate_full_name": "Tester Three Tester Three"
},
"country_code": "DE"
},
"shipping_info": {
"name": "Tester Three, Tester Three",
"address": {
"line1": "Teststreet. 1",
"city": "SomeCity",
"country_code": "DE",
"postal_code": "23434"
}
},
"cart_info": {
"item_details": [
{
"item_quantity": "1",
"item_unit_price": {
"currency_code": "USD",
"value": "10.00"
},
"item_amount": {
"currency_code": "USD",
"value": "10.00"
},
"total_item_amount": {
"currency_code": "USD",
"value": "10.00"
}
}
]
},
"store_info": {},
"auction_info": {},
"incentive_info": {}
}
],
"account_number": "96B45RCG6AX3E",
"start_date": "2019-07-03T00:00:00+0000",
"end_date": "2019-07-04T16:00:00+0000",
"last_refreshed_datetime": "2019-07-15T08:59:59+0000",
"page": 1,
"total_items": 15,
"total_pages": 1,
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/reporting/transactions?start_date=2019-07-03T00%3A00%3A00Z&end_date=2019-07-04T16%3A00%3A00Z&fields=all&page_size=500&page=1",
"rel": "self",
"method": "GET"
}
]
}
I tested a refund call with a transactionId and with an invoiceId but both returned "INTERNAL_SERVICE_ERROR".
Is there any way to get the sale ID by an API after the customer has completed the payment or do I have to save the sale ID in a database after creating a payment?
Thanks
With T0006 you are lucky, it is a simple PayPal Checkout APIs. transaction, it would be harder with T0002. Anyway, no the response have much more data. The example is below.
You can find it in invoice_number, or invoice_id. If only you had this data during payment creation procedures.
"transaction_details":[
{
"transaction_info":{
"paypal_account_id":"HHHHH",
"transaction_id":"040404040404040",
"transaction_event_code":"T0006",
"transaction_initiation_date":"2019-10-31T06:21:37+0000",
"transaction_updated_date":"2019-10-31T06:31:02+0000",
"transaction_amount":{
"currency_code":"AUD",
"value":"96.90"
},
"fee_amount":{
"currency_code":"AUD",
"value":"-4.08"
},
"shipping_amount":{
"currency_code":"AUD",
"value":"17.90"
},
"transaction_status":"S",
"transaction_subject":"Full License",
"ending_balance":{
"currency_code":"AUD",
"value":"92.82"
},
"available_balance":{
"currency_code":"AUD",
"value":"92.82"
},
"invoice_id":"1110-US1",
"protection_eligibility":"01"
},
"payer_info":{
"account_id":"HHHHH",
"email_address":"test#paypal.com",
"address_status":"Y",
"payer_status":"Y",
"payer_name":{
"given_name":"First",
"surname":"Last",
"alternate_full_name":"First Last"
},
"country_code":"GB"
},
"shipping_info":{
"name":"Shaun Smith",
"address":{
"line1":"123, Some Road",
"line2":"Shop 4",
"city":"Melbourne",
"country_code":"AU",
"postal_code":"3185"
}
},
"cart_info":{
"item_details":[
{
"item_name":"Full License",
"item_description":"Full License",
"item_quantity":"1",
"item_unit_price":{
"currency_code":"AUD",
"value":"79.00"
},
"item_amount":{
"currency_code":"AUD",
"value":"79.00"
},
"total_item_amount":{
"currency_code":"AUD",
"value":"79.00"
},
"invoice_number":"1110-US1"
}
]
},
"store_info":{
},
"auction_info":{
},
"incentive_info":{
}
},

Precondition on data pipeline

I did some set of activities on json script. Need to add precondition on it.
how to use precondition on json script.
In precondition, i need to check the mysql db field. once flag as 'Y',
start execution else should be stop the execution.
You can use a ShellCommandPrecondition for this which will let you write a custom precondition.
{
"objects": [
{
"schedule": {
"ref": "DefaultSchedule"
},
"resourceRole": "DataPipelineDefaultResourceRole",
"role": "DataPipelineDefaultRole",
"name": "DefaultResource1",
"id": "ResourceId_dWoZ0",
"type": "Ec2Resource",
"terminateAfter": "1 Hour"
},
{
"name": "DefaultPrecondition1",
"id": "PreconditionId_yA2rV",
"type": "ShellCommandPrecondition",
"command": "<Script to check mysql field>"
},
{
"occurrences": "1",
"period": "1 Day",
"name": "RunOnce",
"id": "DefaultSchedule",
"type": "Schedule",
"startAt": "FIRST_ACTIVATION_DATE_TIME"
},
{
"failureAndRerunMode": "CASCADE",
"schedule": {
"ref": "DefaultSchedule"
},
"resourceRole": "DataPipelineDefaultResourceRole",
"role": "DataPipelineDefaultRole",
"pipelineLogUri": "s3://<mybucket>",
"scheduleType": "cron",
"name": "Default",
"id": "Default"
},
{
"schedule": {
"ref": "DefaultSchedule"
},
"name": "DefaultActivity1",
"runsOn": {
"ref": "ResourceId_dWoZ0"
},
"precondition": {
"ref": "PreconditionId_yA2rV"
},
"id": "ActivityId_gmQ0W",
"type": "ShellCommandActivity",
"command": "echo 'Hello world'"
}
],
"parameters": []
}

facebook events start_time doesnot return correct value

start_time value returned using fql from java code is different than the one returned from graph explorer .
fql:
fql?q={"events":"SELECT eid, name,description, start_time, end_time, pic_small,pic_big, eid,venue,location from event WHERE eid in (SELECT eid FROM event_member WHERE uid = me() and start_time > 1347482366)" ,"locations":"select page_id,location from page where page_id IN (select venue.id from #events)" ,"rsvpStatus":"select eid, rsvp_status from event_member where eid IN (select eid from #events) AND uid = me()"}
java code result :
{
"data": [
{
"name": "events",
"fql_result_set": [
{
"eid": 495493753795633,
"name": "Yo yo party",
"description": "",
"start_time": **1347656400**,
"end_time": **1347670800**,
"pic_small": "http:\/\/profile.ak.fbcdn.net\/static-ak\/rsrc.php\/v2\/yy\/r\/XcB-JGXohjk.png",
"pic_big": "http:\/\/profile.ak.fbcdn.net\/static-ak\/rsrc.php\/v2\/yn\/r\/5uwzdFmIMKQ.png",
"venue": {
"id": 154409375600
},
"location": "PIKE PLACE FISH MARKET"
}
]
},
{
"name": "locations",
"fql_result_set": [
{
"page_id": 154409375600,
"location": {
"street": "86 Pike Place",
"city": "Seattle",
"state": "WA",
"country": "United States",
"zip": "98101",
"latitude": 47.608639747653,
"longitude": -122.3405485174
}
}
]
},
{
"name": "rsvpStatus",
"fql_result_set": [
{
"eid": 495493753795633,
"rsvp_status": "attending"
}
]
}
]
}
graph explorer result :
{
"data": [
{
"name": "events",
"fql_result_set": [
{
"eid": 495493753795633,
"name": "Yo yo party",
"description": "",
"start_time": "**2012-09-14T14:00:00-0700**",
"end_time": "**2012-09-14T18:00:00-0700**",
"pic_small": "http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/yy/r/XcB-JGXohjk.png",
"pic_big": "http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/yn/r/5uwzdFmIMKQ.png",
"venue": {
"id": 154409375600
},
"location": "PIKE PLACE FISH MARKET"
}
]
},
{
"name": "locations",
"fql_result_set": [
{
"page_id": 154409375600,
"location": {
"street": "86 Pike Place",
"city": "Seattle",
"state": "WA",
"country": "United States",
"zip": "98101",
"latitude": 47.608639747653,
"longitude": -122.3405485174
}
}
]
},
{
"name": "rsvpStatus",
"fql_result_set": [
{
"eid": 495493753795633,
"rsvp_status": "attending"
}
]
}
]
}
Here are the issues :
Time format difference
The start_time and end_time returned to the java code is incorrect. When I converted the unix time stamp it turns out to be one hour less than the actual event start and end time.
Is this a known issue? Any information would be really appreciated.
The graph API explorer result is UTC -7 according to the Timestamp
Is this just that the FQL result is a unix timestamp in UTC-8? (this was the default on Facebook until recently, and not all apps will have the correct timezones - i think this is a migration option in the app settings)

Categories