Related
I'm trying to create a ConfigMap with ArgoCD.
I've created a volumes.yaml file as such
---
apiVersion: v1
kind: ConfigMap
metadata:
name: persistent-volumes-argo
labels:
grafana_dashboard: "1"
project: "foo"
data:
kubernetes.json: |
{{ .Files.Get "dashboards/persistent-volumes.json" | indent 4 }}
But ArgoCD doesn't seem to be able to read the data, the way a standard Helm deployment would.
I've tried adding the data directly into the ConfigMap as such
(Data omitted for brevity)
---
apiVersion: v1
kind: ConfigMap
metadata:
name: persistent-volumes-argo
labels:
grafana_dashboard: "1"
project: "foo"
data:
kubernetes.json: |
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"limit": 100,
"name": "Annotations & Alerts",
"showIn": 0,
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": 13646,
"graphTooltip": 0,
"iteration": 1659421503107,
"links": [],
"panels": [
{
"collapsed": false,
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 26,
"panels": [],
"title": "Alerts",
"type": "row"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"noValue": "--",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "semi-dark-red",
"value": null
},
{
"color": "light-green",
"value": -0.0001
},
{
"color": "semi-dark-red",
"value": 0.0001
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 0,
"y": 1
},
"id": 21,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": "count (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"} ) and (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"} )) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes{namespace=~\"${k8s_namespace}\"} )) >= (${warning_threshold} / 100)) or vector (0)",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "PVCs Above Warning Threshold",
"type": "stat"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"decimals": 0,
"mappings": [],
"noValue": "--",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "semi-dark-red",
"value": null
},
{
"color": "light-green",
"value": -0.0001
},
{
"color": "semi-dark-red",
"value": 0.0001
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 8,
"y": 1
},
"id": 24,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": "count((kube_persistentvolumeclaim_status_phase{namespace=~\"${k8s_namespace}\",phase=\"Pending\"}==1)) or vector(0)",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "PVCs in Pending State",
"transformations": [
{
"id": "organize",
"options": {}
}
],
"type": "stat"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"decimals": 0,
"mappings": [],
"noValue": "--",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "semi-dark-red",
"value": null
},
{
"color": "light-green",
"value": -0.0001
},
{
"color": "semi-dark-red",
"value": 0.0001
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 16,
"y": 1
},
"id": 23,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": "count((kube_persistentvolumeclaim_status_phase{namespace=~\"${k8s_namespace}\",phase=\"Lost\"}==1)) or vector(0)",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "PVCs in Lost State",
"transformations": [
{
"id": "organize",
"options": {}
}
],
"type": "stat"
},
{
"collapsed": false,
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 5
},
"id": 17,
"panels": [],
"title": "Usage statistics",
"type": "row"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"displayMode": "auto",
"filterable": false
},
"mappings": [],
"noValue": "--",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "light-green",
"value": null
}
]
},
"unit": "none"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Used (%)"
},
"properties": [
{
"id": "custom.displayMode",
"value": "gradient-gauge"
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "light-green",
"value": null
},
{
"color": "semi-dark-yellow",
"value": 70
},
{
"color": "dark-red",
"value": 80
}
]
}
},
{
"id": "decimals",
"value": 1
}
]
},
{
"matcher": {
"id": "byName",
"options": "Status"
},
"properties": [
{
"id": "custom.displayMode",
"value": "color-background"
},
{
"id": "mappings",
"value": [
{
"options": {
"0": {
"text": "Bound"
},
"1": {
"text": "Pending"
},
"2": {
"text": "Lost"
}
},
"type": "value"
}
]
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "light-green",
"value": null
},
{
"color": "light-green",
"value": 0
},
{
"color": "semi-dark-orange",
"value": 1
},
{
"color": "semi-dark-red",
"value": 2
}
]
}
},
{
"id": "noValue",
"value": "--"
},
{
"id": "custom.align",
"value": "center"
}
]
},
{
"matcher": {
"id": "byName",
"options": "Namespace"
},
"properties": [
{
"id": "custom.width",
"value": 120
}
]
},
{
"matcher": {
"id": "byName",
"options": "Status"
},
"properties": [
{
"id": "custom.width",
"value": 80
}
]
},
{
"matcher": {
"id": "byName",
"options": "Capacity (GiB)"
},
"properties": [
{
"id": "custom.width",
"value": 120
}
]
},
{
"matcher": {
"id": "byName",
"options": "Used (GiB)"
},
"properties": [
{
"id": "custom.width",
"value": 120
}
]
},
{
"matcher": {
"id": "byName",
"options": "Available (GiB)"
},
"properties": [
{
"id": "custom.width",
"value": 120
}
]
},
{
"matcher": {
"id": "byName",
"options": "StorageClass"
},
"properties": [
{
"id": "custom.width",
"value": 150
}
]
},
{
"matcher": {
"id": "byName",
"options": "PersistentVolumeClaim"
},
"properties": [
{
"id": "custom.width",
"value": 370
}
]
}
]
},
"gridPos": {
"h": 12,
"w": 24,
"x": 0,
"y": 6
},
"id": 29,
"interval": "",
"options": {
"frameIndex": 2,
"showHeader": true,
"sortBy": [
{
"desc": false,
"displayName": "PersistentVolumeClaim"
}
]
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": " sum by (persistentvolumeclaim,namespace,storageclass,volumename) (kube_persistentvolumeclaim_info{namespace=~\"${k8s_namespace}\"})",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
},
{
"expr": "sum by (persistentvolumeclaim) (kubelet_volume_stats_capacity_bytes{namespace=~\"${k8s_namespace}\"}/1024/1024/1024)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "B"
},
{
"expr": "sum by (persistentvolumeclaim) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}/1024/1024/1024)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "C"
},
{
"expr": "sum by (persistentvolumeclaim) (kubelet_volume_stats_available_bytes{namespace=~\"${k8s_namespace}\"}/1024/1024/1024)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "D"
},
{
"expr": "sum(kube_persistentvolumeclaim_status_phase{namespace=~\"${k8s_namespace}\",phase=~\"(Pending|Lost)\"}) by (persistentvolumeclaim) + sum(kube_persistentvolumeclaim_status_phase{namespace=~\"${k8s_namespace}\",phase=~\"(Lost)\"}) by (persistentvolumeclaim)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "E"
},
{
"expr": "sum by (persistentvolumeclaim) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}/kubelet_volume_stats_capacity_bytes{namespace=~\"${k8s_namespace}\"} * 100)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "F"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Persistent Volume Claim",
"transformations": [
{
"id": "seriesToColumns",
"options": {
"byField": "persistentvolumeclaim"
}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"Time 1": true,
"Time 2": true,
"Time 3": true,
"Time 4": true,
"Time 5": true,
"Time 6": true,
"Value #A": true
},
"indexByName": {},
"renameByName": {
"Time 1": "",
"Time 2": "",
"Time 3": "",
"Time 4": "",
"Time 5": "",
"Time 6": "",
"Value #A": "",
"Value #B": "Capacity (GiB)",
"Value #C": "Used (GiB)",
"Value #D": "Available (GiB)",
"Value #E": "Status",
"Value #F": "Used (%)",
"namespace": "Namespace",
"persistentvolumeclaim": "PersistentVolumeClaim",
"storageclass": "StorageClass",
"volumename": "PhysicalVolume"
}
}
}
],
"type": "table"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {
"align": null,
"displayMode": "auto",
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 24,
"x": 0,
"y": 18
},
"id": 7,
"options": {
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Status"
}
]
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": "kube_storageclass_info",
"format": "table",
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Storage Class",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"Value": true,
"__name__": true,
"app_kubernetes_io_instance": true,
"app_kubernetes_io_name": true,
"instance": true,
"job": true,
"kubernetes_namespace": true,
"kubernetes_pod_name": true,
"pod_template_hash": true
},
"indexByName": {
"Time": 1,
"Value": 13,
"__name__": 2,
"app_kubernetes_io_instance": 3,
"app_kubernetes_io_name": 4,
"instance": 5,
"job": 6,
"kubernetes_namespace": 7,
"kubernetes_pod_name": 8,
"pod_template_hash": 9,
"provisioner": 10,
"reclaimPolicy": 11,
"storageclass": 0,
"volumeBindingMode": 12
},
"renameByName": {
"provisioner": "Provisioner",
"reclaimPolicy": "ReclaimPolicy",
"storageclass": "StorageClass",
"volumeBindingMode": "VolumeBindingMode"
}
}
},
{
"id": "groupBy",
"options": {
"fields": {
"Provisioner": {
"aggregations": [],
"operation": "groupby"
},
"ReclaimPolicy": {
"aggregations": [],
"operation": "groupby"
},
"StorageClass": {
"aggregations": [],
"operation": "groupby"
},
"VolumeBindingMode": {
"aggregations": [],
"operation": "groupby"
}
}
}
}
],
"type": "table"
},
{
"collapsed": false,
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 23
},
"id": 15,
"panels": [],
"title": "Graphical usage data ",
"type": "row"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "$datasource",
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 12,
"w": 24,
"x": 0,
"y": 24
},
"hiddenSeries": false,
"id": 9,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.0.3",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}))",
"interval": "",
"legendFormat": "{{namespace}} ({{persistentvolumeclaim}})",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "All Running PVCs Used Bytes",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "bytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "Date & time",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"collapsed": true,
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 36
},
"id": 19,
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 41
},
"hiddenSeries": false,
"id": 11,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.1",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "rate(kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}[1h])",
"instant": false,
"interval": "",
"legendFormat": "{{namespace}} ({{persistentvolumeclaim}})",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Hourly Volume Usage Rate",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "binBps",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "Date & time",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 48
},
"hiddenSeries": false,
"id": 12,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.1",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "rate(kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}[1d])",
"interval": "",
"legendFormat": "{{namespace}} ({{persistentvolumeclaim}})",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Daily Volume Usage Rate",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "binBps",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "Date & time",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 55
},
"hiddenSeries": false,
"id": 13,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
}
}
But this errors with rpc error: code = FailedPrecondition desc = Failed to unmarshal "volumes.yaml": <nil>
Is there a way to pass in json data when creating a ConfigMap with ArgoCD, either as a template or by dumping the data in the file?
To create configmap with argocd and helm
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "helm-chart.fullname" . }}-configmap
data:
config.json : |
{{ toJson .Values.configmap | indent 4 }}
and the value file should be like this, which is our JSON but converted to YAML
configmap:
json:
- rigid
- better for data interchange
yaml:
- slim and flexible
- better for configuration
object:
key: value
array:
- null_value:
- boolean: true
- integer: 1
- alias: &example aliases are like variables
- alias: *example
paragraph: >
Blank lines denote
paragraph breaks
content: |-
Or we
can auto
convert line breaks
to save space
alias: &foo
bar: baz
alias_reuse: *foo
json2yaml
A complete demo app can be found here
A very quick way to create app with the above configmap and demo app
argocd app create demo-app --repo https://github.com/Adiii717/argocd-demo-app.git --path helm-chart --dest-namespace default --dest-server https://kubernetes.default.svc --helm-set replicaCount=2
Make sure you also set
export ARGOCD_AUTH_TOKEN="tokeh
export ARGOCD_OPTS="--grpc-web"
export ARGOCD_SERVER="argocd.example.com"
added section for the configmap
I'm trying to filter my data so that it does not include the missing data (noted as 0) in my chart. I'd assume the code I need to add is
"transform": [
{"filter": "datum.Gross enrolment ratio for tertiary education both sexes (%) > 0"
}
],
but it doesn't seem to be working.
Here is the code for my vegalite chart
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"title": {
"text": "Billionaires and Education Attainment",
"subtitle": "Sources: ",
"subtitleFontStyle": "italic",
"subtitleFontSize": 10,
"anchor": "start",
"color": "black"
},
"height": 300,
"width": 260,
"data": {
"url": "https://raw.githubusercontent.com/jamieprince/jamieprince.github.io/main/correlation.csv"
},
"selection": {
"paintbrush": {
"type": "multi",
"on": "mouseover",
"nearest": true
},
"grid": {
"type": "interval",
"bind": "scales"
}
},
"mark": {
"type": "circle",
"opacity": 0.4,
"color": "skyblue"
},
"encoding": {
"x": {
"field": "Number of Billionaires",
"type": "quantitative",
"axis": {
"title": "Number of Billionaires",
"grid": false,
"tickCount": 14,
"labelOverlap": "greedy"
}
},
"y": {
"field": "Gross enrolment ratio for tertiary education both sexes (%)",
"type": "quantitative",
"axis": {
"title": "Educational Attainment",
"grid": false
}
},
"size": {
"condition": {
"selection": "paintbrush",
"value": 300,
"init": {
"value": 70
}
},
"value": 70
},
"tooltip": [
{
"field": "Year",
"type": "nominal",
"title": "Year"
},
{
"field": "Country",
"type": "ordinal",
"title": "Country"
},
{
"field": "Number of Billionaires",
"type": "nominal",
"title": "No of Billionaires"
},
{
"field": "Gross enrolment ratio for tertiary education both sexes (%)",
"type": "nominal",
"title": "Gross enrolment ratio for tertiary education both sexes (%)"
}
]
}
}
Does anyone know how I could filter the data so it only includes points where the variable is not 0?
Thank you so so much!
You can do this with a greater-than predicate:
"transform": [{
"filter": {
"field": "Gross enrolment ratio for tertiary education both sexes (%)",
"gt": 0
}
}],
Working on transformation and created spec for the input. The output is nested array but I am expecting flattened array.
2. Need to split the string and get the first element. split function doesn't seems to be working.
Please find the input, spec , output and expected output below.
Input
[
{
"tables": [
{
"columns": [
{
"size": 20,
"nullable": false,
"databaseSpecificType": "varchar",
"generated": false,
"dataType": "VARCHAR",
"name": "firstname",
"width": "(20)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
},
{
"size": 20,
"nullable": false,
"databaseSpecificType": "varchar",
"generated": false,
"dataType": "VARCHAR",
"name": "lastname",
"width": "(20)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
],
"name": "authors",
"fullName": "books.authors",
"type": "table",
"triggers": [],
"tableConstraints": [],
"remarks": "Contact details for book authors",
"primaryKey": {
"columns": {
"sortSequence": "ascending",
"name": "id"
},
"unique": true,
"name": "pk_authors",
"remarks": ""
}
},
{
"columns": [
{
"size": 10,
"nullable": true,
"databaseSpecificType": "int4",
"generated": false,
"dataType": "INTEGER",
"name": "id",
"width": "",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
],
"name": "authorslist",
"fullName": "books.authorslist",
"type": "view",
"triggers": [],
"tableConstraints": [],
"remarks": "",
"primaryKey": {}
}
],
"schemaCrawlerHeaderInfo": {
"crawlTimestamp": "2018-05-23 10:21:55",
"title": ""
}
}
]
Spec:
[{
"operation": "shift",
"spec": {
"*": {
"tables": {
"*": {
"columns": {
"*": {
"#(2,name)": "[&3].[&1].TABLE.tableName",
"#(2,fullName)": ["[&3].[&1].TABLE.fullName", "[&3].[&1].DB.fullName"],
"#(2,remarks)": "[&3].[&1].TABLE.tableDesc",
"name": "[&3].[&1].COLUMN.name",
"dataType": "[&3].[&1].COLUMN.dataType",
"size": "[&3].[&1].COLUMN.size",
"nullable": "[&3].[&1].COLUMN.nullable",
"databaseSpecificType": "[&3].[&1].COLUMN.databaseSpecificType",
"width": "[&3].[&1].COLUMN.width",
"decimalDigits": "[&3].[&1].COLUMN.decimalDigits",
"remarks": "[&3].[&1].COLUMN.remarks",
"autoIncremented": "[&3].[&1].COLUMN.autoIncremented"
}
}
}
}
}
}
}]
Output
[
[
{
"TABLE": {
"tableName": "authors",
"fullName": "books.authors",
"tableDesc": "Contact details for book authors"
},
"DB": {
"fullName": "books.authors"
},
"COLUMN": {
"name": "firstname",
"dataType": "VARCHAR",
"size": 20,
"nullable": false,
"databaseSpecificType": "varchar",
"width": "(20)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
},
{
"TABLE": {
"tableName": "authors",
"fullName": "books.authors",
"tableDesc": "Contact details for book authors"
},
"DB": {
"fullName": "books.authors"
},
"COLUMN": {
"name": "lastname",
"dataType": "VARCHAR",
"size": 20,
"nullable": false,
"databaseSpecificType": "varchar",
"width": "(20)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
}
],
[
{
"TABLE": {
"tableName": "authorslist",
"fullName": "books.authorslist",
"tableDesc": ""
},
"DB": {
"fullName": "books.authorslist"
},
"COLUMN": {
"name": "id",
"dataType": "INTEGER",
"size": 10,
"nullable": true,
"databaseSpecificType": "int4",
"width": "",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
}
]
]Iamexpectingtheflattenedoutputlikebelowinsinglearrayrathernestedarray.[
{
"TABLE": {
"tableName": "authors",
"fullName": "books.authors",
"tableDesc": "Contact details for book authors"
},
"DB": {
"fullName": "books.authors"
},
"COLUMN": {
"name": "firstname",
"dataType": "VARCHAR",
"size": 20,
"nullable": false,
"databaseSpecificType": "varchar",
"width": "(20)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
},
{
"TABLE": {
"tableName": "authors",
"fullName": "books.authors",
"tableDesc": "Contact details for book authors"
},
"DB": {
"fullName": "books.authors"
},
"COLUMN": {
"name": "lastname",
"dataType": "VARCHAR",
"size": 20,
"nullable": false,
"databaseSpecificType": "varchar",
"width": "(20)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
},
{
"TABLE": {
"tableName": "authorslist",
"fullName": "books.authorslist",
"tableDesc": ""
},
"DB": {
"fullName": "books.authorslist"
},
"COLUMN": {
"name": "id",
"dataType": "INTEGER",
"size": 10,
"nullable": true,
"databaseSpecificType": "int4",
"width": "",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
}
]
I am expecting the flattened output like below in single array rather nested array.
[
{
"TABLE": {
"tableName": "authors",
"fullName": "books.authors",
"tableDesc": "Contact details for book authors"
},
"DB": {
"fullName": "books.authors"
},
"COLUMN": {
"name": "firstname",
"dataType": "VARCHAR",
"size": 20,
"nullable": false,
"databaseSpecificType": "varchar",
"width": "(20)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
},
{
"TABLE": {
"tableName": "authors",
"fullName": "books.authors",
"tableDesc": "Contact details for book authors"
},
"DB": {
"fullName": "books.authors"
},
"COLUMN": {
"name": "lastname",
"dataType": "VARCHAR",
"size": 20,
"nullable": false,
"databaseSpecificType": "varchar",
"width": "(20)",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
},
{
"TABLE": {
"tableName": "authorslist",
"fullName": "books.authorslist",
"tableDesc": ""
},
"DB": {
"fullName": "books.authorslist"
},
"COLUMN": {
"name": "id",
"dataType": "INTEGER",
"size": 10,
"nullable": true,
"databaseSpecificType": "int4",
"width": "",
"decimalDigits": 0,
"remarks": "",
"autoIncremented": false
}
}
]
And also tried split and firstelement function to get the dbname but split is not working.
"DB" : {
"fullName" : "books.authors"
}
"DB" : {
"fullName" : "books"
}
Any help on this would be great.
Have to do two shifts.
Spec and explaination
[
{
// Your input data is two nested arrays.
// Tables array, and its nested columns array.
// The number of elements in your output array is
// the total number of column elements in your input doc.
//
// Can't do it in a single shift.
// The sample input tables arrays is length 2
// The sample input columsn arrays are length 2 and 1.
// You want an output array of length 3, there is no "3"
// that can be referenced by the first shift operation.
//
// So first, "build" the final TABLE, COLUMN, DB format, by
// pushing table information down into the columns data, BUT
// keeping the same nested table and columns array structure.
"operation": "shift",
"spec": {
"0": {
"tables": {
"*": { // tables index
"columns": {
"*": { // columns index
// grabbing info off the "parent" table entry
"#(2,name)": "tables[&3].cols[&1].TABLE.tableName",
"#(2,fullName)": ["tables[&3].cols[&1].TABLE.fullName", "tables[&3].cols[&1].DB.fullName"],
"#(2,remarks)": "tables[&3].cols[&1].TABLE.tableDesc",
//
// handling all the column level data
"*": "tables[&3].cols[&1].COLUMN.&"
}
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"tables": {
"*": {
"cols": {
// now walk the nested tables and cols array
// and accumulate each "fully formatted"
// col entry, into the output top-level array
"*": "[]"
}
}
}
}
}
]
How to create dual axis with primary Y axis having integer value and secondary Y axis has decimal point in fusion chart. Below is my current code that is showing both axis as decimal point values.
<graph animation='0' PYAxisName='Units' SYAxisName='PPB' bgColor='f5f5f5' rotateNames='1' PYAxisMaxValue='" + maxYVal + "' SYAxisMaxValue='" + maxY1Val + "' canvasBorderColor='cccccc' canvasBorderThickness='0' canvasBgAlpha='100' showColumnShadow='0' showvalues='0' formatNumberScale='1' anchorSides='10' anchorRadius='3' decimalPrecision='1' showShadow='0' showDivLineValue='1' numdivlines='" + numLines + "' divlinecolor='DCDCDC' divLineThickness='1'>
Try using FusionCharts v 3.12.2, it is possible to get the secondary y-axis value in decimal by setting "sForceDecimals" attribute at chart attribute level. Refer to the code below:
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'stackedcolumn3dlinedy',
renderAt: 'chart-container',
width: '550',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Product-wise Quarterly Revenue vs. Profit %",
"subCaption": "Harry's SuperMart - Last Year",
"xAxisname": "Quarter",
"pYAxisName": "Sales",
"sYAxisName": "Profit %",
"numberPrefix": "$",
"sNumberSuffix": "%",
//This "sForceDecimals" attribute will make only the secondary y-axis values in decimals.
"sForceDecimals": "1",
"sYAxisMaxValue": "25",
"paletteColors": "#0075c2,#1aaf5d,#f2c500",
"bgColor": "#ffffff",
"borderAlpha": "20",
"showCanvasBorder": "0",
"usePlotGradientColor": "0",
"plotBorderAlpha": "10",
"legendBorderAlpha": "0",
"legendShadow": "0",
"legendBgAlpha": "0",
"valueFontColor": "#ffffff",
"showXAxisLine": "1",
"xAxisLineColor": "#999999",
"divlineColor": "#999999",
"divLineIsDashed": "1",
"showAlternateHGridColor": "0",
"subcaptionFontBold": "0",
"subcaptionFontSize": "14",
"showHoverEffect": "1"
},
"categories": [{
"category": [{
"label": "Q1"
}, {
"label": "Q2"
}, {
"label": "Q3"
}, {
"label": "Q4"
}]
}],
"dataset": [{
"seriesname": "Food Products",
"data": [{
"value": "11000"
}, {
"value": "15000"
}, {
"value": "13500"
}, {
"value": "15000"
}]
}, {
"seriesname": "Non-Food Products",
"data": [{
"value": "11400"
}, {
"value": "14800"
}, {
"value": "8300"
}, {
"value": "11800"
}]
}, {
"seriesname": "Profit %",
"renderAs": "line",
"parentYAxis": "S",
"showValues": "0",
"data": [{
"value": "14"
}, {
"value": "16"
}, {
"value": "15"
}, {
"value": "17"
}]
}]
}
}).render();
});
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<div id="chart-container">FusionCharts will render here</div>
I am trying the trial version of Fusion Charts. I downloaded FusionCharts XT(v3.2.2) SR5 and FusionWidgets XT (v3.2) Service Release 2 trial versions, copied the scripts and flash files into my application, included FusionCharts/jquery.min.js, FusionCharts/FusionCharts.js, FusionCharts/FusionCharts.HC.js, FusionCharts/FusionCharts.HC.Widgets.js in my aspx, I tried the below chart (Column3D) with sample JSON provided and it worked fine. i was able to see the chart.
var myChart = new FusionCharts("Column3D", "myChartId", "400", "300");
myChart.setJSONData(
{ "chart":
{ "caption": "Weekly Sales Summary", "xAxisName": "Week", "yAxisName": "Sales", "numberPrefix": "$" },
"data":
[{ "label": "Week 1", "value": "14400" },
{ "label": "Week 2", "value": "19600" },
{ "label": "Week 3", "value": "24000" },
{ "label": "Week 4", "value": "15700"}]
});
myChart.render("chartContainer");
But when i want to try gantt chart with sample JSON provided, I get Chart type not supported. Please see the code and complete JSON i tried below.
var myChart = new FusionCharts("Gantt", "myChartId", "800", "700");
myChart.setJSONData(
{ "chart": { "manageresize": "1", "dateformat": "dd/mm/yyyy", "outputdateformat": "ddds mns yy", "ganttwidthpercent": "65", "canvasbordercolor": "999999", "canvasborderthickness": "0", "gridbordercolor": "4567aa", "gridborderalpha": "20", "ganttpaneduration": "3", "ganttpanedurationunit": "m" }, "categories": [{ "bgcolor": "009999", "category": [{ "start": "1/3/2008", "end": "31/8/2008", "label": "Residential Construction", "fontcolor": "ffffff", "fontsize": "16"}] }, { "bgcolor": "4567aa", "fontcolor": "ff0000", "category": [{ "start": "1/3/2008", "end": "31/8/2008", "label": "Months", "alpha": "", "font": "Verdana", "fontcolor": "ffffff", "fontsize": "16"}] }, { "bgcolor": "ffffff", "fontcolor": "1288dd", "fontsize": "10", "isbold": "1", "align": "center", "category": [{ "start": "1/3/2008", "end": "31/3/2008", "label": "March" }, { "start": "1/4/2008", "end": "30/4/2008", "label": "April" }, { "start": "1/5/2008", "end": "31/5/2008", "label": "May" }, { "start": "1/6/2008", "end": "30/6/2008", "label": "June" }, { "start": "1/7/2008", "end": "31/7/2008", "label": "July" }, { "start": "1/8/2008", "end": "31/8/2008", "label": "August"}]}], "processes": { "headertext": "Task", "fontcolor": "000000", "fontsize": "11", "isanimated": "1", "bgcolor": "4567aa", "headervalign": "bottom", "headeralign": "left", "headerbgcolor": "4567aa", "headerfontcolor": "ffffff", "headerfontsize": "16", "align": "left", "isbold": "1", "bgalpha": "25", "process": [{ "label": "Writing", "id": "1" }, { "label": "Signing", "id": "2" }, { "label": "Financing", "id": "3" }, { "label": "Permission", "id": "4" }, { "label": "Plumbing", "id": "5" }, { "label": "Terrace", "id": "6" }, { "label": "Inspection", "id": "7" }, { "label": "Wood Work", "id": "8" }, { "label": "Interiors", "id": "9" }, { "label": "Shifting", "id": "10"}] }, "datatable": { "showprocessname": "1", "namealign": "left", "fontcolor": "000000", "fontsize": "10", "valign": "right", "align": "center", "headervalign": "bottom", "headeralign": "left", "headerbgcolor": "4567aa", "headerfontcolor": "ffffff", "headerfontsize": "16", "datacolumn": [{ "bgcolor": "eeeeee", "headertext": "Start", "text": [{ "label": "7/3/2008" }, { "label": "6/4/2008" }, { "label": "1/5/2008" }, { "label": "13/5/2008" }, { "label": "2/5/2008" }, { "label": "1/6/2008" }, { "label": "15/6/2008" }, { "label": "22/6/2008" }, { "label": "18/6/2008" }, { "label": "15/7/2008"}] }, { "bgcolor": "eeeeee", "headertext": "Finish", "text": [{ "label": "22/4/2008" }, { "label": "12/5/2008" }, { "label": "2/6/2008" }, { "label": "19/6/2008" }, { "label": "19/6/2008" }, { "label": "19/7/2008" }, { "label": "11/8/2008" }, { "label": "5/8/2008" }, { "label": "22/7/2008" }, { "label": "11/8/2008"}] }, { "bgcolor": "eeeeee", "headertext": "Hrs", "text": [{ "label": "150" }, { "label": "340" }, { "label": "60" }, { "label": "20" }, { "label": "30" }, { "label": "45" }, { "label": "40" }, { "label": "102" }, { "label": "60" }, { "label": "30" }, { "label": "90" }, { "label": "30"}] }, { "align": "right", "bgcolor": "4567aa", "bgalpha": "25", "headertext": "Cost", "isbold": "1", "text": [{ "label": "$4100" }, { "label": "$8290" }, { "label": "$12340" }, { "label": "$2330" }, { "label": "$4550" }, { "label": "$15720" }, { "label": "$1780" }, { "label": "$32330" }, { "label": "$9890" }, { "label": "$1110" }, { "label": "$1260" }, { "label": "$4260"}]}] }, "tasks": { "task": [{ "label": "Planned", "processid": "1", "start": "7/3/2008", "end": "18/4/2008", "id": "1-1", "color": "4567aa", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "1", "start": "9/3/2008", "end": "22/4/2008", "id": "1", "color": "EEEEEE", "alpha": "100", "toppadding": "56%", "height": "32%" }, { "label": "Planned", "processid": "8", "start": "22/6/2008", "end": "29/7/2008", "id": "2-1", "color": "4567aa", "alpha": "100", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "8", "start": "22/6/2008", "end": "5/8/2008", "id": "2", "color": "EEEEEE", "alpha": "100", "height": "32%", "toppadding": "56%", "percentcomplete": "78" }, { "label": "Planned", "processid": "2", "start": "6/4/2008", "end": "2/5/2008", "id": "3-1", "color": "4567aa", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "2", "start": "6/4/2008", "end": "12/5/2008", "id": "3", "color": "EEEEEE", "alpha": "100", "isanimated": "1", "height": "32%", "toppadding": "56%" }, { "label": "Planned", "processid": "9", "start": "18/6/2008", "end": "21/7/2008", "id": "4-1", "color": "4567aa", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "9", "start": "18/6/2008", "end": "22/7\t/2008", "id": "4", "color": "EEEEEE", "alpha": "100", "isanimated": "1", "height": "32%", "toppadding": "56%" }, { "label": "Planned", "processid": "3", "start": "1/5/2008", "end": "2/6/2008", "id": "5-1", "color": "4567aa", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "3", "start": "1/5/2008", "end": "2/6/2008", "id": "5", "color": "EEEEEE", "height": "32%", "toppadding": "56%" }, { "label": "Planned", "processid": "4", "start": "11/5/2008", "end": "12/6/2008", "id": "6-1", "color": "4567aa", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "4", "start": "13/5/2008", "end": "19/6/2008", "id": "6", "color": "EEEEEE", "height": "32%", "toppadding": "56%" }, { "label": "Planned", "processid": "5", "start": "1/5/2008", "end": "12/6/2008", "id": "7-1", "color": "4567aa", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "5", "start": "2/5/2008", "end": "19/6/2008", "id": "7", "color": "EEEEEE", "height": "32%", "toppadding": "56%" }, { "label": "Planned", "processid": "6", "start": "1/6/2008", "end": "12/7/2008", "id": "8-1", "color": "4567aa", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "6", "start": "1/6/2008", "end": "19/7/2008", "id": "8", "color": "EEEEEE", "height": "32%", "toppadding": "56%", "percentcomplete": "91" }, { "label": "Planned", "processid": "7", "start": "11/6/2008", "end": "7/8/2008", "id": "9-1", "color": "4567aa", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "7", "start": "15/6/2008", "end": "11/8/2008", "id": "9", "color": "EEEEEE", "height": "32%", "toppadding": "56%" }, { "label": "Planned", "processid": "10", "start": "11/7/2008", "end": "7/8/2008", "id": "10-1", "color": "4567aa", "height": "32%", "toppadding": "12%" }, { "label": "Actual", "processid": "10", "start": "15/7/2008", "end": "11/8/2008", "id": "10", "color": "EEEEEE", "height": "32%", "toppadding": "56%"}] }, "connectors": [{ "connector": [{ "fromtaskid": "3", "totaskid": "5", "color": "4567aa", "thickness": "2", "fromtaskconnectstart": "1" }, { "fromtaskid": "8", "totaskid": "2", "color": "4567aa", "thickness": "2", "fromtaskconnectstart": "1"}]}], "milestones": { "milestone": [{ "date": "7/8/2008", "taskid": "10-1", "color": "2E4472", "shape": "star", "tooltext": "Original moving date" }, { "date": "21/8/2008", "taskid": "10", "color": "999999", "shape": "star", "tooltext": "New estimated moving date"}] }, "legend": { "item": { "label": "Slack (Delay)", "color": "FF5E5E"} }, "styles": { "definition": [{ "type": "Font", "name": "legendFont", "size": "12"}], "application": [{ "toobject": "LEGEND", "styles": "legendFont"}]} });
myChart.render("chartContainer");
I dont think there is any problem with the JSON asi took it straight from the sample. But why am i getting Chart type not supported? Is there anything additional we have to do to make fusionwidgets work? Any help would be appreciated.
The latest version of FusionWidgets XT 3.3.1 supports Gantt chart in JavaScript flavor.
Refer for more info at: http://forum.fusioncharts.com/topic/13689-javascript-variant-of-gantt-chart/