How to customize the Label Frequency when zoom in [amChart(serial)] - amcharts

I am using amChart(serial) for showing graph. I have data of length more than 4000. I managed to show the last label value of category axis through "labelFunction" : formatLabel,. But now the problem is to set the label frequency =10. whenever a user zoom in the graph.
Please help, Thanks in advance.
here is code,
var chart= AmCharts.makeChart("rmChart",
{
"theme": "light",
"autoMargins": true, "chartScrollbar": {},
"type": "serial",
"categoryField": 'x-distance',
"legend": {
"useGraphSettings": false
},
"zoomControl": {
"panControlEnabled": false,
"zoomControlEnabled": false
},
"categoryAxis": {
"autoGridCount":false,
"includeHidden":true,
"dashLength":1,
" axisAlpha":1,
"gridPosition": "start",
"labelFunction" : formatLabel,
"minHorizontalGap":20,
"title": "Distance In Meters [m]"
},
"chartCursor": {
"zoomable":true,
"enabled": true,
},
"chartScrollbar": {
"enabled": false
},
"trendLines": [],
"valueAxes": [{
}],
"graphs": [
{
"balloonText": "Distance:[[x-axis]] dB:[[y-axis-0]]",
"fillAlphas": 0,
"fillToAxis": "x",
"lineAlpha": 1,
"valueField": "x-axis",
"valueField": "y-axis-0",
"lineColor": "#FF6600",
},
],
"guides": [],
"valueAxes": [
{
"id": "ValueAxis-1",
"title": "Strength [dB]",
"titleFontSize": 15,
}
],
"balloon": {},
"legend": {
"enabled": false,
"useGraphSettings": false
},
"titles": [
{
"id": "Title-1",
"size": 15,
"text": data[0]["date"]
}
],
"dataProvider": data,
export: {
enabled: false
},
"export": {
"enabled": true,
"menu": []
},
"chartScrollbar": {
"enabled":false
},
});
function formatLabel(value, valueText, axis) {
if (valueText.category%2==0) {
var lastNumber = (Math.abs(valueText.category) % 10)
if (lastNumber==0) {
return valueText.category;
}
}
if (valueText.category==data.length-1) {
return valueText.category;
}
else{
return "";
}
}
here is link to the jsfiddle
https://jsfiddle.net/8zw9h007/10/

Related

Change entry in json file that matches the condition in CloudFront Update Distribution

