How can I use special input format in Highcharts? - highcharts

I have an input, which you can see below:
{
"Data": [{
"Time": "00:00:00",
"Value": 2959.927000
}, {
"Time": "00:15:00",
"Value": 2959.927000
}, {
"Time": "00:30:00",
"Value": 2959.927000
}, {
"Time": "00:45:00",
"Value": 2959.927000
}, {
"Time": "01:00:00",
"Value": 2959.927000
}, {
"Time": "01:15:00",
"Value": 2959.927000
}]
}
I would like to display it, how can I?

You can use the script you found at http://karanbalkar.com/2014/06/populate-highcharts-with-json-data-using-jquery/ and then just modify the part where you populate the series:
// Populate series
for (i = 0; i < data.student_data.length; i++) {
processed_json.push({
name: data.student_data[i].key,
y: parseInt(data.student_data[i].value)
});
}
Then, you set the xAxis type to category:
xAxis: {
type: 'category'
}

Related

How to add a temporary price change of InAppPurchase with /v1/inAppPurchasePriceSchedules

Like Steve with his question, i have problem with this new API :
Unknown Error trying to add Pricing to a In App Purchase String
I followed Guide from Apple :
https://developer.apple.com/documentation/appstoreconnectapi/app_store/in-app_purchase/managing_in-app_purchases
I can change price from inAppPurchase but now i'm stuck with "Promotional Price".
For example, my inApp Puchase have a product tiers 8 at 9.99€ and from 1 November 2022 to 30 November i want a different price (product tiers 4 at 4.99€). The first of December, price will go back to 9.99€.
When testing inAppPurchasePriceSchedules POST, i have 409 error (Conflict) or 500 error.
Here one of payload i test :
{
"data": {
"relationships": {
"inAppPurchase": {
"data": {
"id": 1592386688,
"type": "inAppPurchases"
}
},
"manualPrices": {
"data": [{
"type": "inAppPurchasePrices",
"id": "${prices-id}"
}, {
"type": "inAppPurchasePrices",
"id": "${prices-id-1}"
}
]
}
},
"type": "inAppPurchasePriceSchedules"
},
"included": [{
"attributes": {
"startDate": "2022-11-01"
},
"id": "${prices-id}",
"relationships": {
"inAppPurchasePricePoint": {
"data": {
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiMyJ9", //Tiers 5
"type": "inAppPurchasePricePoints"
}
},
"inAppPurchaseV2": {
"data": {
"id": "1592386688",
"type": "inAppPurchases"
}
}
}
}, {
"attributes": {
"startDate": "2022-12-01"
},
"id": "${prices-id-1}",
"relationships": {
"inAppPurchasePricePoint": {
"data": {
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiNSJ9", //Tiers 10
"type": "inAppPurchasePricePoints"
}
},
"inAppPurchaseV2": {
"data": {
"id": "1592386688",
"type": "inAppPurchases"
}
}
},
"type": "inAppPurchasePrices"
}
]
}
I tried with 3 manualPrices, with "{$price1}" or "{$price2}" as id.
I tried with id from current price...
I'm missing something, I must be close by...
Update
after using Fiddler on appstoreconnect.apple.com and adding / removing promotion i was able to create this payload :
{
"data": {
"type": "inAppPurchasePriceSchedules",
"relationships": {
"inAppPurchase": {
"data": {
"type": "inAppPurchases",
"id": "1592386688"
}
},
"manualPrices": {
"data": [{
"type": "inAppPurchasePrices",
"id": "${price1}"
}, {
"type": "inAppPurchasePrices",
"id": "${price2}"
}, {
"type": "inAppPurchasePrices",
"id": "${price3}"
}
]
}
}
},
"included": [{
"type": "inAppPurchasePrices",
"id": "${price1}",
"attributes": {
"startDate": null
},
"relationships": {
"inAppPurchaseV2": {
"data": {
"type": "inAppPurchases",
"id": "1592386688"
}
},
"inAppPurchasePricePoint": {
"data": {
"type": "inAppPurchasePricePoints",
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiNSJ9"
}
}
}
}, {
"type": "inAppPurchasePrices",
"id": "${price2}",
"attributes": {
"startDate": "2022-11-01"
},
"relationships": {
"inAppPurchaseV2": {
"data": {
"type": "inAppPurchases",
"id": "1592386688"
}
},
"inAppPurchasePricePoint": {
"data": {
"type": "inAppPurchasePricePoints",
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiMyJ9"
}
}
}
}, {
"type": "inAppPurchasePrices",
"id": "${price3}",
"attributes": {
"startDate": "2022-12-01"
},
"relationships": {
"inAppPurchaseV2": {
"data": {
"type": "inAppPurchases",
"id": "1592386688"
}
},
"inAppPurchasePricePoint": {
"data": {
"type": "inAppPurchasePricePoints",
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiNSJ9"
}
}
}
}
]
}
This one worked !
Thanks
Guldil

