Tooltip Title , how to set the title as field value instead of hard coded value in vegalite charts - vega-lite

In Vegalite for tooltip, how to set data value as Title
When i set data field in the title it does not work, below is code snippet
"tooltip": [
{
"field" : "xToolTip",
"title" : "xName"
}
where xName is data attribute
Tooltip image

Just don't set a title at all and the title will be the name of the field in your dataset.

Related

How to divide full name text from textfield into two strings(firstname and secondname) in swift

I have one textfield called fullnameTextField here i am writing firstname space secondname in textfield
while parsing i need firstname separately and secondname separately,
how to add firstname and secondname parameters from one fullnameTextField
#IBOutlet weak var fullName : UITextField!
and my api parameters are
let param = ["fname" : "hello",
"lname": "test",
"country_code": "1",
"password" : txtPassword.text?.trim() ?? "",
"password_confirmation" : txtConfirmPassword.text?.trim() ?? "",
"phone" : mobileNum
]
how to add one input to two parameters
There is no solution for this
If You need 2 fields for any other services(Stripe, etc) only way is use 2 inputs
We have too many variables of full names. It can contain 2 - 5 words or like utf16 symbols string (japanese, arabic).
Also Full name field not forcing to write first name in first, so even if u have 2 basic words, after separating it by whitespace u can be sure which one this parts is

iterate and strikethrough based on condition

I am showing the information in the table using angularjs,html.
I want to strike through the ID displayed in the second column of the table whose status is "delivered" given in productstatus of $scope.items.
Demo : http://plnkr.co/edit/m0x5TQNY4QprCF5CqRSn?p=preview&preview
I tried as below , but unable to show strikethrough for productID's 10,12 in row1 and 11A,100AX in row3:
<a ng-repeat="pid in item.productid.split(',')" href="https://urladdr/associateid={{associateNum}}" target="_blank">
<span data-ng-class="item.productstatus.split(',')[$index] === 'delivered' ? 'strikethrough' : 'null'">{{pid}}
</span><span ng-if="$index+1 != item.productid.split(',').length">;</span>
</a>
json object:
$scope.items = [{
"name":"John",
"product":"Laptop",
"productid":"10,11X,12",
"standing": true,
"productstatus":{"10":"delivered","11x":"Shipped","12":"delivered"}
},{
"name":"Rob",
"product":"Mobile",
"productid":"13PX",
"standing": true,
"productstatus":{"13PX":"Shipped"}
},{
"name":"Dan",
"product":"Laptop",
"productid":"",
"standing": true,
"productstatus":null
},{
"name":"Robert",
"product":"Laptop",
"productid":"11A,100AX",
"standing": true,
"productstatus":{"11A":"delivered","100AX":"delivered"}
}]
You're trying to split a json object which you can't do. If productstatus is changed to a string you can keep your code as is. Otherwise you'll want to do a ng-repeat with key/value pairs. (i.e. ng-repeat="(key, prop) in item.productstatus" or use the key directly i.e. data-ng-class="item.productstatus[pid] === 'delivered' ? 'strikethrough' : 'null'"
The following works for me if you want to copy and replace your code:
<a ng-repeat="pid in item.productid.split(',')" href="https://urladdr/associateid={{associateNum}}" target="_blank">
<span data-ng-class="item.productstatus[pid.trim()] === 'delivered' ? 'strikethrough' : 'null'">{{pid}}
</span><span ng-if="$index+1 != item.productid.split(',').length">;</span>
</a>
Updated: added trim() based on comments.
Pay attention that your data structure of item.productstatus is an Object and not Array.
Therefore you should change the usage to something like that: item.productstatus[pid].
http://plnkr.co/edit/s7ySyexnVrhzSXkY
Pro TIP: Use the map to boolean option of ng-class directive, it is more cleaner.
ng-class="{className: item.productstatus[pid] === 'delivered'}"
The result of the evaluation can be a string representing space delimited class names, an array, or a map of class names to boolean values. In the case of a map, the names of the properties whose values are truthy will be added as css classes to the element.

Json to excel using power query

I have some json on a website that i want to convert to excel using the power query option from web. But I ran into a small problem. My json looks like this:
[
{
"id" : 1,
"visitors" : 26,
"some_number" : 1,
"value" : 3500
},
{
"id" : 2,
"visitors" : 21,
"some_number" : 5,
"value" : 2000
}
]
but when i use from web i get this:
I can drill down into a record,convert it to a table, transpose and use first row as header but then i get just one row. How can i get all of my data to the table and not just one row?
First I would use the List Tools / Transform menu (it should be automatically selected) and click the To Table button. This will give you a single-column table with 2 rows. Then I would click the small Expand button - it will appear in the column headings, just to the right of "Column1". Uncheck the Use original column name ... option and you will get a table of 4 columns and 2 rows.
Here's the full script I generated:
let
Source = Json.Document(File.Contents("C:\Users\Mike.Honey\Downloads\json2.json")),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column2" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "visitors", "some_number", "value"}, {"id", "visitors", "some_number", "value"})
in
#"Expanded Column2"
The Table.FromRecords() function is suitable for that sample data:
let
Source = Json.Document("[{""id"": 1, ""visitors"": 26, ""some_number"": 1, ""value"": 3500}, {""id"": 2, ""visitors"": 21, ""some_number"": 5, ""value"": 2000}]"),
AsTable = Table.FromRecords(Source)
in
AsTable
I have Excel Professional 2016 and I don't see the JSON option, but I can get to it via the "Other Sources" query option. Here are all the steps to convert a JSON array to a table.
Data > New Query > From Other Sources > From Web
Enter URL : "file:///C:/temp/document.json", (or a http web url) Press OK
A row is displayed with a "items" property and List type,
Click on "List", the items in list are displayed
Press "To Table" button in upper left corner, Press OK in next
dialog
A table with one column named "Column1" is displayed
Press the button next to the column name (has left and right arrows
on it)
Properties in the row object are selected
Uncheck "User Original column name as prefix", Press "OK"
Press "Close & Load" button in upper left corner
my file looks like
{
"items": [{
"code": "1",
"name": "first"
}, {
"code": "2",
"name": "second"
}, {
"code": "3",
"name": "third"
},
]
}
You need to convert the list to a table first, then you can expand the record column and proceed from there. If no luck, then you can take a look at this video I created recently for a similar question.

How to concatenate existing variable and string in Template Variables Dialog (PhpStorm)

I have a live template like this
<div>$name$: $id$</div>
Now I want to set the default value of $id$ to name + "_id".
But when I put the default value of $id$ as name + "_id", in the "Edit Template Variables Dialog", the autocomplete does not concatenate value of name and (string) "_id" together. It only uses the value of name and ignored the "_id" part (for default value of $id$).
How can I make the default value of $id$ as name + "_id" in my live templates?
You can try to create a variable and concat the values into it.
Something like:
#set( $your_var = $NAME + '_id')
<div>$name$: $your_var$</div>
Not sure about phpstorm, but I was just looking for the solution to this problem in webstorm and there is a concat(expressions...) function. So, solution to the problem could be to put in the 'Expression' field:
concat(name,"_id")
You can just do this:
<div>$name$: $name$_id</div>

JSON path parent object, or equivalent MongoDB query

I am selecting nodes in a JSON input but can't find a way to include parent object detail for each array entry that I am querying. I am using pentaho data integration to query the data using JSON input form a mongodb input.
I have also tried to create a mongodb query to achieve the same but cannot seem to do this either.
Here are the two fields/paths that display the data:
$.size_break_costs[*].size
$.size_break_costs[*].quantity
Here is the json source format:
{
"_id" : ObjectId("4f1f74ecde074f383a00000f"),
"colour" : "RAVEN-SMOKE",
"name" : "Authority",
"size_break_costs" : [
{
"quantity" : NumberLong("80"),
"_id" : ObjectId("518ffc0697eee36ff3000002"),
"size" : "S"
},
{
"quantity" : NumberLong("14"),
"_id" : ObjectId("518ffc0697eee36ff3000003"),
"size" : "M"
},
{
"quantity" : NumberLong("55"),
"_id" : ObjectId("518ffc0697eee36ff3000004"),
"size" : "L"
}
],
"sku" : "SK3579"
}
I currently get the following results:
S,80
M,14
L,55
I would like to get the SKU and Name as well as my source will have multiple products (SKU/Description):
SK3579,Authority,S,80
SK3579,Authority,M,14
SK3579,Authority,L,55
When I try To include using $.sku, I the process errors.
The end result i'm after is a report of all products and the available quantities of their various sizes. Possibly there's an alternative mongodb query that provides this.
EDIT:
It seems the issue may be due to the fact that not all lines have the same structure. For example the above contains 3 sizes - S,M,L. Some products come in one size - PACK. Other come in multiple sizes - 28,30,32,33,34,36,38 etc.
The error produced is:
*The data structure is not the same inside the resource! We found 1 values for json path [$.sku], which is different that the number retourned for path [$.size_break_costs[].quantity] (7 values). We MUST have the same number of values for all paths.
I have tried the following mongodb query separately which gives the correct results, but the corresponding export of this doesn't work. No values are returned for the Size and Quantity.
Query:
db.product_details.find( {}, {sku: true, "size_break_costs.size": true, "size_break_costs.quantity": true}).pretty();
Export:
mongoexport --db brandscope_production --collection product_details --csv --out Test01.csv --fields sku,"size_break_costs.size","size_break_costs.quantity" --query '{}';
Shortly after I added my own bounty, I figured out the solution. My problem has the same basic structure, which is a parent identifier, and some number N child key/value pairs for ratings (quality, value, etc...).
First, you'll need a JSON Input step that gets the SKU, Name, and size_break_costs array, all as Strings. The important part is that size_break_costs is a String, and is basically just a stringified JSON array. Make sure that under the Content tab of the JSON Input, that "Ignore missing path" is checked, in case you get one with an empty array or the field is missing for some reason.
For your fields, use:
Name | Path | Type
ProductSKU | $.sku | String
ProductName | $.name | String
SizeBreakCosts | $.size_break_costs | String
I added a "Filter rows" block after this step, with the condition "SizeBreakCosts IS NOT NULL", which is then passed to a second JSON Input block. This second JSON block, you'll need to check "Source is defined in a field?", and set the value of "Get source from field" to "SizeBreakCosts", or whatever you named it in the first JSON Input block.
Again, make sure "Ignore missing path" is checked, as well as "Ignore empty file". From this block, we'll want to get two fields. We'll already have ProductSKU and ProductName with each row that's passed in, and this second JSON Input step will further split it into however many rows are in the SizeBreakCosts input JSON. For fields, use:
Name | Path | Type
Quantity | $.[*].quantity | Integer
Size | $.[*].size | String
As you can see, these paths use "$.[*].FieldName", because the JSON string we passed in has an array as the root item, so we're getting every item in that array, and parsing out its quantity and size.
Now every row should have the SKU and name from the parent object, and the quantity and size from each child object. Dumping this example to a text file, I got:
ProductSKU;ProductName;Size;Quantity
SK3579;Authority;S; 80
SK3579;Authority;M; 14
SK3579;Authority;L; 55