Related
When I query the Google Page Speed API data is missing in the response.
Response when querying url https://www.online-it-support.dk using Pagespeed API https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://www.online-it-support.dk
The loadingExperience property is almost empty.
{
"captchaResult": "CAPTCHA_NOT_NEEDED",
"kind": "pagespeedonline#result",
"id": "https://marketing-manager.dk/",
"loadingExperience": {
"initial_url": "https://marketing-manager.dk/"
},
"lighthouseResult": {
When querying developers.google.com (https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://developers.google.com/)
the loadingExperince is filled with data
{
"captchaResult": "CAPTCHA_NOT_NEEDED",
"kind": "pagespeedonline#result",
"id": "https://developers.google.com/",
"loadingExperience": {
"id": "https://developers.google.com/",
"metrics": {
"CUMULATIVE_LAYOUT_SHIFT_SCORE": {
"percentile": 31,
"distributions": [
{
"min": 0,
"max": 10,
"proportion": 0.28354700854700876
},
Any idea what this is caused by?
I have tried with an API key but no difference.
I think I found out that it is caused by to little data on the website. In Google Page Speed it also says it lacks data so only data in lighthouseResult is present.
I want to display these fields :name, age, addresses_id, addresses_city, addresses_primary for each person into data studio.
My JSON data
{
"data": [
{
"name": "Lio",
"age": 30,
"addresses": [
{
"id": 7834,
"city": "ML",
"primary": 1
},
{
"id": 5034,
"city": "MM",
"primary": 1
}
]
},
{
"name": "Kali",
"age": 41,
"addresses": [
{
"id": 3334,
"city": "WK",
"primary": 1
},
{
"id": 1730,
"city": "DC",
"primary": 1
}
]
},
...
]
}
there is no problem if i don't render the addresses field
return {
schema: requestedFields.build(),
rows: rows
};
//rows:
/*
"rows": [
{
"values": ["Lio", 30]
},
{
"values": ["Kali", 41]
},
...
]
*/
The problem is
I'm not able to model the nested JSON data in Google Data Studio. I
have the problem exactly in the "addresses" field.
Could anyone tell me what format should be for the rows in this case?
As you already know, for each name of your dataset, you clearly have more than one row (one person has multiple addresses). Data Studio only accepts a single data for each field, since arrays are not supported at all. So you need to work on this.
There are some ways to solve this, but always keep in mind that:
getSchema() should return all available fields for your connector (the order doesn't really matter, since Data Studio always sort alphabetically the available fields)
getData() should return a list of values. But here the order is relevant: it should be the same as the parameter passed to getData() (which means the results should be dynamic, sometimes you'll return all values, sometimes not, and the order may change).
Solution 1: Return multiple rows per record
Since you can produce multiple rows for each name, just do it.
To achieve this, your field definition (=getSchema()) should include fields address_id, address_city and address_primary (you can also add address_order if you need to know the position of the address in the list).
Supposing getData() is called with all fields in the same order they were discribed, rows array should look like this:
"rows": [
{
"values": ["Lio", 30, "7834", "ML", 1]
},
{
"values": ["Lio", 30, "5034", "MM", 1]
},
{
"values": ["Kali", 41, "3334", "WK", 1]
},
{
"values": ["Kali", 41, "1730", "DC", 1]
},
...
]
IMO, this is the best solution for your data.
Solution 2: Return one address only, ignoring others
If you prefer one row per person, you can get one of the addresses and display only it (usually the main/primary address, or the first one).
To achieve this, your field definition (=getSchema()) should include fields address_id, address_city and address_primary.
Supposing getData() is called with all fields in the same order they were discribed, rows array should look like this:
"rows": [
{
"values": ["Lio", 30, "7834", "ML", 1]
},
{
"values": ["Kali", 41, "3334", "WK", 1]
},
...
]
Solution 3: Return all addresses, serialized in a field
This is helpful if you really need all information but do not want a complex scheme.
Just create a field called addresses in your field definition (=getSchema()) and write the JSON there as a string (or any other format you want).
Supposing getData() is called with all fields in the same order they were discribed, rows array should look like this:
"rows": [
{
"values": ["Lio", 30, "[{\"id\": 7834, \"city\": "ML", \"primary\": 1}, {\"id\": 5034, \"city\": \"MM\", \"primary\": 1}]"]
},
{
"values": ["Kali", 41, "[{\"id\": 3334, \"city\": \"WK\", \"primary\": 1}, {\"id\": 1730, \"city\": \"DC\", \"primary\": 1}]"]
},
...
]
This solution may appear senseless, but it is possible to interact with this data later in DataStudio using REGEX if really needed.
Solution 4: Create a different field for each address
If you're sure all records has a maximum number of addresses (in you example, both names have 2 addresses, for example), you can create multiple fields.
Your field definition (=getSchema()) should include fields address_id1, address_city1, address_primary1, address_id2, ... address_primaryN.
I wouldn't explain how rows should look like in this situation, but it is not hard to guess with the other examples.
I am trying to build a dashboard with multiple plotly graphs in Javascript. I would like to implement a crossfilter function within the charts where the selected data in a graph will be highlighted in the other graphs on the same id. Please see an example below:
Dataset Graph 1:
[{
"id": "1",
"ItemWidth" : 545,
"ItemLength" : 234
},
{
"id": "2",
"ItemWidth" : 33,
"ItemLength" : 2234234
}]
Dataset Graph 2:
[{
"id": "1",
"ItemSold" : 44,
"AnotherAtt" : 567
},
{
"id": "2",
"ItemSold" : 1213,
"AnotherAtt" : 656
}]
As you can see the datasets are different but they have the same id. I would like to know how to implement a crossfilter on id based on the datasets within multiple graphs where they share the same id.
Any help and advise is appreciated.
I am converting a JSON Object as below to XML File for download.
1) JSON:
[
{
"entityid": 11,
"claimid": 221
},
{
"entityid": 11,
"claimid": 456
},
{
"entityid": 11,
"claimid": 6478
},
{
"entityid": 11,
"claimid": 4343
},
{
"entityid": 11,
"claimid": 444
},
{
"entityid": 11,
"claimid": 789
},
{
"entityid": 11,
"claimid": 56
}
]
2) XML:
To start with, I converted the JSON object into XML String but see the numbers displaying for each row... <0>, , <1>, etc...
<0><entityid>11</entityid><claimid>221</claimid></0>
<1><entityid>11</entityid><claimid>456</claimid></1>
<2><entityid>11</entityid><claimid>6478</claimid></2>
<3><entityid>11</entityid><claimid>4343</claimid></3>
<4><entityid>11</entityid><claimid>444</claimid></4>
<5><entityid>11</entityid><claimid>789</claimid></5>
<6><entityid>11</entityid><claimid>56</claimid></6>
3) CODE for conversion of JSON to XML:
var jsonObj = JSON.parse(JSONDownloadString);
console.log(json2xml(jsonObj));
How do I get rid of the numbers at start and end for each record?
Subsequently how do I get this into a file for Download ?
Pls help.
There is no canonical transformation from JSON to XML. One area where this is particularly obvious is with lists. There is no notion of a list in XML, only a tree of elements. As such you have many options for how you would like to construct lists in XML. The tool you have chosen has made the decision to include the index of the item as an element that wraps the list item. If you don't like that you could find a different tool or manually create the XML yourself.
I need to create a stacked bar chart showing the engine status in a day. Here is the example of what I would like to have:
It looks like a gantt chart, but probably much simpler than a normal gantt chart. I am badly looking for a JavaScript/jQuery charting library which supports this kind of chart. I know lots of gantt chart library available, but wondering which library have the option/setting for the chart I want.
My data would be in this format:
[
{
"day": "2009-07-13",
"work": ["11:16:35-12:03:12", "12:32:48-13:26:28", "13:39:09-13:39:12", "13:41:03-13:41:05", "14:18:09-24:00:00"]
}, {
"day": "2009-07-14",
"work": ["00:00:00-07:22:25", "07:22:25-07:22:28", "10:10:04-10:10:31", "10:10:32-10:15:33", "10:18:07-10:21:19", "11:04:49-11:06:15", "11:12:50-11:19:05", "11:19:11-11:19:19", "11:45:50-11:51:42", "11:51:43-11:53:55", "14:03:13-14:13:04", "14:23:55-14:31:28", "14:31:28-14:38:00", "14:38:00-14:49:04", "16:34:56-16:44:33", "16:46:37-16:48:10", "16:48:11-24:00:00"]
}, {
"day": "2009-07-15",
"work": ["00:00:00-08:16:23", "09:57:57-10:15:05"]
}, {
"day": "2009-07-16",
"work": ["10:02:40-10:05:56", "10:07:16-10:09:26", "10:09:27-10:09:28", "13:18:31-24:00:00"]
}, {
"day": "2009-07-17",
"work": ["00:00:00-08:56:41", "16:07:58-16:08:23"]
}, {
"day": "2009-07-20",
"work": ["14:44:47-14:48:35", "15:09:14-16:47:06", "16:47:05-16:47:10", "16:47:13-16:47:15", "16:47:16-16:47:20"]
}, {
"day": "2009-07-21",
"work": ["10:52:51-16:37:07"]
}, {
"day": "2009-07-24",
"work": ["14:54:38-16:03:07", "16:16:23-16:35:14", "16:35:17-16:41:22", "16:43:37-23:56:37"]
}, {
"day": "2009-07-25",
"work": ["20:36:34-21:24:28", "21:24:43-23:45:53"]
}, {
"day": "2009-07-26",
"work": ["13:46:59-18:09:09"]
}, {
"day": "2009-07-28",
"work": ["13:48:30-13:51:10", "13:51:18-13:51:27", "13:52:17-14:57:31"]
}, {
"day": "2009-07-29",
"work": ["14:50:15-14:50:16", "15:36:17-15:43:51", "15:53:31-16:29:30", "16:57:50-23:07:28"]
}, {
"day": "2009-07-30",
"work": ["11:25:29-11:41:32", "16:06:37-16:33:09", "21:14:04-21:20:18", "21:53:57-22:18:59"]
}
]
The work attribute time slot is when the engine is working, the slots between work time slots is when the engine is off.
Have been looking for this for long. Any suggestion would be greatly appreaciated!
You could use JavaScript InfoVis Toolkit or make your own custom renderer.
Maybe you could modify BarChart example, so that it would display time in y-axis.
If you decide to write your own control then library like Raphael will help you a lot.
Anyways, it seems to be quite simple control, so there isn't any need for external dependencies to Flash, Silverlight etc.
You can try Flot which has a good looking Gantt chart plugin.
Example data:
var d1 = [
[Date.UTC(2010, 0, 1, 11, 23), 5, Date.UTC(2010, 0, 1, 11, 25), "Put Water into Pot"],
[Date.UTC(2010, 0, 1, 11, 35), 5, Date.UTC(2010, 0, 1, 11, 47), "Clean Cooker"],
[Date.UTC(2010, 0, 1, 11, 25), 4, Date.UTC(2010, 0, 1, 11, 27), "Put Pot on Cooker"]
]
From plugin specification:
var data = [
[Date.UTC(2010,0,25,12,45),1,Date.UTC(2010,0,25,13,15],"Name of Step"]
First Parameter is Start of Step.
Second is number of resource.
Third is End of step.
Fourth describes Name for step (used for tooltip).
I'm working on a timeline feature for jqplot. http://www.jqplot.com/
I've a JsFiddle with an example here: http://jsfiddle.net/NVbjv/8/
It's still work in progress and I need to figure out a few things. Take a look at some of my questions here at stackoverflow if you like to learn more. I hope to be able to evolve it in somekind of a plug-in.
( display pointlabel in highlighter jqplot , jqplot text labels on y-axis )