How to generate a Levey-Jennings Chart with DC.js and crossfilter - dc.js

I have the following Data...
data =
[
{rundate:"2019-05-01 00:00:00", productLevel:"Level1", QCValue : 78.00},
{rundate:"2019-05-02 00:00:00", productLevel:"Level1", QCValue : 82.00},
{rundate:"2019-05-03 00:00:00", productLevel:"Level1", QCValue : 79.00},
{rundate:"2019-05-04 00:00:00", productLevel:"Level1", QCValue : 81.00},
{rundate:"2019-05-05 00:00:00", productLevel:"Level1", QCValue : 78.00},
{rundate:"2019-05-06 00:00:00", productLevel:"Level1", QCValue : 80.00},
{rundate:"2019-05-07 00:00:00", productLevel:"Level1", QCValue : 81.00},
{rundate:"2019-05-01 00:00:00", productLevel:"Level2", QCValue : 175.00},
{rundate:"2019-05-03 00:00:00", productLevel:"Level2", QCValue : 180.00},
{rundate:"2019-05-04 00:00:00", productLevel:"Level2", QCValue : 179.00},
{rundate:"2019-05-06 00:00:00", productLevel:"Level2", QCValue : 176.00},
{rundate:"2019-05-08 00:00:00", productLevel:"Level2", QCValue : 178.00},
{rundate:"2019-05-09 00:00:00", productLevel:"Level2", QCValue : 176.00},
{rundate:"2019-05-10 00:00:00", productLevel:"Level2", QCValue : 177.00}
];
I need to plot two Levey-Jennings Charts ( could be 'N' Charts ) one for each of the productLevels ( ie Level1 and Level2 ). I can't use the 'series' example because they have to be two different charts.
In both the cases the dimension is rundate...
I would like to know how to set up the dimension and group for each one of them so that the dimension is filtered by the ProductLevel value ( such as Level1, Level2 etc).
I would also need the mean, min, max and std dev for each of the product Level-values. I guess that can be done using group.reduce Function.

Related

Elastic search aggregation key value

PRODUCT 1
"attributes_list" : {
"src1" : [
{
"aname" : "Manufacturer Standard Lead Time",
"avalue" : "16 Weeks"
},
{
"aname" : "Color",
"avalue" : "red"
},
{
"aname" : "Detailed Description",
"avalue" : "Pre-Biased Bipolar
},
{
"aname" : "DC Current Gain (hFE) (Min) # Ic, Vce",
"avalue" : "100 # 10mA, 5V"
},
{
"aname" : "Transistor Type",
"avalue" : "2 NPN - Pre-Biased (Dual)"
},
{
"aname" : "Mounting Type",
"avalue" : "Surface Mount"
}
]
}
PRODUCT 2-------------
"attributes_list" : {
"src1" : [
{
"aname" : "Lead Time",
"avalue" : "16 Weeks"
},
{
"aname" : "Color",
"avalue" : "green"
},
{
"aname" : "Description",
"avalue" : "Pre-Biased Bipolar
},
{
"aname" : "DC Current Gain (hFE) ",
"avalue" : "100 # 10mA, 5V"
},
{
"aname" : "Transistor",
"avalue" : "2 NPN - Pre-Biased (Dual)"
},
{
"aname" : "Type",
"avalue" : "Surface Mount"
}
]
}
The question is
How can i get all the colors (avalues) by key.
like:
aggs
Colors
Red
doc_count 10
Green
doc_count 5
Simple is
We need to get all the colors by key.
We have tried different aggs queries on avalue but all are getting all the avalues. We need just to get all the avalue:colors [red,green etc ] by aname:color.

MIT APP INVENTOR 2 dictionary trouble