We have a scenario where we need to replace the TargetOriginID of CacheBehaviour in the distribution of a json file. We need to replace the Existing TargetOriginID with New Values. I have tried with below jq command but not getting any closer
for targetoriginID in $(jq '(.CacheBehaviors.Items[].TargetOriginId)' distconfig.json);
do
echo "#######fetch the new value from change behaviour json file"#######
NewValue=$(jq -r "map(select(.targetoriginid == ""$targetoriginID""))[].targetorigindr" changebehaviour.json)
echo "#########replace value in dist config json file with new value from change behaviour###########"
jq -r '(.CacheBehaviors.Items[].TargetOriginId | select(. == "$targetoriginID")) = "$NewValue"' distconfig.json > "tmp" && mv "tmp" distconfig.json
{
"CachedMethods": {
"Quantity": 3,
"Items": [
"HEAD",
"GET",
"OPTIONS"
]
}
},
"SmoothStreaming": false,
"Compress": false,
"LambdaFunctionAssociations": {
"Quantity": 0
},
"FunctionAssociations": {
"Quantity": 0
},
"FieldLevelEncryptionId": "",
"ForwardedValues": {
"QueryString": true,
"Cookies": {
"Forward": "none"
},
"Headers": {
"Quantity": 9,
"Items": [
"Authorization",
"Origin",
"access-control-allow-credentials",
"expires",
"access-control-max-age",
"access-control-allow-headers",
"cache-control",
"access-control-allow-methods",
"pragma"
]
},
"QueryStringCacheKeys": {
"Quantity": 1,
"Items": [
"*"
]
}
},
"MinTTL": 0,
"DefaultTTL": 86400,
"MaxTTL": 31536000
},
"CacheBehaviors": {
"Quantity": 2,
"Items": [
{
"PathPattern": "jkl/*",
"TargetOriginId": "nkl/Prod",
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TrustedKeyGroups": {
"Enabled": false,
"Quantity": 0
},
"ViewerProtocolPolicy": "redirect-to-https",
"AllowedMethods": {
"Quantity": 7,
"Items": [
"HEAD",
"DELETE",
"POST",
"GET",
"OPTIONS",
"PUT",
"PATCH"
],
"CachedMethods": {
"Quantity": 3,
"Items": [
"HEAD",
"GET",
"OPTIONS"
]
}
},
"SmoothStreaming": false,
"Compress": false,
"LambdaFunctionAssociations": {
"Quantity": 0
},
"FunctionAssociations": {
"Quantity": 0
},
"FieldLevelEncryptionId": "",
"ForwardedValues": {
"QueryString": true,
"Cookies": {
"Forward": "all"
},
"Headers": {
"Quantity": 9,
"Items": [
"Authorization",
"Origin",
"access-control-allow-credentials",
"access-control-max-age",
"access-control-allow-headers",
"cache-control",
"access-control-allow-methods",
"expirers",
"pragma"
]
},
"QueryStringCacheKeys": {
"Quantity": 1,
"Items": [
"*"
]
}
},
"MinTTL": 0,
"DefaultTTL": 86400,
"MaxTTL": 31536000
},
{
"PathPattern": "fgh/*",
"TargetOriginId":"xyz/Prod",
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TrustedKeyGroups": {
"Enabled": false,
"Quantity": 0
},
"ViewerProtocolPolicy": "redirect-to-https",
"AllowedMethods": {
"Quantity": 7,
"Items": [
"HEAD",
"DELETE",
"POST",
"GET",
"OPTIONS",
"PUT",
"PATCH"
],
"CachedMethods": {
"Quantity": 3,
"Items": [
"HEAD",
"GET",
"OPTIONS"
]
}
},
"SmoothStreaming": false,
"Compress": false,
"LambdaFunctionAssociations": {
"Quantity": 0
},
"FunctionAssociations": {
"Quantity": 0
},
"FieldLevelEncryptionId": "",
"ForwardedValues": {
"QueryString": true,
"Cookies": {
"Forward": "none"
},
"Headers": {
"Quantity": 10,
"Items": [
"access-control-allow-origin",
"authorization",
"Origin",
"access-control-allow-credentials",
"access-control-max-age",
"access-control-allow-headers",
"cache-control",
"access-control-allow-methods",
"expirers",
"pragma"
]
},
"QueryStringCacheKeys": {
"Quantity": 1,
"Items": [
"*"
]
}
},
"MinTTL": 0,
"DefaultTTL": 0,
"MaxTTL": 0
}
]
}
Looking for a solution to make bulk change in CacheBehaviour for all TargetOriginID's
Providing a second answer with some assumption. Let's start with a minimal example input:
{
"CacheBehaviors": {
"Quantity": 2,
"Items": [
{
"PathPattern": "jkl/*",
"TargetOriginId": [
"nkl",
"something else"
]
},
{
"PathPattern": "fgh/*",
"TargetOriginId": [
"xyz",
"abc"
]
}
]
},
"IsIPV6Enabled": true
}
Assuming you want to define a mapping "{old1: new1, old2: new2, old3: new3, …}", the following program could work and is easily extendable:
(.CacheBehaviors.Items[].TargetOriginId[]) |= ({
nkl: "wkl",
xyz: "123",
"something else": "is changed too",
"not found": "never replaced"
}[.] // .)
And if you like to have your mapping at the top/start of your program, bind it to a variable:
{
nkl: "wkl",
xyz: "123",
"something else": "is changed too",
"not found": "rever replaced"
} as $mapping
| (.CacheBehaviors.Items[].TargetOriginId[]) |= ($mapping[.] // .)
Output after running through above's program:
{
"CacheBehaviors": {
"Quantity": 2,
"Items": [
{
"PathPattern": "jkl/*",
"TargetOriginId": [
"wkl",
"is changed too"
]
},
{
"PathPattern": "fgh/*",
"TargetOriginId": [
"123",
"abc"
]
}
]
},
"IsIPV6Enabled": true
}
Is that what you are after? This chooses the new value by key from an object/dictionary/map and falls back to the current value if no mapping was found.
… |= ({ old: "new" }[.] // .)
The mapping itself could be provided as an argument to jq from a separate file:
jq --slurpfile mapping old_to_new_ids.json \
'(.CacheBehaviors.Items[].TargetOriginId[]) |= ($mapping[0][.] // .)'
With the contents of file old_to_new_ids.json simply being:
{
"nkl": "wkl",
"xyz": "123",
"something else": "is changed too",
"not found": "never replaced"
}
As of this writing, the posted JSON is invalid, so it's not clear exactly what is needed, but the following is illustrative:
jq --arg newvalue xyz '
(.. | objects | select(has("TargetOriginId")) | .TargetOriginId) |= $newvalue
'
Fixed (i.e. made valid) and reduced your JSON input down to the necessary minimum (the M in MRE), that is 50 lines.
{
"CacheBehaviors": {
"Quantity": 2,
"Items": [
{
"PathPattern": "jkl/*",
"TargetOriginId": [
"nkl"
],
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TrustedKeyGroups": {
"Enabled": false,
"Quantity": 0
},
"ViewerProtocolPolicy": "redirect-to-https"
},
{
"PathPattern": "fgh/*",
"TargetOriginId": [
"xyz"
],
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TrustedKeyGroups": {
"Enabled": false,
"Quantity": 0
},
"ViewerProtocolPolicy": "redirect-to-https"
}
]
},
"CustomErrorResponses": {
"Quantity": 0
},
"Comment": "vvvv",
"Logging": {
"Enabled": true,
"IncludeCookies": false,
"Bucket": "abc.s3.amazonaws.com",
"Prefix": "std"
},
"WebACLId": "",
"HttpVersion": "http2",
"IsIPV6Enabled": true
}
You probably want to run a jq program similar to the following:
(.CacheBehaviors.Items[].TargetOriginId | select(. as $id | "nkl" | IN($id[]))) = ["wkl"]
It selects all TargetOriginIds which contain the value "nkl" and changes the list to only contain "wkl".
Output:
{
"CacheBehaviors": {
"Quantity": 2,
"Items": [
{
"PathPattern": "jkl/*",
"TargetOriginId": [
"wkl"
],
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TrustedKeyGroups": {
"Enabled": false,
"Quantity": 0
},
"ViewerProtocolPolicy": "redirect-to-https"
},
{
"PathPattern": "fgh/*",
"TargetOriginId": [
"xyz"
],
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
"TrustedKeyGroups": {
"Enabled": false,
"Quantity": 0
},
"ViewerProtocolPolicy": "redirect-to-https"
}
]
},
"CustomErrorResponses": {
"Quantity": 0
},
"Comment": "vvvv",
"Logging": {
"Enabled": true,
"IncludeCookies": false,
"Bucket": "abc.s3.amazonaws.com",
"Prefix": "std"
},
"WebACLId": "",
"HttpVersion": "http2",
"IsIPV6Enabled": true
}
From the question it is unclear if "TargetOriginId": ["nkl", "xyz"] should become ["wkl"] or ["wkl", "xyz"]. Or whether ["nkl", "xyz"] is a match because it contains different values too. Maybe you only want to select those where the full TargetOriginId array matches?
If you only want to match items with single-valued target origin ids, the program becomes a bit simpler:
(.CacheBehaviors.Items[].TargetOriginId | select(. == ["nkl"])) = ["wkl"]
If your target origin ids are always an array and you want to change say "[abc,nkl,xyz]" to "[abc,REPLACED,xyz]", then select only those array elements and assign them the new value.
New input (as I understood it, the Q is quite vague on this):
{
"CacheBehaviors": {
"Quantity": 2,
"Items": [
{
"PathPattern": "jkl/*",
"TargetOriginId": [
"nkl",
"something else"
]
},
{
"PathPattern": "fgh/*",
"TargetOriginId": [
"xyz",
"abc"
]
}
]
},
"IsIPV6Enabled": true
}
jq:
(.CacheBehaviors.Items[].TargetOriginId[] | select(. == "nkl")) = "wkl"
Output:
{
"CacheBehaviors": {
"Quantity": 2,
"Items": [
{
"PathPattern": "jkl/*",
"TargetOriginId": [
"wkl",
"something else"
]
},
{
"PathPattern": "fgh/*",
"TargetOriginId": [
"xyz",
"abc"
]
}
]
},
"IsIPV6Enabled": true
}