Geojson gets distorted when trying to render in vega

I try to render a geojson in vega.
I found this example which work fine:
How to read geojson with vega
however, when trying to replace the geojson with one of mine, the features get completely distorted.
{"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"width": 500,
"height": 600,
"autosize": "none",
"signals": [
{
"name": "translate0",
"update": "width / 2"
},
{
"name": "translate1",
"update": "height / 2"
}
],
"projections": [
{
"name": "projection",
"type": "mercator",
"scale": 1000,
"rotate": [
0,
0,
0
],
"center": [
17,
-3
],
"translate": [
{
"signal": "translate0"
},
{
"signal": "translate1"
}
]
}
],
"data": [
{
"name": "drc",
"url": "https://gist.githubusercontent.com/thomas-maschler/ef9891ef03ed4cf3fb23a4378dab485e/raw/47f3632d2135b9a783eeb76d0091762b70677c0d/drc.geojson",
"format": {
"type": "json",
"property": "features"
}
}
],
"marks": [
{
"type": "shape",
"from": {
"data": "drc"
},
"encode": {
"update": {
"strokeWidth": {
"value": 0.5
},
"stroke": {
"value": "darkblue"
},
"fill": {
"value": "lightblue"
},
"fillOpacity": {
"value": 0.5
}
},
"hover": {
"fill": {
"value": "#66C2A5"
},
"strokeWidth": {
"value": 2
},
"stroke": {
"value": "#FC8D62"
}
}
},
"transform": [
{
"type": "geoshape",
"projection": "projection"
}
]
}
]
}
Here is what they are suppose to look like
https://gist.github.com/thomas-maschler/ef9891ef03ed4cf3fb23a4378dab485e
What am I getting wrong?
Thanks,
Thomas
Not sure what happened. It seems your geojson was corrupt, but not really as I eventually could parse it in www.mapshaper.org. I reduced the file to 35% and then it parsed normally:
Vega-lite spec below (compile to Vega code in the editor if needed):
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"width": 700,
"height": 500,
"config": {"view": {"stroke": "transparent"}},
"layer": [
{
"data": {
"url": "https://gist.githubusercontent.com/mattijn/2ce897c2020a6e5b7ae6baf03dffe179/raw/564b6d484657864dcb77d0bb18db00fc7dc7668d/drc.geojson",
"format": {"type": "json", "property": "features"}
},
"mark": {"type": "geoshape", "stroke": "white", "strokeWidth": 1},
"encoding": {"color": {"value": "#bcbcbc"}}
}
]
}

How to read geojson with vega

