Writing Box Packing Solution to txt or csv - R - r

I am using the BoxPacking package in R from here
Although I have manipulated it in many ways, the base is that I cannot export the solution to txt or preferably csv. I've tried converting to data frame or writing lines for txt as suggested here, but keep getting errors:
Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class "structure("Container", package = "BoxPacking")" to a data.frame
Is anyone familiar enough with this package to assist please?
Thanks

CSV seems like a bad choice for this since it's a nested structure. JSON wld be far more appropriate.
First, define some json serializers for the custom objects:
library(jsonlite)
setMethod(jsonlite:::asJSON, "Box", function(x, ...) {
jsonlite:::asJSON(
list(
Box =
list(
origin = x#origin,
length = unbox(x#length),
height = unbox(x#height),
width = unbox(x#width)
)
),
...
)
})
setMethod(jsonlite:::asJSON, "EMS", function(x, ...) {
jsonlite:::asJSON(
list(
EMS = list(
origin = x#origin,
length = unbox(x#length),
height = unbox(x#height),
width = unbox(x#width)
)
),
...
)
})
setMethod(jsonlite:::asJSON, "Container", function(x, ...) {
jsonlite:::asJSON(
list(
Container =
list(
origin = x#origin,
length = unbox(x#length),
height = unbox(x#height),
width = unbox(x#width),
ems = x#ems
)
),
...
)
})
then, just call jsonlite::toJSON() on the object:
[
[
{
"Container": {
"origin": [0, 0, 0],
"length": 2,
"height": 2,
"width": 2,
"ems": [
{
"EMS": {
"origin": [0, 0, 0],
"length": 2,
"height": 2,
"width": 2
}
}
]
}
}
],
[
{
"Container": {
"origin": [0, 0, 0],
"length": 2,
"height": 2,
"width": 2,
"ems": [
{
"EMS": {
"origin": [0, 0, 0],
"length": 2,
"height": 2,
"width": 2
}
}
]
}
}
],
[
{
"Container": {
"origin": [0, 0, 0],
"length": 2,
"height": 2,
"width": 2,
"ems": [
{
"EMS": {
"origin": [0, 0, 0],
"length": 2,
"height": 2,
"width": 2
}
}
]
}
}
],
[
{
"Container": {
"origin": [0, 0, 0],
"length": 2,
"height": 2,
"width": 2,
"ems": [
{
"EMS": {
"origin": [0, 1.9, 0],
"length": 2,
"height": 0.1,
"width": 2
}
},
{
"EMS": {
"origin": [0, 0, 1.9],
"length": 2,
"height": 2,
"width": 0.1
}
},
{
"EMS": {
"origin": [1.4, 0.9, 0],
"length": 0.6,
"height": 1.1,
"width": 0.4
}
},
{
"EMS": {
"origin": [0.4, 0.9, 0.4],
"length": 0.1,
"height": 0.5,
"width": 1.6
}
},
{
"EMS": {
"origin": [0, 1.8, 0],
"length": 0.4,
"height": 0.2,
"width": 0.4
}
},
{
"EMS": {
"origin": [0, 1.4, 1.5],
"length": 2,
"height": 0.6,
"width": 0.5
}
},
{
"EMS": {
"origin": [0, 1, 1.4],
"length": 0.4,
"height": 1,
"width": 0.6
}
},
{
"EMS": {
"origin": [0, 1, 1.5],
"length": 0.5,
"height": 1,
"width": 0.5
}
},
{
"EMS": {
"origin": [0, 1, 1.4],
"length": 0.5,
"height": 0.4,
"width": 0.6
}
},
{
"EMS": {
"origin": [0.9, 1.4, 0],
"length": 1.1,
"height": 0.6,
"width": 0.5
}
},
{
"EMS": {
"origin": [1.4, 1.4, 0],
"length": 0.6,
"height": 0.6,
"width": 2
}
},
{
"EMS": {
"origin": [1.5, 1.3, 0],
"length": 0.5,
"height": 0.7,
"width": 2
}
},
{
"EMS": {
"origin": [1, 1.3, 1.5],
"length": 1,
"height": 0.7,
"width": 0.5
}
},
{
"EMS": {
"origin": [1, 0, 1.4],
"length": 1,
"height": 0.9,
"width": 0.6
}
},
{
"EMS": {
"origin": [1.4, 1.3, 0.9],
"length": 0.6,
"height": 0.7,
"width": 1.1
}
},
{
"EMS": {
"origin": [1, 1.3, 0.9],
"length": 1,
"height": 0.1,
"width": 1.1
}
},
{
"EMS": {
"origin": [1.4, 0, 0.8],
"length": 0.6,
"height": 0.4,
"width": 0.1
}
},
{
"EMS": {
"origin": [1.5, 0, 0],
"length": 0.5,
"height": 2,
"width": 0.4
}
},
{
"EMS": {
"origin": [1.8, 0, 0],
"length": 0.2,
"height": 2,
"width": 0.9
}
},
{
"EMS": {
"origin": [1.5, 0, 0.8],
"length": 0.5,
"height": 2,
"width": 0.1
}
},
{
"EMS": {
"origin": [1.5, 0.4, 0],
"length": 0.5,
"height": 1.6,
"width": 0.9
}
},
{
"EMS": {
"origin": [1.8, 0, 0],
"length": 0.2,
"height": 0.5,
"width": 2
}
},
{
"EMS": {
"origin": [1.5, 0, 0.8],
"length": 0.5,
"height": 0.5,
"width": 1.2
}
},
{
"EMS": {
"origin": [1.5, 0.4, 0],
"length": 0.5,
"height": 0.1,
"width": 2
}
},
{
"EMS": {
"origin": [0.8, 0, 1.4],
"length": 1.2,
"height": 0.4,
"width": 0.6
}
},
{
"EMS": {
"origin": [0.4, 0, 1.8],
"length": 1.6,
"height": 0.4,
"width": 0.2
}
},
{
"EMS": {
"origin": [0.4, 0, 1.8],
"length": 0.1,
"height": 2,
"width": 0.2
}
},
{
"EMS": {
"origin": [0.4, 0.4, 1.5],
"length": 0.1,
"height": 1.6,
"width": 0.5
}
},
{
"EMS": {
"origin": [0.4, 0.4, 1.4],
"length": 0.1,
"height": 1,
"width": 0.6
}
}
]
}
},
{
"Box": {
"origin": [0, 0, 0],
"length": 1,
"height": 1,
"width": 0.4
}
},
{
"Box": {
"origin": [0, 0, 0.4],
"length": 1,
"height": 0.4,
"width": 1
}
},
{
"Box": {
"origin": [0, 0.4, 0.4],
"length": 0.5,
"height": 0.5,
"width": 1
}
},
{
"Box": {
"origin": [0.5, 0.4, 0.4],
"length": 1,
"height": 1,
"width": 0.5
}
},
{
"Box": {
"origin": [0, 0.9, 0.4],
"length": 0.4,
"height": 1,
"width": 1
}
},
{
"Box": {
"origin": [0.5, 0.4, 0.9],
"length": 0.5,
"height": 1,
"width": 1
}
},
{
"Box": {
"origin": [1, 0, 0],
"length": 0.5,
"height": 0.4,
"width": 0.4
}
},
{
"Box": {
"origin": [1, 0, 0.9],
"length": 0.5,
"height": 0.5,
"width": 0.5
}
},
{
"Box": {
"origin": [0, 1, 0],
"length": 1,
"height": 0.4,
"width": 0.4
}
},
{
"Box": {
"origin": [1, 0.4, 0],
"length": 0.5,
"height": 0.5,
"width": 0.4
}
},
{
"Box": {
"origin": [1, 0, 0.4],
"length": 0.4,
"height": 0.4,
"width": 0.5
}
},
{
"Box": {
"origin": [0, 0, 1.4],
"length": 0.4,
"height": 1,
"width": 0.5
}
},
{
"Box": {
"origin": [1, 0.9, 0],
"length": 0.4,
"height": 0.5,
"width": 0.4
}
},
{
"Box": {
"origin": [1, 0.5, 0.9],
"length": 1,
"height": 0.4,
"width": 0.5
}
},
{
"Box": {
"origin": [0, 1.4, 0],
"length": 0.4,
"height": 0.4,
"width": 0.4
}
},
{
"Box": {
"origin": [0.4, 1.4, 0],
"length": 0.5,
"height": 0.5,
"width": 0.5
}
},
{
"Box": {
"origin": [0.4, 1.4, 0.5],
"length": 1,
"height": 0.5,
"width": 1
}
},
{
"Box": {
"origin": [1, 0.9, 0.9],
"length": 1,
"height": 0.4,
"width": 1
}
},
{
"Box": {
"origin": [1.4, 0, 0.4],
"length": 0.4,
"height": 0.4,
"width": 0.4
}
},
{
"Box": {
"origin": [0.4, 0, 1.4],
"length": 0.4,
"height": 0.4,
"width": 0.4
}
}
]
]

Related

Particle.js Radial Gradient background to particles

i would like to use gradient backgrounds in particles, that is to say, I want the particles to each have a gradient of different colours with some shadows for depth and if at all its possible, i would like to animate the gradeients as well.
I am new to this library and am not sure if this is possible, Thanks!
i have made a simple canvas with circles bouncing around, thats all i have been able to achieve
{
"autoPlay": true,
"background": {
"color": {
"value": "#000"
},
"image": "",
"position": "",
"repeat": "",
"size": "",
"opacity": 1
},
"backgroundMask": {
"composite": "destination-out",
"cover": {
"color": {
"value": "#fff"
},
"opacity": 1
},
"enable": false
},
"defaultThemes": {},
"delay": 0,
"fullScreen": {
"enable": true,
"zIndex": -1
},
"detectRetina": true,
"duration": 0,
"fpsLimit": 120,
"interactivity": {
"detectsOn": "window",
"events": {
"onClick": {
"enable": false,
"mode": []
},
"onDiv": {
"selectors": [],
"enable": false,
"mode": [],
"type": "circle"
},
"onHover": {
"enable": false,
"mode": [],
"parallax": {
"enable": false,
"force": 2,
"smooth": 10
}
},
"resize": {
"delay": 0.5,
"enable": true
}
},
"modes": {
"attract": {
"distance": 200,
"duration": 0.4,
"easing": "ease-out-quad",
"factor": 1,
"maxSpeed": 50,
"speed": 1
},
"bounce": {
"distance": 200
},
"bubble": {
"distance": 200,
"duration": 0.4,
"mix": false,
"divs": {
"distance": 200,
"duration": 0.4,
"mix": false,
"selectors": []
}
},
"connect": {
"distance": 80,
"links": {
"opacity": 0.5
},
"radius": 60
},
"grab": {
"distance": 100,
"links": {
"blink": false,
"consent": false,
"opacity": 1
}
},
"push": {
"default": true,
"groups": [],
"quantity": 4
},
"remove": {
"quantity": 2
},
"repulse": {
"distance": 200,
"duration": 0.4,
"factor": 100,
"speed": 1,
"maxSpeed": 50,
"easing": "ease-out-quad",
"divs": {
"distance": 200,
"duration": 0.4,
"factor": 100,
"speed": 1,
"maxSpeed": 50,
"easing": "ease-out-quad",
"selectors": []
}
},
"slow": {
"factor": 3,
"radius": 200
},
"trail": {
"delay": 1,
"pauseOnStop": false,
"quantity": 1
},
"light": {
"area": {
"gradient": {
"start": {
"value": "#ffffff"
},
"stop": {
"value": "#000000"
}
},
"radius": 1000
},
"shadow": {
"color": {
"value": "#000000"
},
"length": 2000
}
}
}
},
"manualParticles": [],
"particles": {
"bounce": {
"horizontal": {
"random": {
"enable": false,
"minimumValue": 0.1
},
"value": 1
},
"vertical": {
"random": {
"enable": false,
"minimumValue": 0.1
},
"value": 1
}
},
"collisions": {
"absorb": {
"speed": 2
},
"bounce": {
"horizontal": {
"random": {
"enable": false,
"minimumValue": 1
},
"value": {
"min": 0.1,
"max": 10
}
},
"vertical": {
"random": {
"enable": false,
"minimumValue": 0.1
},
"value": {
"min": 0.1,
"max": 10
}
}
},
"enable": true,
"mode": "bounce",
"overlap": {
"enable": false,
"retries": 0
}
},
"color": {
"value": "#ff0000",
"animation": {
"h": {
"count": 0,
"enable": false,
"offset": 0,
"speed": 1,
"decay": 0,
"sync": true
},
"s": {
"count": 0,
"enable": false,
"offset": 0,
"speed": 1,
"decay": 0,
"sync": true
},
"l": {
"count": 0,
"enable": false,
"offset": 0,
"speed": 1,
"decay": 0,
"sync": true
}
}
},
"groups": {},
"move": {
"angle": {
"offset": 0,
"value": 90
},
"attract": {
"distance": 200,
"enable": false,
"rotate": {
"x": 3000,
"y": 3000
}
},
"center": {
"x": 50,
"y": 50,
"mode": "percent",
"radius": 0
},
"decay": 0,
"distance": {},
"direction": "none",
"drift": 0,
"enable": true,
"gravity": {
"acceleration": 9.81,
"enable": false,
"inverse": false,
"maxSpeed": 50
},
"path": {
"clamp": true,
"delay": {
"random": {
"enable": false,
"minimumValue": 0
},
"value": 0
},
"enable": false,
"options": {}
},
"outModes": {
"default": "bounce",
"bottom": "bounce",
"left": "bounce",
"right": "bounce",
"top": "bounce"
},
"random": true,
"size": true,
"speed": 8,
"spin": {
"acceleration": 0,
"enable": false
},
"straight": false,
"trail": {
"enable": true,
"length": 3,
"fillColor": {
"value": "#000000"
}
},
"vibrate": false,
"warp": false
},
"number": {
"density": {
"enable": false,
"area": 800,
"factor": 1000
},
"limit": 0,
"value": 14
},
"opacity": {
"random": {
"enable": false,
"minimumValue": 0.1
},
"value": 1,
"animation": {
"count": 0,
"enable": false,
"speed": 0.25,
"decay": 0,
"sync": false,
"destroy": "none",
"startValue": "random"
}
},
"reduceDuplicates": false,
"shadow": {
"blur": 4,
"color": {
"value": "#000"
},
"enable": true,
"offset": {
"x": 0,
"y": 0
}
},
"shape": {
"options": {},
"type": "circle"
},
"size": {
"random": {
"enable": false,
"minimumValue": 1
},
"value": 41,
"animation": {
"count": 0,
"enable": false,
"speed": 5,
"decay": 0,
"sync": false,
"destroy": "none",
"startValue": "random"
}
},
"stroke": {
"width": 0,
"color": {
"value": "#004cff",
"animation": {
"h": {
"count": 0,
"enable": false,
"offset": 0,
"speed": 1,
"decay": 0,
"sync": true
},
"s": {
"count": 0,
"enable": false,
"offset": 0,
"speed": 1,
"decay": 0,
"sync": true
},
"l": {
"count": 0,
"enable": false,
"offset": 0,
"speed": 1,
"decay": 0,
"sync": true
}
}
}
},
"zIndex": {
"random": {
"enable": false,
"minimumValue": 0
},
"value": 0,
"opacityRate": 1,
"sizeRate": 1,
"velocityRate": 1
},
"life": {
"count": 0,
"delay": {
"random": {
"enable": false,
"minimumValue": 0
},
"value": 0,
"sync": false
},
"duration": {
"random": {
"enable": false,
"minimumValue": 0.0001
},
"value": 0,
"sync": false
}
},
"rotate": {
"random": {
"enable": false,
"minimumValue": 0
},
"value": 0,
"animation": {
"enable": false,
"speed": 0,
"decay": 0,
"sync": false
},
"direction": "clockwise",
"path": false
},
"destroy": {
"bounds": {},
"mode": "none",
"split": {
"count": 1,
"factor": {
"random": {
"enable": false,
"minimumValue": 0
},
"value": 3
},
"rate": {
"random": {
"enable": false,
"minimumValue": 0
},
"value": {
"min": 4,
"max": 9
}
},
"sizeOffset": true,
"particles": {}
}
},
"roll": {
"darken": {
"enable": false,
"value": 0
},
"enable": false,
"enlighten": {
"enable": false,
"value": 0
},
"mode": "vertical",
"speed": 25
},
"tilt": {
"random": {
"enable": false,
"minimumValue": 0
},
"value": 0,
"animation": {
"enable": false,
"speed": 0,
"decay": 0,
"sync": false
},
"direction": "clockwise",
"enable": false
},
"twinkle": {
"lines": {
"enable": false,
"frequency": 0.05,
"opacity": 1
},
"particles": {
"enable": false,
"frequency": 0.05,
"opacity": 1
}
},
"wobble": {
"distance": 5,
"enable": false,
"speed": {
"angle": 50,
"move": 10
}
},
"orbit": {
"animation": {
"count": 0,
"enable": false,
"speed": 1,
"decay": 0,
"sync": false
},
"enable": false,
"opacity": 1,
"rotation": {
"random": {
"enable": false,
"minimumValue": 0
},
"value": 45
},
"width": 1
},
"links": {
"blink": false,
"color": {
"value": "#fff"
},
"consent": false,
"distance": 100,
"enable": false,
"frequency": 1,
"opacity": 1,
"shadow": {
"blur": 5,
"color": {
"value": "#000"
},
"enable": false
},
"triangles": {
"enable": false,
"frequency": 1
},
"width": 1,
"warp": false
},
"repulse": {
"random": {
"enable": false,
"minimumValue": 0
},
"value": 0,
"enabled": false,
"distance": 1,
"duration": 1,
"factor": 1,
"speed": 1
}
},
"pauseOnBlur": true,
"pauseOnOutsideViewport": true,
"responsive": [],
"smooth": false,
"style": {},
"themes": [],
"zLayers": 100,
"emitters": []
}

How do I draw line after receiving data - Route from GPS Trace

I just started using Here Maps. Before I used Google Direction, I want to try use 'Here Maps' API. This is example JSON result. After I got this result, How do I implement this into Polyline or Direction (MAP Here)? Thanks
{
RouteLinks: [
{
linkId: 25664478,
functionalClass: 5,
shape: "51.1017723 0.3934907 51.1018066 0.3933491 51.1018295 0.39326",
linkLength: 15.575699313408467
},
{
linkId: 25664473,
functionalClass: 4,
shape: "51.1018295 0.39326 51.1022491 0.39348",
linkLength: 44.17562556306323
},
{
linkId: 25664459,
functionalClass: 4,
shape: "51.1022491 0.39348 51.1022987 0.39351",
linkLength: 5.305684979980019
},
{
linkId: 781742854,
functionalClass: 4,
shape: "51.1022987 0.39351 51.1025505 0.39365",
linkLength: 26.670487136749067
},
{
linkId: 781742855,
functionalClass: 4,
shape: "51.1025505 0.39365 51.1027794 0.39378",
linkLength: 24.302012297623005
},
{
linkId: 25664450,
functionalClass: 4,
shape: "51.1027794 0.39378 51.1030807 0.39403",
linkLength: 33.974229462422905
},
{
linkId: 25664444,
functionalClass: 4,
shape: "51.1030807 0.39403 51.103241 0.39413",
linkLength: 17.215963662407898
},
{
linkId: 25664440,
functionalClass: 4,
shape: "51.103241 0.39413 51.1033783 0.39421 51.1035385 0.39433 51.1036797 0.39445",
linkLength: 48.32839625333388
},
{
linkId: 25664427,
functionalClass: 4,
shape: "51.1036797 0.39445 51.1038017 0.39454",
linkLength: 13.445306290244636
},
{
linkId: 860272608,
functionalClass: 4,
shape: "51.1038017 0.39454 51.1039391 0.39465",
linkLength: 15.378381014646559
},
{
linkId: 860272609,
functionalClass: 4,
shape: "51.1039391 0.39465 51.1041908 0.39484",
linkLength: 27.85427285471891
},
{
linkId: 781742870,
functionalClass: 4,
shape: "51.1041908 0.39484 51.1043282 0.39494 51.1045609 0.39506",
linkLength: 39.56626207722863
},
{
linkId: 781742871,
functionalClass: 4,
shape: "51.1045609 0.39506 51.1047287 0.39515 51.1050262 0.3953021",
linkLength: 48.951382959921716
}
],
TracePoints: [
{
confidenceValue: 1, linkIdMatched: 25664478, matchDistance: 1.46,
routeLinkSeqNrMatched: 0, lat: 51.10177, lon: 0.39349,
elevation: 0, speedMps: 0, headingDegreeNorthClockwise: 10000,
latMatched: 51.10178065190155, lonMatched: 0.3934977183445852,
timestamp: 0, headingMatched: 114.46568884011239,
minError: 1.3027890756593314
},
{
confidenceValue: 1, linkIdMatched: 25664478, matchDistance: 1.57,
routeLinkSeqNrMatched: 0, lat: 51.10181, lon: 0.39335,
elevation: 0, speedMps: 0, headingDegreeNorthClockwise: 10000,
latMatched: 51.10182, lonMatched: 0.39336,
timestamp: 0, headingMatched: -65.53429247174023,
minError: 1000000
},
{
confidenceValue: 1, linkIdMatched: 781742854, matchDistance: 1,
routeLinkSeqNrMatched: 4, lat: 51.10255, lon: 0.39366,
elevation: 0, speedMps: 0, headingDegreeNorthClockwise: 10000,
latMatched: 51.102547928304084, lonMatched: 0.3936687569824506,
timestamp: 0, headingMatched: 20.644254301899522,
minError: 0.6541474931313044
},
{
confidenceValue: 1, linkIdMatched: 860272608, matchDistance: 4.59,
routeLinkSeqNrMatched: 10, lat: 51.10398, lon: 0.39466,
elevation: 0, speedMps: 0, headingDegreeNorthClockwise: 10000,
latMatched: 51.10394, lonMatched: 0.39465,
timestamp: 0, headingMatched: 25.217234923243595,
minError: 1.2405405512432781
},
{
confidenceValue: 1, linkIdMatched: 1022687693, matchDistance: 1.33,
routeLinkSeqNrMatched: 14, lat: 51.10501, lon: 0.39533,
elevation: 0, speedMps: 0, headingDegreeNorthClockwise: 10000,
latMatched: 51.105012239590245, lonMatched: 0.39531827230152644,
timestamp: 0, headingMatched: 16.91643828307876,
minError: 0.8568378930601925
}
],
Warnings: [
{
"tracePointSeqNum": -1,
"routeLinkSeqNum": 3,
"category": 3,
"text": "Entering link 781742854 into forbidden driving direction"
}
],
MapVersion: "2013Q4" }
*linkId,shape is like that trip points which is given by Heremap api step1.
You just draw route by polyline function.
addPolylineToMap(map,linkId);
function addPolylineToMap(map,linkId) {
for (j = 0; j < (shape.length - 1); j = j + 2) {
var strip = new H.geo.Strip();
strip.pushPoint({lat: shape[j],lng: shape[j+1]});
}
}

highcharts, four aeraranges with linear gradients

I'm trying to create chart in Highcharts with four arearanges and one line. I'm doing my best to get something like on image:
arearanges
I'v managed to do something like this:
$(function () {
var rangesHI = [
[1246406400000, 90, 75],
[1248998400000, 90, 75]
],
rangesME = [
[1246406400000, 75, 60],
[1248998400000, 75, 60]
],
rangesNO = [
[1246406400000, 60, 35],
[1248998400000, 60, 35]
],
rangesLO = [
[1246406400000, 35, 15],
[1248998400000, 35, 15]
],
averages = [
[1246406400000, 31.5],
[1246492800000, 32.1],
[1246579200000, 33],
[1246665600000, 33.8],
[1246752000000, 31.4],
[1246838400000, 31.3],
[1246924800000, 38.3],
[1247011200000, 35.4],
[1247097600000, 36.4],
[1247184000000, 47.7],
[1247270400000, 47.5],
[1247356800000, 37.6],
[1247443200000, 47.7],
[1247529600000, 46.8],
[1247616000000, 47.7],
[1247702400000, 46.3],
[1247788800000, 47.8],
[1247875200000, 48.1],
[1247961600000, 57.2],
[1248048000000, 54.4],
[1248134400000, 53.7],
[1248220800000, 55.7],
[1248307200000, 54.6],
[1248393600000, 55.3],
[1248480000000, 45.3],
[1248566400000, 55.8],
[1248652800000, 65.2],
[1248739200000, 74.8],
[1248825600000, 44.4],
[1248912000000, 55],
[1248998400000, 43.6]
];
$('#container').highcharts({
title: {
text: null
},
xAxis: {
type: 'datetime'
},
yAxis: {
max:90,
min:20,
title: {
text: null
}
},
series: [{
name: 'RH',
data: averages,
zIndex: 1
}, {
data: rangesHI,
type: 'arearange',
lineWidth: 0,
fillColor: {
linearGradient: [0, 0, 0, 300],
stops: [
[0, 'rgba(255,0,0, 0.2)'],
[1, 'rgba(255,0,0, 1)']
]
},
zIndex: 0
}, {
data: rangesME,
type: 'arearange',
lineWidth: 0,
fillColor: {
linearGradient: [300, 0, 300, 400],
stops: [
[0, 'rgba(237,230,126, 0.2)'],
[1, 'rgba(237,230,126, 1)']
]
},
zIndex: 0
}, {
data: rangesNO,
type: 'arearange',
lineWidth: 0,
fillColor: {
linearGradient: [500, 0, 500, 600],
stops: [
[0, 'rgba(104,217,91, 0.2)'],
[1, 'rgba(104,217,91, 0.7)']
]
},
zIndex: 0
}, {
data: rangesLO,
type: 'arearange',
lineWidth: 0,
fillColor: {
linearGradient: [0, 0, 0, 220],
stops: [
[0, 'rgba(91,187,217, 0.2)'],
[1, 'rgba(91,187,217, 0.7)']
]
},
zIndex: 0
}]
}, function (chart) {
chart.renderer.text('EKSTREMALNA', 80, 95).css({
fontSize: '16pt',
color: 'rgba(255,0,0, 1)'
}).add();
chart.renderer.text('WYSOKA', 80, 145).css({
fontSize: '16pt',
color: 'rgba(237,230,126, 1)'
}).add();
chart.renderer.text('KOMFORTOWA', 80, 225).css({
fontSize: '16pt',
color: 'rgba(104,217,91, 01)'
}).add();
chart.renderer.text('NISKA', 80, 305).css({
fontSize: '16pt',
color: 'rgba(91,187,217, 1)'
}).add();
});
http://jsfiddle.net/qazopap4/1/ but this is far from what I'v expected.
I can't make linear gradient for each arearange separately.
You can use plotBands which allows you to apply gradients.
yAxis: {
plotBands: [{
from: 60,
to: 90,
color: {
linearGradient: [0, 0, 0, 300],
stops: [
[0, 'rgba(255,0,0, 0.2)'],
[1, 'rgba(255,0,0, 1)']
]
}
}],
max: 90,
min: 20,
title: {
text: null
}
},
Example: http://jsfiddle.net/pag5qgsm

Amchart X axis position and fill to axis

I am using AmChartXY to draw graph areas, here is the fiddle:
https://jsfiddle.net/ap60fhsu/1/
var chart = AmCharts.makeChart("chartdiv", {
"type": "xy",
"autoMarginOffset": 20,
"dataProvider": [{
"ax": 0,
"ay": 0,
"bx": 0,
"by": 0,
}, {
"ax": 8,
"ay": 1,
"bx": 12,
"by": -2,
},
{
"ax": 32,
"ay": 9,
"bx": 35,
"by": -1,
},
{
"ax": 45,
"ay": 6,
"bx": 45,
"by": -2,
},
{
"ax": 60,
"ay": 2,
"bx": 60,
"by": -2,
},
{
"ax": 70,
"ay": 0,
"bx": 70,
"by": 0,
},
{
"ax": 75,
"ay": 0,
"bx": 72,
"by": 0,
},
{
"ax": 85,
"ay": 6,
"bx": 80,
"by": -1,
},
{
"ax": 90,
"ay": 0,
"bx": 90,
"by": 0,
}],
"valueAxes": [ {
"position": "bottom",
"axisAlpha": 0,
"dashLength": 1,
"id": "x",
"title": "X Axis"
}, {
"axisAlpha": 0,
"dashLength": 1,
"position": "left",
"id": "y",
"title": "Y Axis"
}],
"plotAreaBorderAlpha": 1,
"startDuration": 1,
"graphs": [ {
"balloonText": "x:[[x]] y:[[y]]",
"fillAlphas": 0.3,
"fillToAxis": "x",
"lineAlpha": 1,
"xField": "ax",
"yField": "ay",
"lineColor": "#FF6600"
}, {
"balloonText": "x:[[x]] y:[[y]]",
"lineAlpha": 1,
"fillToAxis": "x",
"fillAlphas": 0.3,
"xField": "bx",
"yField": "by",
"lineColor": "#FCD202"
}],
"marginLeft": 64,
"marginBottom": 60,
"chartScrollbar": {},
"chartCursor": {},
"export": {
"enabled": true,
"position": "bottom-right"
}
});
As you see I have negative values for Y axis, this makes the X axis fall down from Y=0 to Y=-4 and when I use fillToAxis: x, expecting that the graph fill areas will be areas bounded with graphs and X axis corresponding to the value Y=0, I get another result. How can I move the X axis to the Y=0, or at least get the fill area result as I expect?
Thanks in advance

Getting Object's name in stdClass

I have a string like this.
{
"type": "item",
"version": "3.10.3",
"basic": {
"name": "",
"rune": {
"isrune": false,
"tier": 1,
"type": "red"
},
"gold": {
"base": 0,
"total": 0,
"sell": 0,
"purchasable": false
},
"group": "",
"description": "",
"colloq": ";",
"plaintext": "",
"consumeable": false,
"stacks": 1,
"depth": 1,
"consumed": false,
"consumeOnFull": false,
"from": [],
"into": [],
"specialRecipe": 0,
"inStore": true,
"hideFromAll": false,
"requiredChampion": "",
"stats": {
"FlatHPPoolMod": 0,
"rFlatHPModPerLevel": 0,
"FlatMPPoolMod": 0,
"rFlatMPModPerLevel": 0,
"PercentHPPoolMod": 0,
"PercentMPPoolMod": 0,
"FlatHPRegenMod": 0,
"rFlatHPRegenModPerLevel": 0,
"PercentHPRegenMod": 0,
"FlatMPRegenMod": 0,
"rFlatMPRegenModPerLevel": 0,
"PercentMPRegenMod": 0,
"FlatArmorMod": 0,
"rFlatArmorModPerLevel": 0,
"PercentArmorMod": 0,
"rFlatArmorPenetrationMod": 0,
"rFlatArmorPenetrationModPerLevel": 0,
"rPercentArmorPenetrationMod": 0,
"rPercentArmorPenetrationModPerLevel": 0,
"FlatPhysicalDamageMod": 0,
"rFlatPhysicalDamageModPerLevel": 0,
"PercentPhysicalDamageMod": 0,
"FlatMagicDamageMod": 0,
"rFlatMagicDamageModPerLevel": 0,
"PercentMagicDamageMod": 0,
"FlatMovementSpeedMod": 0,
"rFlatMovementSpeedModPerLevel": 0,
"PercentMovementSpeedMod": 0,
"rPercentMovementSpeedModPerLevel": 0,
"FlatAttackSpeedMod": 0,
"PercentAttackSpeedMod": 0,
"rPercentAttackSpeedModPerLevel": 0,
"rFlatDodgeMod": 0,
"rFlatDodgeModPerLevel": 0,
"PercentDodgeMod": 0,
"FlatCritChanceMod": 0,
"rFlatCritChanceModPerLevel": 0,
"PercentCritChanceMod": 0,
"FlatCritDamageMod": 0,
"rFlatCritDamageModPerLevel": 0,
"PercentCritDamageMod": 0,
"FlatBlockMod": 0,
"PercentBlockMod": 0,
"FlatSpellBlockMod": 0,
"rFlatSpellBlockModPerLevel": 0,
"PercentSpellBlockMod": 0,
"FlatEXPBonus": 0,
"PercentEXPBonus": 0,
"rPercentCooldownMod": 0,
"rPercentCooldownModPerLevel": 0,
"rFlatTimeDeadMod": 0,
"rFlatTimeDeadModPerLevel": 0,
"rPercentTimeDeadMod": 0,
"rPercentTimeDeadModPerLevel": 0,
"rFlatGoldPer10Mod": 0,
"rFlatMagicPenetrationMod": 0,
"rFlatMagicPenetrationModPerLevel": 0,
"rPercentMagicPenetrationMod": 0,
"rPercentMagicPenetrationModPerLevel": 0
},
"tags": [],
"maps": {
"1": true,
"8": true,
"10": true,
"12": true
}
},
"data": {
"1001": {
"name": "Boots of Speed",
"group": "BootsNormal",
"description": "<groupLimit>Limited to 1.</groupLimit><br><br><unique>UNIQUE Passive - Enhanced Movement:</unique> +25 Movement Speed<br><br><i>(Unique Passives with the same name don't stack.)</i>",
"colloq": ";",
"plaintext": "Slightly increases Movement Speed",
"into": [
"3006",
"3047",
"3020",
"3158",
"3111",
"3117",
"3009"
],
"image": {
"full": "1001.png",
"sprite": "item0.png",
"group": "item",
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"gold": {
"base": 325,
"purchasable": true,
"total": 325,
"sell": 227
},
"tags": [
"MOVEMENT",
"BOOTS"
],
"stats": {
"FlatMovementSpeedMod": 25
}
},
"1004": {
"name": "Faerie Charm",
"description": "<stats>+3 Mana Regen per 5 seconds</stats>",
"colloq": ";",
"plaintext": "Slightly increases Mana Regen",
"into": [
"3037",
"3096",
"3028",
"3070",
"3073",
"1080",
"3165"
],
"image": {
"full": "1004.png",
"sprite": "item0.png",
"group": "item",
"x": 48,
"y": 0,
"w": 48,
"h": 48
},
"gold": {
"base": 180,
"purchasable": true,
"total": 180,
"sell": 126
},
"tags": [
"MANAREGEN"
],
"stats": {
"FlatMPRegenMod": 0.6
}
},
"1006": {
its going like this I'm trying to get 1006 from "1006: { but i cant
$iveri = $iresponse->body;
foreach($iveri->data as $esya)
{
print($esya);
}
Because it's object, but i want it's name but i cant find a way to get that can you help me, I'm building database from that like getting values insade it and they will their id's they are id's of items so they cant be auto assing they had to be like in array.
1006 in your example is a key value, you need to slightly modify your loop syntax:
foreach($ivery->data as $key=>$esya) {
print $key; // This will be '1006'
print $esya;
}

Resources