LWC Datatable in a multi-currency org: Dollar sign $ appears for a moment on Cell change for non-dollar currency

The column definition is:
{
"columns": [
{
"cellAttributes": {
"alignment": "left"
},
"editable": false,
"fieldName": "aiq_BandNumber__c",
"label": "Tier Band",
"sortable": false,
"typeAttributes": {}
},
{
"cellAttributes": {
"alignment": "left"
},
"editable": true,
"fieldName": "aiq_LowerBound__c",
"label": "Lower Bound",
"sortable": false,
"type": "currency",
"typeAttributes": {
"currencyCode": {
"fieldName": "CurrencyIsoCode"
},
"currencyDisplayAs": "code",
"step": "0.01",
"maximumFractionDigits": "2"
}
},
{
"cellAttributes": {
"alignment": "left"
},
"editable": false,
"fieldName": "aiq_UpperBound__c",
"label": "Upper Bound",
"sortable": false,
"type": "currency",
"typeAttributes": {
"currencyCode": {
"fieldName": "CurrencyIsoCode"
},
"currencyDisplayAs": "code",
"step": "0.01",
"maximumFractionDigits": "2"
}
}
]
}
Datatable with multicurrency
Once we click to edit cell
Once editing a cell Dollar Sign appears for a moment ($), no matter which currency code is (USD, EUR, PLN etc.) and then Currency displays how it should
Nobody knows how to avoid that?
Many thanks