MIT APP INVENTOR 2 I have this problem: I have a dictionary with many sub-classes. But I have no idea how I could access to specific data inside the dictionary. For example a have the next list:
{
"keystatus" : "valid",
"status" : 0,
"result" : [
{
"stores" : {
"0" : {
"category" : "",
"min_price" : "64.90",
"manufacturer" : "adidas",
"url" : "https:\/\/www.rakuten.de\/%20produkt%20\/adidas-leonero-herrenschuhe-sneaker-2040331525.html?portaldv=6",
"title" : "adidas Leonero Herrenschuhe Sneaker",
"advertiser" : "Rakuten Deutschland GmbH",
"currency" : "€",
"max_price" : ""
}
},
"details" : {
"barcode_formats" : "EAN 4058025901204",
"color" : "",
"publisher" : "",
"weight" : "",
"actor" : "",
"brand" : "adidas",
"product_name" : "adidas Leonero Herrenschuhe Sneaker",
"category" : "",
"prod_details" : "",
"manufacturer" : "adidas",
"length" : "",
"label" : "",
"clothing_size" : "",
"artist" : "",
"height" : "",
"model" : "",
"width" : "",
"director" : "",
"genre" : "",
"manufacturer_part_number" : "Adidas Leonero",
"long_description" : "Nach 70 Jahren als einer der weltbesten Hersteller von FuBballschuhen hat adidas jede Menge Erfahrung gesammelt, wenn es um cleanen Sportstyle geht. Wir haben uns von einigen der legendärsten Designs aus unseren Archiven inspirieren lassen und m",
"features" : "",
"author" : ""
},
"reviews" : {
},
"type" : "EAN",
"images" : {
"0" : "https:\/\/images.barcodelookup.com\/9152\/91526482-1.jpg"
},
"barcode" : "4058025901204"
}
]
}
I want to access to this part of the dictionary ["result"][0]["stores"]["0"]["title"] . Any thoughts?
All ideas are welcome. Thanks
You will have to learn how to work with lists and list of lists...
See these examples:
How to work with Lists by Saj
How to work with Lists and Lists of lists (pdf) by appinventor.org
JSON and list of lists: example1 and example2

Square point of sale web app-"auto_return" does not work