It sounds super simple, but I can't get how can I use geojson, not topojson, for my polygons.
that's my current attempt:
"data": [
{
"name": "nabs",
"url": "both_boundaries.geojson",
"format": {"type": "json"},
"transform": [
{
"type": "geopath", "projection": "mercator",
"scale": 74, "center": [-73.99,40.72]
}
]
}
]
You have to parse the features using property within your format:
"format": {"type": "json", "property":"features"},
Full example spec:
{"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"width": 500,
"height": 600,
"autosize": "none",
"signals": [
{
"name": "translate0",
"update": "width / 2"
},
{
"name": "translate1",
"update": "height / 2"
}
],
"projections": [
{
"name": "projection",
"size": {"signal": "[width, height]"},
"fit": {"signal": "data('netherlands')"}
}
],
"data": [
{
"name": "netherlands",
"url": "https://raw.githubusercontent.com/mattijn/datasets/master/NL_outline_geo.json",
"format": {
"type": "json",
"property": "features"
}
}
],
"marks": [
{
"type": "shape",
"from": {
"data": "netherlands"
},
"encode": {
"update": {
"strokeWidth": {
"value": 0.5
},
"stroke": {
"value": "darkblue"
},
"fill": {
"value": "lightblue"
},
"fillOpacity": {
"value": 0.5
}
},
"hover": {
"fill": {
"value": "#66C2A5"
},
"strokeWidth": {
"value": 2
},
"stroke": {
"value": "#FC8D62"
}
}
},
"transform": [
{
"type": "geoshape",
"projection": "projection"
}
]
}
]
}

How to add data to a custom HighChart's HighMaps map? joinBy?