Usage of multiple images in Particle.js

I have a project which uses Particle.JS to create a canvas with moving image particles. The problem i am currently having is that every image is being reloaded constantly after a certain amount of time while it's already loaded.
config.json
"particles": {
"number": {
"value": 10,
"density": {
"enable": false,
"value_area": 100
}
},
"color": {
"value": "#ffffff"
},
"shape": {
"type": ["image0", "image1", "image2", "image3", "image4", "image5"],
"stroke": {
"width": 0,
"color": "#000000"
},
"polygon": {
"nb_sides": 5
},
"image": {
"src": "images/0.png",
"width": 100,
"height": 100
}
},
I used this case to filter out all image types in the switch.(pJS.fn.particle.prototype.draw)
particles.js
case (p.shape.match(/image/) || {}).input:
if(pJS.tmp.img_type == 'svg'){
var img_obj = p.img.obj;
}else{
var img_obj = pJS.tmp.img_obj;
}
var element = document.createElement('img');
var number = p.shape.replace("image", "")
element.src = './styles/eles/theme/images/particlelogo/'+number+'.png';
img_obj = element;
if(img_obj){
draw();
}
break;
Original particle.js github link
"shape": {
"type": "images",
"stroke": {
"width": 0,
"color": "#000"
},
"polygon": {
"nb_sides": 6
},
"images": [
{
"src": "img/shapes/0.svg",
"width": 100,
"height": 100
},
{
"src": "img/shapes/1.svg",
"width": 100,
"height": 100
}
]
},

liquibase defaultvalue sys_guid

how can i make a column default to SYS_GUID()using liquibase? i tried
{
"column": {
"name": "ID",
"type": "varchar(32)",
"constraints": {
"nullable": false,
"primariKey": true,
"unique": true,
"defaultValueComputed": "SYS_GUID()"
}
}
},
also tried changing sys guid to uuid
"column": {
"name": "ID",
"type": "varchar(32)"
"constraints": {
"nullable": false,
"primariKey": true,
"unique": true,
"defaultValueComputed": "UUID"
}
}
sorry for the dumb question, it was like this:
"column": {
"name": "ID",
"type": "varchar(32)",
"defaultValueComputed": "SYS_GUID()",
"constraints": {
"nullable": false,
"primariKey": true,
"unique": true
}
}
i was dumb enough to put the default in the constraints

jqgrid tree reader not working

My sample Json object is shown below:
{
"o": [
{
"level": 0,
"outlineItemId": 8,
"parentItemId": null,
"parentItem": null,
"order": 0,
"text": "section 1",
"isLeaf": "false",
"expanded": "true"
},
{
"level": 1,
"outlineItemId": 9,
"parentItemId": 8,
"parentItem": {
"level": 0,
"outlineItemId": 8,
"parentItemId": null,
"parentItem": null,
"order": 0,
"text": "section 1",
"isLeaf": "false",
"expanded": "true"
},
"order": 0,
"text": "sub 1",
"isLeaf": "false",
"expanded": "true"
},
{
"level": 2,
"outlineItemId": 10,
"parentItemId": 9,
"parentItem": {
"level": 1,
"outlineItemId": 9,
"parentItemId": 8,
"parentItem": {
"level": 0,
"outlineItemId": 8,
"parentItemId": null,
"parentItem": null,
"order": 0,
"text": "section 1",
"isLeaf": "false",
"expanded": "true"
},
"order": 0,
"text": "sub 1",
"isLeaf": "false",
"negateDevice": null,
"expanded": "true"
},
"order": 0,
"text": "sub sub 1",
"isLeaf": "true",
"expanded": "true"
}
]
}
Earlier when the tree was configured as:
treeReader: {
level_field: "level",
parent_id_field: "parentItemId",
leaf_field: "isLeaf",
expanded_field: "expanded"
},
I was displaying the correct indentation and image icons, however they were not expanded when the json obj always had "expanded":"true" so i tried the below code.
treeReader: {
level_field: "o.level",
parent_id_field: "o.parentItemId",
leaf_field: "o.isLeaf",
expanded_field: "o.expanded"
},
Now I am not getting the Image icons and the tree which was expanded earlier is now flat.
My Json reader just in case i goofed up..
jsonReader: {
root: 'o',
id: 'o.outlineItemId',
parentItemId: 'o.parentItem.outlineItemId',
text: 'o.text',
repeatitems: false,
page: function(obj) { return 1; },
total: function(obj) { return 1; },
records: function(obj) { return obj.o.length; },
},
Any help will be appreciated.
Shah
Got it!
For the reader i had to include cell:'' and remove the o. references. and also loaded:true in the json object.

Resources