I am setting the return to true, but when i complete the payment on square, the app does not redirect on its own.
{
"amount_money": {
"amount" : "100",
"currency_code" : "USD"
},
"auto_return":true,
"callback_url" : "https://floating-inlet-19449.herokuapp.com/redirect",
"client_id" : "sq0idp-U8x6mJyLFtHuhCfv9sqL5g",
"version": "1.3",
"notes": "notes for the transaction",
"options" : {
"supported_tender_types" : ["CREDIT_CARD"]
}
auto_return should be nested in the options object, like this:
{
"amount_money": { "amount" : 100, "currency_code" : "USD" },
"callback_url" : "https://floating-inlet-19449.herokuapp.com/redirect",
"client_id" : "sq0idp-U8x6mJyLFtHuhCfv9sqL5g",
"version": "1.3",
"notes": "notes for the transaction",
"options" : {
"supported_tender_types" : ["CREDIT_CARD"],
"auto_return": true
}

Google places API not returning address components

My program is trying to determine the City, state, and country based on some text, for example "New york yankee stadium" I want to get New york city, NY, USA. I am using Google places API to do this. According to the documentations, the API should return a list of address component https://developers.google.com/places/web-service/details. However, right now its only returning formatted address "1 E 161st St, Bronx, NY 10451, United States".
here is my web service url
https://maps.googleapis.com/maps/api/place/textsearch/json?key=MY_KEY&query=new%20york%20yankee%20stadium
Anyone familiar with google places API that can let me know if I am not writting the right query or parameter?
{
"html_attributions" : [],
"results" : [
{
"formatted_address" : "1 E 161st St, Bronx, NY 10451, United States",
"geometry" : {
"location" : {
"lat" : 40.82964260000001,
"lng" : -73.9261745
},
"viewport" : {
"northeast" : {
"lat" : 40.83279975,
"lng" : -73.92236575000001
},
"southwest" : {
"lat" : 40.82643674999999,
"lng" : -73.93052034999999
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "3d78036d61d35f48650bda737226432b57d82511",
"name" : "Yankee Stadium",
"opening_hours" : {
"open_now" : true,
"weekday_text" : []
},
"photos" : [
{
"height" : 540,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/101696810905045719819/photos\"\u003eYankee Stadium\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAIxmCLrNS_XZ2FcJqVvRVtBUlNYMBVTVKppOWBu7sICj2q70cqJARBoJlTcZpydbMTzURKWWMVJhYpVCqsnia5pjmDhjvjsTirrEnAc6gvmRYKuUwgewB9Re--FulXzXZ5DY3P9fkwIwuc4U9BJVbqHD5O-N6SbbHcqn4XHUj_OdEhCoNPZ3kiNJhxOCGdYG5O4DGhTqVfUjdq7JzasqYATvQxkL1-H3xg",
"width" : 1242
}
],
"place_id" : "ChIJcWnnWiz0wokRCB6aVdnDQEk",
"rating" : 4.4,
"reference" : "CmRRAAAA5dHiw1YmLxW60_jITBZjMiUs48L4aVUqlPnPDpN_ySa7rw8kPp04WWk0qf8mG-kkMFSNzh39lP0YwfynW54tLcY4s_EYbAPvNWTMe6wXHm_FJiVbI0Lfenyxz4yOTzunEhDgI64EWoXkQe9k45y6qP3-GhSVSdCMPPZA3joFbnYGV-bqo2e0lw",
"types" : [ "stadium", "point_of_interest", "establishment" ]
}
],
"status" : "OK"
}
Its a two step process, first search and get the place_id from google places search service,
use the returned place_id and pass it with another call to receive the individual address components,
https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJcWnnWiz0wokRCB6aVdnDQEk&key=
{"html_attributions": [],
"result": {
"address_components": [
{
"long_name": "1",
"short_name": "1",
"types": [
"street_number"
]
},
{
"long_name": "East 161st Street",
"short_name": "E 161st St",
"types": [
"route"
]
},
{
"long_name": "Concourse",
"short_name": "Concourse",
"types": [
"neighborhood",
"political"
]
},
{
"long_name": "Bronx",
"short_name": "Bronx",
"types": [
"sublocality_level_1",
"sublocality",
"political"
]
},
{
"long_name": "Bronx County",
"short_name": "Bronx County",
"types": [
"administrative_area_level_2",
"political"
]
},

Google Maps Geocoding API: How to get city/region names *consistently* in English or local language?

When I make the following request (note the language=en part!) with latitude & longitude for Warsaw, Poland,
https://maps.googleapis.com/maps/api/geocode/json?latlng=52.23,21.01&language=en
I get a result list which includes the following:
Result 3 (neighborhood):
{
"address_components" : [
{
"long_name" : "Śródmieście Północne",
"short_name" : "Śródmieście Północne",
"types" : [ "neighborhood", "political" ]
},
{
"long_name" : "Śródmieście",
"short_name" : "Śródmieście",
"types" : [ "sublocality_level_1", "sublocality", "political" ]
},
{
"long_name" : "Warszawa", <-- city in Polish
"short_name" : "Warszawa",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Warszawa",
"short_name" : "Warszawa",
"types" : [ "administrative_area_level_3", "political" ]
},
{
"long_name" : "Warszawa",
"short_name" : "Warszawa",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "mazowieckie", <-- region in Polish
"short_name" : "mazowieckie",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Poland",
"short_name" : "PL",
"types" : [ "country", "political" ]
}
],
[...]
"place_id" : "ChIJjaxkh4rMHkcR1lza9qbbnrU",
"types" : [ "neighborhood", "political" ]
}
Result 4 (sublocality_level_1):
{
"address_components" : [
{
"long_name" : "Śródmieście",
"short_name" : "Śródmieście",
"types" : [ "sublocality_level_1", "sublocality", "political" ]
},
{
"long_name" : "Warsaw", <-- city in English
"short_name" : "Warsaw",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Warszawa",
"short_name" : "Warszawa",
"types" : [ "administrative_area_level_3", "political" ]
},
{
"long_name" : "Warszawa",
"short_name" : "Warszawa",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Masovian Voivodeship", <-- region in English
"short_name" : "Masovian Voivodeship",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Poland",
"short_name" : "PL",
"types" : [ "country", "political" ]
}
],
[...]
"place_id" : "ChIJ8e41PvbMHkcRit4n8qe36Ns",
"types" : [ "sublocality_level_1", "sublocality", "political" ]
},
The main problem with this is the inconsistency for the same address components (locality, administrative_area_level_1) - sometimes English (as requested), sometimes the local language. Without some other ID to know that these refer to the same administrative reality, I can't be sure of that, unless I used another source of English & local geo names and did some pattern matching.
Is there a way to get around this problem? Or could someone suggest a reverse geocoding service not having such issues?
Many thanks!
I ran into the same problem. I wrote an if/else group to grab location data in order of preference.
foreach ($data->results[0]->address_components as $stuff) {
// city
if ($stuff->types[0] == 'locality') {
$zip->locality_short = $stuff->short_name;
$zip->locality_long = $stuff->long_name;
} elseif ($stuff->types[0] == 'sublocality_level_1') {
$zip->locality_short = $stuff->short_name;
$zip->locality_long = $stuff->long_name;
} elseif ($stuff->types[0] == 'neighborhood') {
$zip->locality_short = $stuff->short_name;
$zip->locality_long = $stuff->long_name;
}
// state
if ($stuff->types[0] == 'administrative_area_level_1') {
$zip->location_short = $stuff->short_name;
$zip->location_long = $stuff->long_name;
}
// country
if ($stuff->types[0] == 'country') {
$zip->country_short = $stuff->short_name;
$zip->country_long = $stuff->long_name;
}
}

Resources