sineverba
Posts: 3
Joined: Fri Oct 16, 2015 11:23 am

Server side export a map with export server

Hi to all,
I need to export a map as PNG from server side. I'm tryng from several hours against `https://export.highcharts.com` but my best result is

Code: Select all

No chart data found. Please make sure you are using application/json or multipart/form-data headers, and that the chart
data is in the options attribute if sending JSON.
This is the body that I'm passing in POST (taken from some fiddle). Please, where is my wrong? Or... Do you have a working example?

Thank you in advance!

Code: Select all

{
	"chart": {
		"type": "map"
	},
	"series": [{
		"mapData": {
			"title": "United States of America",
			"version": "1.1.2",
			"type": "FeatureCollection",
			"copyright": "Copyright (c) 2015 Highsoft AS, Based on data from Natural Earth",
			"copyrightShort": "Natural Earth",
			"copyrightUrl": "http://www.naturalearthdata.com",
			"crs": {
				"type": "name",
				"properties": {
					"name": "urn:ogc:def:crs:EPSG:102004"
				}
			},
			"hc-transform": {
				"default": {
					"crs": "+proj=lcc +lat_1=33 +lat_2=45 +lat_0=39 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs",
					"scale": 0.000151481324748,
					"jsonres": 15.5,
					"jsonmarginX": -999,
					"jsonmarginY": 9851.0,
					"xoffset": -2361356.09818,
					"yoffset": 1398996.77886
				},
				"us-all-hawaii": {
					"xpan": 190,
					"ypan": 417,
					"hitZone": {
						"type": "Polygon",
						"coordinates": [
							[
								[1747, 3920],
								[3651, 2950],
								[3651, -999],
								[1747, -999],
								[1747, 3920]
							]
						]
					},
					"crs": "+proj=aea +lat_1=8 +lat_2=18 +lat_0=13 +lon_0=-157 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs",
					"scale": 0.000123090941806,
					"jsonres": 15.5,
					"jsonmarginX": -999,
					"jsonmarginY": 9851.0,
					"xoffset": -338610.47557,
					"yoffset": 1022754.31736
				},
				"us-all-alaska": {
					"rotation": -0.0174532925199,
					"xpan": 5,
					"ypan": 357,
					"hitZone": {
						"type": "Polygon",
						"coordinates": [
							[
								[-999, 5188],
								[-707, 5188],
								[1747, 3920],
								[1747, -999],
								[-999, -999],
								[-999, 5188]
							]
						]
					},
					"crs": "+proj=tmerc +lat_0=54 +lon_0=-142 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs",
					"scale": 5.84397059179e-05,
					"jsonres": 15.5,
					"jsonmarginX": -999,
					"jsonmarginY": 9851.0,
					"xoffset": -1566154.00853,
					"yoffset": 1992671.14918
				}
			},

			"features": [{
				"type": "Feature",
				"id": "US.MA",
				"properties": {
					"hc-group": "admin1",
					"hc-middle-x": 0.36,
					"hc-middle-y": 0.47,
					"hc-key": "us-ma",
					"hc-a2": "MA",
					"labelrank": "0",
					"hasc": "US.MA",
					"woe-id": "2347580",
					"state-fips": "25",
					"fips": "US25",
					"postal-code": "MA",
					"name": "Massachusetts",
					"country": "United States of America",
					"region": "Northeast",
					"longitude": "-71.99930000000001",
					"woe-name": "Massachusetts",
					"latitude": "42.3739",
					"woe-label": "Massachusetts, US, United States",
					"type": "State"
				},
				"geometry": {
					"type": "MultiPolygon",
					"coordinates": [
						[
							[
								[9430, 7889],
								[9476, 7878],
								[9436, 7864],
								[9417, 7844],
								[9430, 7889]
							]
						],
						[
							[
								[9314, 7915],
								[9312, 7927],
								[9304, 7921],
								[9278, 7938],
								[9254, 7990],
								[9177, 7968],
								[8997, 7925],
								[8860, 7896],
								[8853, 7901],
								[8856, 8080],
								[8922, 8096],
								[9005, 8115],
								[9005, 8115],
								[9222, 8166],
								[9242, 8201],
								[9300, 8236],
								[9318, 8197],
								[9357, 8186],
								[9312, 8147],
								[9299, 8081],
								[9324, 8091],
								[9365, 8074],
								[9428, 7985],
								[9483, 7974],
								[9525, 8007],
								[9501, 8067],
								[9535, 8028],
								[9549, 7982],
								[9504, 7965],
								[9420, 7906],
								[9411, 7955],
								[9371, 7921],
								[9373, 7898],
								[9339, 7878],
								[9327, 7915],
								[9314, 7915]
							]
						]
					]
				}
			}, {
				"type": "Feature",
				"id": "US.WA",
				"properties": {
					"hc-group": "admin1",
					"hc-middle-x": 0.56,
					"hc-middle-y": 0.52,
					"hc-key": "us-wa",
					"hc-a2": "WA",
					"labelrank": "0",
					"hasc": "US.WA",
					"woe-id": "2347606",
					"state-fips": "53",
					"fips": "US53",
					"postal-code": "WA",
					"name": "Washington",
					"country": "United States of America",
					"region": "West",
					"longitude": "-120.361",
					"woe-name": "Washington",
					"latitude": "47.4865",
					"woe-label": "Washington, US, United States",
					"type": "State"
				},
				"geometry": {
					"type": "MultiPolygon",
					"coordinates": [
						[
							[
								[-77, 9797],
								[-56, 9768],
								[-91, 9757],
								[-86, 9712],
								[-136, 9751],
								[-111, 9756],
								[-77, 9797]
							]
						],
						[
							[
								[-52, 9689],
								[-85, 9658],
								[-66, 9645],
								[-43, 9568],
								[-77, 9588],
								[-74, 9635],
								[-89, 9664],
								[-52, 9690],
								[-60, 9697],
								[-61, 9737],
								[-31, 9701],
								[-12, 9731],
								[-9, 9774],
								[-33, 9788],
								[-46, 9839],
								[-32, 9851],
								[926, 9593],
								[767, 8925],
								[779, 8870],
								[774, 8822],
								[398, 8914],
								[378, 8905],
								[289, 8922],
								[163, 8905],
								[94, 8923],
								[38, 8914],
								[-10, 8925],
								[-22, 8950],
								[-113, 8979],
								[-207, 8965],
								[-283, 9014],
								[-271, 9096],
								[-280, 9134],
								[-321, 9167],
								[-357, 9171],
								[-365, 9207],
								[-400, 9226],
								[-436, 9219],
								[-460, 9259],
								[-436, 9333],
								[-441, 9279],
								[-416, 9297],
								[-401, 9347],
								[-434, 9357],
								[-429, 9395],
								[-369, 9396],
								[-424, 9436],
								[-424, 9523],
								[-410, 9624],
								[-433, 9678],
								[-428, 9749],
								[-385, 9790],
								[-313, 9713],
								[-183, 9655],
								[-161, 9666],
								[-146, 9623],
								[-100, 9637],
								[-95, 9567],
								[-135, 9518],
								[-77, 9566],
								[-112, 9491],
								[-89, 9426],
								[-154, 9433],
								[-175, 9394],
								[-167, 9449],
								[-222, 9394],
								[-157, 9376],
								[-124, 9418],
								[-82, 9426],
								[-82, 9476],
								[-66, 9527],
								[-18, 9570],
								[-37, 9644],
								[-24, 9661],
								[-52, 9689]
							]
						]
					]
				}
			}]
		},
		"data": [{
			"hc-key": "us-ma",
			"value": 42
		}, {
			"hc-key": "us-wa",
			"value": 43
		}],
		"joinBy": ["hc-key"]
	}]
}
If I surround the body on top with an

Code: Select all

{"infile": {...}}
I get a blank chart type and not a map:

Image
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Server side export a map with export server

Hi sineverba!
Thanks for contacting us with your question!

I think all you are missing is a general option parameter --constr, which is responsible for the constructor with which the chart will be generated. In your case, you should set it to mapChart. Also on the online exporting page, you should set the constructor to map.

Docs: https://github.com/highcharts/node-expo ... -arguments

Let me know if you have any further questions.
Regards!
Hubert Kozik
Highcharts Developer

Return to “Highcharts Maps”