I created a custom map using Inkscape as described on the HighMaps docs pages at: http://www.highcharts.com/docs/maps/custom-maps
Everything up to step 16 seems to go smoothly.
Step 16 says that the only remaining thing to do is to add data or use the MapData option and this is where I am struggling.
How does one link the custom shapes in the map to data points? Using the shape name in a JoinBy?
http://jsfiddle.net/GeertClaes/aWJ2D/
$(function () {
// Initiate the chart
$('#container').highcharts('Map', {
title:{text:''},
subTitle:{text:''},
credits:{enabled:false},
legend:{enabled: false},
series:
[
{
"type": "map",
"data": [
{
"name": "Status1-CurrentPeriod",
"path": "M0,-695,0,-682C1,-682,2,-683,3,-683,15,-683,25,-672,25,-658,25,-645,15,-634,3,-634,2,-634,1,-634,1,-634L1,-622,108,-622,107,-694,0,-695z"
},
{
"name": "Status1-Period-1",
"path": "M0,-684,1,-633C15,-635,26,-646,26,-658,26,-672,14,-682,0,-684z"
},
{
"name": "Status2-CurrentPeriod",
"path": "M178,-695,178,-682C179,-682,180,-683,181,-683,193,-683,203,-672,203,-658,203,-645,193,-634,181,-634,180,-634,180,-634,179,-634L179,-622,286,-622,285,-694,178,-695z"
},
{
"name": "Status2-Period-1",
"path": "M178,-684,179,-633C193,-635,204,-646,204,-658,204,-672,193,-682,178,-684z"
},
{
"name": "Status3-CurrentPeriod",
"path": "M357,-695,357,-682C358,-682,359,-683,360,-683,372,-683,382,-672,382,-658,382,-645,372,-634,360,-634,359,-634,359,-634,358,-634L358,-622,465,-622,464,-694,357,-695z"
},
{
"name": "Status3-Period-1",
"path": "M357,-684,358,-633C372,-635,383,-646,383,-658,383,-672,372,-682,357,-684z"
},
{
"name": "Status4-CurrentPeriod",
"path": "M535,-695,535,-682C536,-682,537,-683,538,-683,550,-683,560,-672,560,-658,560,-645,550,-634,538,-634,537,-634,536,-634,536,-634L536,-622,643,-622,642,-694,535,-695z"
},
{
"name": "Status4-Period-1",
"path": "M535,-684,536,-633C550,-635,561,-646,561,-658,561,-672,549,-682,535,-684z"
},
{
"name": "Status5-CurrentPeriod",
"path": "M713,-695,713,-682C714,-682,715,-683,716,-683,728,-683,738,-672,738,-658,738,-645,728,-634,716,-634,715,-634,715,-634,714,-634L714,-622,821,-622,820,-694,713,-695z"
},
{
"name": "Status5-Period-1",
"path": "M713,-684,714,-633C728,-635,739,-646,739,-658,739,-672,728,-682,713,-684z"
},
{
"name": "Status6-CurrentPeriod",
"path": "M892,-695,892,-682C893,-682,894,-683,895,-683,907,-683,917,-672,917,-658,917,-645,907,-634,895,-634,894,-634,893,-634,893,-634L893,-622,1000,-622,999,-694,892,-695z"
},
{
"name": "Status6-Period-1",
"path": "M892,-684,893,-633C907,-635,918,-646,918,-658,918,-672,907,-682,892,-684z"
}
]
}
]
});
});
There's a couple of ways:
1.) The easiest is to add it into your data using the value property. This is discouraged because it hardcodes the value for the map paths:
"data": [
{
"name": "Status1-CurrentPeriod",
"path": "M0,-695,0,-682C1,-682,2,-683,3,-683,15,-683,25,-672,25,-658,25,-645,15,-634,3,-634,2,-634,1,-634,1,-634L1,-622,108,-622,107,-694,0,-695z",
"value": 6 // <-- here's a numerical value for this path
}
2.) Seperate your mapData from your data. Map the values in mapData to the values in data with a joinBy. This makes your map paths reusable:
series: [{
"type": "map",
"joinBy": ['name', 'name'], // <- mapping 'name' in data to 'name' in mapData
"data": [
{
"name": "Status1-CurrentPeriod",
"value": 6
}
],
"mapData": [
{
"name": "Status1-CurrentPeriod",
"path": "M0,-695,0,-682C1,-682,2,-683,3,-683,15,-683,25,-672,25,-658,25,-645,15,-634,3,-634,2,-634,1,-634,1,-634L1,-622,108,-622,107,-694,0,-695z"
}
...
}]
Update fiddle here.

Highchart Stacked Column w/ Datetime X-axis Columns Too Thin

I am trying to display to my users the number of videos recorded per day with each one of their cameras. To do so I would like to use a stacked back (each stack showing the # of videos recorded with a given camera). Here are the options I am passing in:
var options = {
"title": {
"text": null
},
"legend": {
"layout": "vertical",
"style": { },
"enabled": false
},
"xAxis": {
"type": "datetime",
"minTickInterval": 86400000
},
"yAxis": {
"stackLabels": { "enabled": true },
"title": { "text": null }
},
"tooltip": { "enabled": true },
"credits": { "enabled": false },
"plotOptions": {
"column": { "stacking": "normal" }
},
"chart": {
"defaultSeriesType": "column",
"height": 200,
"borderRadius": 0,
"renderTo": "monthy_chart"
},
"subtitle": { },
"colors": [ "#c7084b","#089fbf","#00d047","#d300d1","#f48400","#f6f400" ],
"series": [
{
"name": "Camera",
"data": [ [ 1362614400000,6 ],[ 1362528000000,2 ] ]
},
{
"name": "NewCamera2",
"data": [ [ 1362614400000,1 ] ]
}
]
};
The graph displays the data correctly but is rendering the columns extremely narrowly even when there are only 2 days of data (image below). Is there a way for me to deine the scale of the x-axis so the widths of the columns will display a bit better?
http://i.stack.imgur.com/NSSYg.png
You can set pointWidth and startOnTick / endOfTick
http://jsfiddle.net/bLrah/
"xAxis": {
startOnTick:true,
endOnTick:true,
"type": "datetime",
"minTickInterval": 86400000
http://api.highcharts.com/highcharts#xAxis.startOnTick
http://api.highcharts.com/highcharts#xAxis.endOnTick
http://api.highcharts.com/highcharts#plotOptions.column.pointWidth

Resources