window.onload = function (){
$("#work_sanctioned_year").change();
};
$(document).ready(function(){
$("#work_sanctioned_year").change();
});
$("#work-sanctioned-year").change(function(){
var work_sanctioned_year = $(this).val();
alert(work_sanctioned_year);
$.ajax({
url: 'get_data.php',
type: 'post',
data: {work_sanctioned_year:work_sanctioned_year},
dataType: 'json',
success:function(response){
FusionCharts.ready();
}
});
FusionCharts.ready(function() {
var dataChart = new FusionCharts({
"type": "overlappedBar2d",
"renderAt": "chart-5",
"width": '100%',
"height": '400',
"dataFormat": "json",
"dataSource": {
"chart": {
"caption": "Major League Baseball - Season Rankings",
"subCaption": "Teams in the Lead",
"xAxisName": "Team",
"yAxisName": "Position",
"theme": "fusion",
"showValues": "0"
},
"categories": [{
"labelFontSize": "13",
"category": [{
"label": "Boston Red Sox"
}, {
"label": "New York Yankees"
}, {
"label": "Tampa Bay Rays"
}, {
"label": "Toronto Blue Jays"
}, {
"label": "Baltimore Orioles"
}, {
"label": "Cleveland Indians"
}, {
"label": "Detroit Tigers"
}, {
"label": "Minnesota Twins"
}, {
"label": "Chicago White Sox"
}, {
"label": "Kansas City Royals"
}, {
"label": "Cleveland Indians"
}, {
"label": "Detroit Tigers"
}, {
"label": "Minnesota Twins"
}, {
"label": "Chicago White Sox"
}]
}],
"dataset": [{
"seriesname": "Matches",
"data": [{
"value": parseInt(document.getElementById("work_sanctioned").value)-4650
}, {
"value": "84"
}, {
"value": "86"
}, {
"value": "86"
}, {
"value": "85"
}, {
"value": "85"
}, {
"value": "88"
}, {
"value": "83"
}, {
"value": "86"
}, {
"value": "86"
}, {
"value": "85"
}, {
"value": "88"
}, {
"value": "83"
}, {
"value": "86"
}]
}, {
"seriesname": "Wins",
"data": [{
"value": "57"
}, {
"value": "54"
}, {
"value": "42"
}, {
"value": "39"
}, {
"value": "24"
}, {
"value": "46"
}, {
"value": "38"
}, {
"value": "35"
}, {
"value": "29"
}, {
"value": "25"
}, {
"value": "46"
}, {
"value": "38"
}, {
"value": "35"
}, {
"value": "29"
}, {
"value": "25"
}]
}]
}
})
.render();
});
});
when m selecting something from the dropdown its working. but when what m trying to do is call the function with the first value by default.I have tried both window.onload method and .ready function individually but still function is not getting called.. and also m not getting error in console related to this so this is making it harder to spot what actually is wrong over here
<script>
function work_sanctioned(){
console.log('onchange');
var work_sanctioned_year = $("#work-sanctioned-year").val();
alert(work_sanctioned_year);
$.ajax({
url: 'get_data.php',
type: 'post',
data: {work_sanctioned_year:work_sanctioned_year},
dataType: 'json',
success:function(response){
FusionCharts.ready();
}
});
FusionCharts.ready(function() {
var dataChart = new FusionCharts({
"type": "overlappedBar2d",
"renderAt": "chart-5",
"width": '100%',
"height": '400',
"dataFormat": "json",
"dataSource": {
"chart": {
"caption": "Major League Baseball - Season Rankings",
"subCaption": "Teams in the Lead",
"xAxisName": "Team",
"yAxisName": "Position",
"theme": "fusion",
"showValues": "0"
},
"categories": [{
"labelFontSize": "13",
"category": [{
"label": "Boston Red Sox"
}, {
"label": "New York Yankees"
}, {
"label": "Tampa Bay Rays"
}, {
"label": "Toronto Blue Jays"
}, {
"label": "Baltimore Orioles"
}, {
"label": "Cleveland Indians"
}, {
"label": "Detroit Tigers"
}, {
"label": "Minnesota Twins"
}, {
"label": "Chicago White Sox"
}, {
"label": "Kansas City Royals"
}, {
"label": "Cleveland Indians"
}, {
"label": "Detroit Tigers"
}, {
"label": "Minnesota Twins"
}, {
"label": "Chicago White Sox"
}]
}],
"dataset": [{
"seriesname": "Matches",
"data": [{
"value": parseInt(document.getElementById("work_sanctioned").value)-4650
}, {
"value": "84"
}, {
"value": "86"
}, {
"value": "86"
}, {
"value": "85"
}, {
"value": "85"
}, {
"value": "88"
}, {
"value": "83"
}, {
"value": "86"
}, {
"value": "86"
}, {
"value": "85"
}, {
"value": "88"
}, {
"value": "83"
}, {
"value": "86"
}]
}, {
"seriesname": "Wins",
"data": [{
"value": "57"
}, {
"value": "54"
}, {
"value": "42"
}, {
"value": "39"
}, {
"value": "24"
}, {
"value": "46"
}, {
"value": "38"
}, {
"value": "35"
}, {
"value": "29"
}, {
"value": "25"
}, {
"value": "46"
}, {
"value": "38"
}, {
"value": "35"
}, {
"value": "29"
}, {
"value": "25"
}]
}]
}
})
.render();
});
}
</script>
and then called this on window.onload as well as on select property onchange
<select id="work-sanctioned-year" onChange="work_sanctioned()" style="max-width:40%;min-width:20%; margin:auto;">
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
</select>
finally on window.onload
<script>
window.onload = function (){
work_sanctioned();
};
</script>
Related
I have an api call response with this format.
They are token and I know how to filter an array.
But here instead of an array I have an object.
{
"AFjQbjBwEF4HfBgKYTeK3SZg4cGRuB9o3rNGmQvHwtFX": {
"name": "000# Heartbreak",
"symbol": "NNPOSTER",
"description": "The crystal broken heart is a mirror through which residents of the NEONEXUS can take a peek into the real world as we know it.",
"seller_fee_basis_points": 500,
"image": "https://arweave.net/8TpUvw7hi7N_rVuG6avV_cOX2bXQ7OsY-ZNtILCM-zo?ext=jpg",
"animation_url": "https://arweave.net/WdzVw-_XE7LQArXArYJNpeMSgFbYYwa1ATpCVrfrTK8?ext=mp4",
"external_url": "https://neonexus.io",
"attributes": [
{
"trait_type": "City",
"value": "Miami"
},
{
"trait_type": "Theme",
"value": "Heartbreak in Miami"
},
{
"trait_type": "Origin",
"value": "Airdrop"
},
{
"trait_type": "Scene",
"value": "Moody"
},
{
"trait_type": "Period",
"value": "Lockdown"
},
{
"trait_type": "Artist",
"value": "Daramola"
}
],
"collection": {
"name": "NEONEXUS Posters",
"family": "Raynesfere"
},
"properties": {
"files": [
{
"uri": "https://arweave.net/8TpUvw7hi7N_rVuG6avV_cOX2bXQ7OsY-ZNtILCM-zo?ext=jpg",
"type": "image/gif"
},
{
"uri": "https://arweave.net/WdzVw-_XE7LQArXArYJNpeMSgFbYYwa1ATpCVrfrTK8?ext=mp4",
"type": "video/mp4"
}
],
"category": "video",
"creators": [
{
"address": "Ef896VQS1tfMACgL5Ce1TR7JZhehkrtowCyZZyYv7SWn",
"share": 100
}
]
}
},
"F8EeyxkR5EBs7ALaapV2jNos8jdbdgpqjtEaJ6fVfB3K": {
"name": "Skellies #4107",
"symbol": "SKULL",
"description": "Skellies is a collection of 8888 spooky skeletons presented by the SolSocks team",
"seller_fee_basis_points": 500,
"image": "https://www.arweave.net/mG5dY4GC-3g9j661NRQWoGYWKUtbqDvfhW8whDVVEF0?ext=png",
"attributes": [
{
"trait_type": "Background",
"value": "Pepto"
},
{
"trait_type": "Skin",
"value": "Purple Haze"
},
{
"trait_type": "Eyes",
"value": "Angry"
},
{
"trait_type": "Nose",
"value": "Double Double"
},
{
"trait_type": "Chest",
"value": "None"
},
{
"trait_type": "Ears",
"value": "none"
},
{
"trait_type": "Mouth",
"value": "WGMI #2"
},
{
"trait_type": "Glasses",
"value": "none"
},
{
"trait_type": "Headwear",
"value": "Droid"
},
{
"trait_type": "Limited Edition",
"value": "no"
},
{
"trait_type": "Dna",
"value": "82310019050"
}
],
"collection": {
"name": "Skellies X SolSocks",
"family": "Skellies"
},
"properties": {
"files": [
{
"uri": "https://www.arweave.net/mG5dY4GC-3g9j661NRQWoGYWKUtbqDvfhW8whDVVEF0?ext=png",
"type": "image/png"
}
],
"category": "image",
"creators": [
{
"address": "CpvHujvbSJ9btvPmP5FUKC8QpGM8AQjFk7uLJSsomoH2",
"share": 85
},
{
"address": "BQ6FxfRVDWKUVeqD9uHFqBjebJ9Um8RVzPTPZ1bBoByU",
"share": 15
}
]
}
},
}
I need to keep only the tokens with a specific collection.name: "Skellies X SolSocks".
I cannot use map because is an object.
Is there a map/filter/reduce function I can use?
You could use Object.entries(), to get an array of the objects key/value pairs.
We can then use Array.filter() to filter by any property, in this case name, then we can use Object.fromEntries() to create the desired result.
let obj = { "AFjQbjBwEF4HfBgKYTeK3SZg4cGRuB9o3rNGmQvHwtFX": { "name": "000# Heartbreak", "symbol": "NNPOSTER", "description": "The crystal broken heart is a mirror through which residents of the NEONEXUS can take a peek into the real world as we know it.", "seller_fee_basis_points": 500, "image": "https://arweave.net/8TpUvw7hi7N_rVuG6avV_cOX2bXQ7OsY-ZNtILCM-zo?ext=jpg", "animation_url": "https://arweave.net/WdzVw-_XE7LQArXArYJNpeMSgFbYYwa1ATpCVrfrTK8?ext=mp4", "external_url": "https://neonexus.io", "attributes": [ { "trait_type": "City", "value": "Miami" }, { "trait_type": "Theme", "value": "Heartbreak in Miami" }, { "trait_type": "Origin", "value": "Airdrop" }, { "trait_type": "Scene", "value": "Moody" }, { "trait_type": "Period", "value": "Lockdown" }, { "trait_type": "Artist", "value": "Daramola" } ], "collection": { "name": "NEONEXUS Posters", "family": "Raynesfere" }, "properties": { "files": [ { "uri": "https://arweave.net/8TpUvw7hi7N_rVuG6avV_cOX2bXQ7OsY-ZNtILCM-zo?ext=jpg", "type": "image/gif" }, { "uri": "https://arweave.net/WdzVw-_XE7LQArXArYJNpeMSgFbYYwa1ATpCVrfrTK8?ext=mp4", "type": "video/mp4" } ], "category": "video", "creators": [ { "address": "Ef896VQS1tfMACgL5Ce1TR7JZhehkrtowCyZZyYv7SWn", "share": 100 } ] } }, "F8EeyxkR5EBs7ALaapV2jNos8jdbdgpqjtEaJ6fVfB3K": { "name": "Skellies #4107", "symbol": "SKULL", "description": "Skellies is a collection of 8888 spooky skeletons presented by the SolSocks team", "seller_fee_basis_points": 500, "image": "https://www.arweave.net/mG5dY4GC-3g9j661NRQWoGYWKUtbqDvfhW8whDVVEF0?ext=png", "attributes": [ { "trait_type": "Background", "value": "Pepto" }, { "trait_type": "Skin", "value": "Purple Haze" }, { "trait_type": "Eyes", "value": "Angry" }, { "trait_type": "Nose", "value": "Double Double" }, { "trait_type": "Chest", "value": "None" }, { "trait_type": "Ears", "value": "none" }, { "trait_type": "Mouth", "value": "WGMI #2" }, { "trait_type": "Glasses", "value": "none" }, { "trait_type": "Headwear", "value": "Droid" }, { "trait_type": "Limited Edition", "value": "no" }, { "trait_type": "Dna", "value": "82310019050" } ], "collection": { "name": "Skellies X SolSocks", "family": "Skellies" }, "properties": { "files": [ { "uri": "https://www.arweave.net/mG5dY4GC-3g9j661NRQWoGYWKUtbqDvfhW8whDVVEF0?ext=png", "type": "image/png" } ], "category": "image", "creators": [ { "address": "CpvHujvbSJ9btvPmP5FUKC8QpGM8AQjFk7uLJSsomoH2", "share": 85 }, { "address": "BQ6FxfRVDWKUVeqD9uHFqBjebJ9Um8RVzPTPZ1bBoByU", "share": 15 } ] } }, }
const searchTerm = 'Skellies';
const result = Object.fromEntries(Object.entries(obj).filter(([key, val]) => {
return val.name.includes(searchTerm);
}));
console.log('Result:', result)
.as-console-wrapper { max-height: 100% !important; top: 0; }
You could also try a for .. in loop to iterate over the object keys, adding any child objects with a matching name value.
let obj = { "AFjQbjBwEF4HfBgKYTeK3SZg4cGRuB9o3rNGmQvHwtFX": { "name": "000# Heartbreak", "symbol": "NNPOSTER", "description": "The crystal broken heart is a mirror through which residents of the NEONEXUS can take a peek into the real world as we know it.", "seller_fee_basis_points": 500, "image": "https://arweave.net/8TpUvw7hi7N_rVuG6avV_cOX2bXQ7OsY-ZNtILCM-zo?ext=jpg", "animation_url": "https://arweave.net/WdzVw-_XE7LQArXArYJNpeMSgFbYYwa1ATpCVrfrTK8?ext=mp4", "external_url": "https://neonexus.io", "attributes": [ { "trait_type": "City", "value": "Miami" }, { "trait_type": "Theme", "value": "Heartbreak in Miami" }, { "trait_type": "Origin", "value": "Airdrop" }, { "trait_type": "Scene", "value": "Moody" }, { "trait_type": "Period", "value": "Lockdown" }, { "trait_type": "Artist", "value": "Daramola" } ], "collection": { "name": "NEONEXUS Posters", "family": "Raynesfere" }, "properties": { "files": [ { "uri": "https://arweave.net/8TpUvw7hi7N_rVuG6avV_cOX2bXQ7OsY-ZNtILCM-zo?ext=jpg", "type": "image/gif" }, { "uri": "https://arweave.net/WdzVw-_XE7LQArXArYJNpeMSgFbYYwa1ATpCVrfrTK8?ext=mp4", "type": "video/mp4" } ], "category": "video", "creators": [ { "address": "Ef896VQS1tfMACgL5Ce1TR7JZhehkrtowCyZZyYv7SWn", "share": 100 } ] } }, "F8EeyxkR5EBs7ALaapV2jNos8jdbdgpqjtEaJ6fVfB3K": { "name": "Skellies #4107", "symbol": "SKULL", "description": "Skellies is a collection of 8888 spooky skeletons presented by the SolSocks team", "seller_fee_basis_points": 500, "image": "https://www.arweave.net/mG5dY4GC-3g9j661NRQWoGYWKUtbqDvfhW8whDVVEF0?ext=png", "attributes": [ { "trait_type": "Background", "value": "Pepto" }, { "trait_type": "Skin", "value": "Purple Haze" }, { "trait_type": "Eyes", "value": "Angry" }, { "trait_type": "Nose", "value": "Double Double" }, { "trait_type": "Chest", "value": "None" }, { "trait_type": "Ears", "value": "none" }, { "trait_type": "Mouth", "value": "WGMI #2" }, { "trait_type": "Glasses", "value": "none" }, { "trait_type": "Headwear", "value": "Droid" }, { "trait_type": "Limited Edition", "value": "no" }, { "trait_type": "Dna", "value": "82310019050" } ], "collection": { "name": "Skellies X SolSocks", "family": "Skellies" }, "properties": { "files": [ { "uri": "https://www.arweave.net/mG5dY4GC-3g9j661NRQWoGYWKUtbqDvfhW8whDVVEF0?ext=png", "type": "image/png" } ], "category": "image", "creators": [ { "address": "CpvHujvbSJ9btvPmP5FUKC8QpGM8AQjFk7uLJSsomoH2", "share": 85 }, { "address": "BQ6FxfRVDWKUVeqD9uHFqBjebJ9Um8RVzPTPZ1bBoByU", "share": 15 } ] } }, }
const result = {};
const searchTerm = 'Skellies';
for(let k in obj) {
if (obj[k] && ((obj[k].name || "").includes(searchTerm))) {
result[k] = obj[k];
}
}
console.log('Result:', result);
.as-console-wrapper { max-height: 100% !important; top: 0; }
You can simply use a for loop to loop over the object's entries:
const yourObject = {"AFjQbjBwEF4HfBgKYTeK3SZg4cGRuB9o3rNGmQvHwtFX":{"name":"000# Heartbreak","symbol":"NNPOSTER","description":"The crystal broken heart is a mirror through which residents of the NEONEXUS can take a peek into the real world as we know it.","seller_fee_basis_points":500,"image":"https://arweave.net/8TpUvw7hi7N_rVuG6avV_cOX2bXQ7OsY-ZNtILCM-zo?ext=jpg","animation_url":"https://arweave.net/WdzVw-_XE7LQArXArYJNpeMSgFbYYwa1ATpCVrfrTK8?ext=mp4","external_url":"https://neonexus.io","attributes":[{"trait_type":"City","value":"Miami"},{"trait_type":"Theme","value":"Heartbreak in Miami"},{"trait_type":"Origin","value":"Airdrop"},{"trait_type":"Scene","value":"Moody"},{"trait_type":"Period","value":"Lockdown"},{"trait_type":"Artist","value":"Daramola"}],"collection":{"name":"NEONEXUS Posters","family":"Raynesfere"},"properties":{"files":[{"uri":"https://arweave.net/8TpUvw7hi7N_rVuG6avV_cOX2bXQ7OsY-ZNtILCM-zo?ext=jpg","type":"image/gif"},{"uri":"https://arweave.net/WdzVw-_XE7LQArXArYJNpeMSgFbYYwa1ATpCVrfrTK8?ext=mp4","type":"video/mp4"}],"category":"video","creators":[{"address":"Ef896VQS1tfMACgL5Ce1TR7JZhehkrtowCyZZyYv7SWn","share":100}]}},"F8EeyxkR5EBs7ALaapV2jNos8jdbdgpqjtEaJ6fVfB3K":{"name":"Skellies #4107","symbol":"SKULL","description":"Skellies is a collection of 8888 spooky skeletons presented by the SolSocks team","seller_fee_basis_points":500,"image":"https://www.arweave.net/mG5dY4GC-3g9j661NRQWoGYWKUtbqDvfhW8whDVVEF0?ext=png","attributes":[{"trait_type":"Background","value":"Pepto"},{"trait_type":"Skin","value":"Purple Haze"},{"trait_type":"Eyes","value":"Angry"},{"trait_type":"Nose","value":"Double Double"},{"trait_type":"Chest","value":"None"},{"trait_type":"Ears","value":"none"},{"trait_type":"Mouth","value":"WGMI #2"},{"trait_type":"Glasses","value":"none"},{"trait_type":"Headwear","value":"Droid"},{"trait_type":"Limited Edition","value":"no"},{"trait_type":"Dna","value":"82310019050"}],"collection":{"name":"Skellies X SolSocks","family":"Skellies"},"properties":{"files":[{"uri":"https://www.arweave.net/mG5dY4GC-3g9j661NRQWoGYWKUtbqDvfhW8whDVVEF0?ext=png","type":"image/png"}],"category":"image","creators":[{"address":"CpvHujvbSJ9btvPmP5FUKC8QpGM8AQjFk7uLJSsomoH2","share":85},{"address":"BQ6FxfRVDWKUVeqD9uHFqBjebJ9Um8RVzPTPZ1bBoByU","share":15}]}}};
const tokens = [];
const filteredObject = {};
for (let [token, entry] of Object.entries(yourObject)) {
if (entry.collection.name === 'Skellies X SolSocks') {
tokens.push(token);
filteredObject[token] = entry;
}
}
console.log(tokens);
console.log(filteredObject);
I have a JSON as below
{
"Header": {
"Time": "2020-06-09T07:03:20-07:00",
"ReportName": "JournalReport",
"StartPeriod": "2020-06-09",
"EndPeriod": "2020-06-09",
"Currency": "USD",
"Option": [
{
"Name": "NoReportData",
"Value": "false"
}
]
},
"Columns": {
"Column": [
{
"ColTitle": "Date",
"ColType": "Date",
"MetaData": [
{
"Name": "ColKey",
"Value": "tx_date"
}
]
},
{
"ColTitle": "Transaction Type",
"ColType": "String",
"MetaData": [
{
"Name": "ColKey",
"Value": "txn_type"
}
]
},
{
"ColTitle": "Num",
"ColType": "String",
"MetaData": [
{
"Name": "ColKey",
"Value": "doc_num"
}
]
},
{
"ColTitle": "Name",
"ColType": "String",
"MetaData": [
{
"Name": "ColKey",
"Value": "name"
}
]
},
{
"ColTitle": "Memo/Description",
"ColType": "String",
"MetaData": [
{
"Name": "ColKey",
"Value": "memo"
}
]
},
{
"ColTitle": "Account",
"ColType": "String",
"MetaData": [
{
"Name": "ColKey",
"Value": "account_name"
}
]
},
{
"ColTitle": "Debit",
"ColType": "Money",
"MetaData": [
{
"Name": "ColKey",
"Value": "debt_home_amt"
}
]
},
{
"ColTitle": "Credit",
"ColType": "Money",
"MetaData": [
{
"Name": "ColKey",
"Value": "credit_home_amt"
}
]
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"value": "0-00-00"
},
{
"value": "",
"id": "559"
},
{
"value": ""
},
{
"value": "",
"id": ""
},
{
"value": ""
},
{
"value": "California Department of Tax and Fee Administration Payable",
"id": "678"
},
{
"value": ""
},
{
"value": "1.25"
}
],
"type": "Data"
},
{
"ColData": [
{
"value": "0-00-00"
},
{
"value": "",
"id": "559"
},
{
"value": ""
},
{
"value": "",
"id": ""
},
{
"value": ""
},
{
"value": "California Department of Tax and Fee Administration Payable",
"id": "678"
},
{
"value": ""
},
{
"value": ".10"
}
],
"type": "Data"
},
{
"Summary": {
"ColData": [
{
"value": ""
},
{
"value": ""
},
{
"value": ""
},
{
"value": ""
},
{
"value": ""
},
{
"value": ""
},
{
"value": "31.75"
},
{
"value": "31.75"
}
]
},
"type": "Section"
},
{
"ColData": [
{
"value": "0-00-00"
},
{
"value": "",
"id": "567"
},
{
"value": ""
},
{
"value": "",
"id": ""
},
{
"value": ""
},
{
"value": "Accounts Payable (A/P)",
"id": "676"
},
{
"value": "232.00"
},
{
"value": ""
}
],
"type": "Data"
}
]
}
}
I want to filter this array which matches Rows.Row[someindex].ColData[1].id == 567. Here id should match with second object of ColData array.
But after filtering i don't want to skip the records from resulting array those have Summary as Rows.Row[someindex].Summary. Summary records should be included in resulting array.
I have tried below code but it does not work because In Row.Row array Summary can be there instead of ColData at some indexs & also i want include Summary records in resulting array even if i have found the desired object.
function getResult(filterbY, objList) {
return objList.Rows.Row.filter(function(obj) {
return obj.ColData.some(function(item){
return item.id == filterbY;
});
});
}
Please help with the same ?
you need to include your summary in your filter function then,
function getResult(filterbY, objList) {
return objList.Rows.Row.filter(function(obj) {
if(obj.Summary){return true;}
return obj.ColData.some(function(item){
return item.id == filterbY;
});
});
}
How can I create Scrollable X-axis using Fusioncharts? I'm trying to create a scrollbar like this for stacked bar and line graph combination.
Can I add scrollbar by using any inbuilt functions provided by Fusioncharts library?
Can someone please help me with a solution?
/StackOverflow didn't accepted my question, so I added this comment to the increase question length/
const dataSource = {
"chart": {
"subcaption": "2016 - 2021",
"syaxisname": "YoY growth in %",
"formatnumberscale": "0",
"numberprefix": "$",
"numbersuffix": "M",
"snumbersuffix": "%",
"showvalues": "0",
"plottooltext": "Market size for $seriesName in $label is <b>$dataValue</b>",
"theme": "fusion"
},
"categories": [
{
"category": [
{
"label": "2016"
},
{
"label": "2017"
},
{
"label": "2018"
},
{
"label": "2019"
},
{
"label": "2020"
}
]
}
],
"dataset": [
{
"seriesname": "RPA Software",
"data": [
{
"value": "73"
},
{
"value": "113"
},
{
"value": "153"
},
{
"value": "192"
},
{
"value": "232"
}
]
},
{
"seriesname": "RPA Services",
"data": [
{
"value": "198"
},
{
"value": "330"
},
{
"value": "476"
},
{
"value": "630"
},
{
"value": "790"
}
]
},
{
"seriesname": "YoY Growth",
"parentyaxis": "S",
"plottooltext": "$dataValue growth expected in $label",
"renderas": "line",
"data": [
{
"value": "73"
},
{
"value": "63"
},
{
"value": "42"
},
{
"value": "31"
},
{
"value": "24"
},
{
"value": "20"
}
]
}
]
};
FusionCharts.ready(function() {
var myChart = new FusionCharts({
type: "stackedcolumn3dlinedy",
renderAt: "chart-container",
width: "100%",
height: "100%",
dataFormat: "json",
dataSource
}).render();
});
The chart which you are looking for is scrollcombidy2d
Here is a demo - http://jsfiddle.net/nqt410Lk/
const dataSource = {
"chart": {
"caption": "Analysing Subsidies by Youth Population",
"subcaption": "By province",
"yaxisname": "Population Count",
"syaxisname": "Subsidies % of Income",
"labeldisplay": "rotate",
"snumbersuffix": "%",
"scrollheight": "10",
"numvisibleplot": "10",
"drawcrossline": "1",
"theme": "fusion"
},
"categories": [{
"category": [{
"label": "Matzikama"
},
{
"label": "Cederberg"
},
{
"label": "Bergrivier"
},
{
"label": "Saldanha Bay"
},
{
"label": "Swartland"
},
{
"label": "Witzenberg"
},
{
"label": "Drakenstein"
},
{
"label": "Stellenbosch"
},
{
"label": "Breede Valley"
},
{
"label": "Langeberg"
},
{
"label": "Swellendam"
},
{
"label": "Theewaterskloof"
},
{
"label": "Overstrand"
},
{
"label": "Cape Agulhas"
},
{
"label": "Kannaland"
},
{
"label": "Hessequa"
},
{
"label": "Mossel Bay"
},
{
"label": "George"
},
{
"label": "Oudtshoorn"
},
{
"label": "Bitou"
},
{
"label": "Knysna"
},
{
"label": "Laingsburg"
},
{
"label": "Prince Albert"
},
{
"label": "Beaufort West"
}
]
}],
"dataset": [{
"seriesname": "Total Population",
"plottooltext": "Population: $dataValue",
"data": [{
"value": "71045"
},
{
"value": "52949"
},
{
"value": "67474"
},
{
"value": "111173"
},
{
"value": "133762"
},
{
"value": "130548"
},
{
"value": "280195"
},
{
"value": "173419"
},
{
"value": "176578"
},
{
"value": "105483"
},
{
"value": "40211"
},
{
"value": "117109"
},
{
"value": "93466"
},
{
"value": "36000"
},
{
"value": "24168"
},
{
"value": "54237"
},
{
"value": "94135"
},
{
"value": "208237"
},
{
"value": "97509"
},
{
"value": "59157"
},
{
"value": "73835"
},
{
"value": "8895"
},
{
"value": "14272"
},
{
"value": "51080"
}
]
},
{
"seriesname": "Youth",
"renderas": "area",
"showanchors": "0",
"plottooltext": "Youth: $dataValue",
"data": [{
"value": "24598"
},
{
"value": "18302"
},
{
"value": "22162"
},
{
"value": "40696"
},
{
"value": "47420"
},
{
"value": "49981"
},
{
"value": "97230"
},
{
"value": "73162"
},
{
"value": "60668"
},
{
"value": "34594"
},
{
"value": "12567"
},
{
"value": "39907"
},
{
"value": "30681"
},
{
"value": "11323"
},
{
"value": "7801"
},
{
"value": "15785"
},
{
"value": "31478"
},
{
"value": "72762"
},
{
"value": "32301"
},
{
"value": "21401"
},
{
"value": "27863"
},
{
"value": "3254"
},
{
"value": "5562"
},
{
"value": "19047"
}
]
},
{
"seriesname": "Subsidies received %",
"parentyaxis": "S",
"renderas": "line",
"plottooltext": "$dataValue subsidies received",
"showvalues": "0",
"data": [{
"value": "28.0"
},
{
"value": "35.2"
},
{
"value": "23.9"
},
{
"value": "11.8"
},
{
"value": "18.0"
},
{
"value": "26.9"
},
{
"value": "11.1"
},
{
"value": "11.2"
},
{
"value": "24.0"
},
{
"value": "18.9"
},
{
"value": "35.6"
},
{
"value": "37.9"
},
{
"value": "12.9"
},
{
"value": "27.6"
},
{
"value": "40.5"
},
{
"value": "19.9"
},
{
"value": "15.6"
},
{
"value": "28.2"
},
{
"value": "23.3"
},
{
"value": "26.2"
},
{
"value": "16.9"
},
{
"value": "41.9"
},
{
"value": "62.1"
},
{
"value": "31.2"
}
]
}
]
};
FusionCharts.ready(function() {
var myChart = new FusionCharts({
type: "scrollcombidy2d",
renderAt: "chart-container",
width: "100%",
height: "400",
dataFormat: "json",
dataSource
}).render();
});
If I have multiple charts, say a stacked bar and a pie chart on my page. I would like to interact (e.g. click) on one of it and see some visual update on the other chart.
I tried creating them using FusionCharts in the following manner:
FusionCharts.ready(function() {
var pieChart = new FusionCharts({
type: 'pie2d',
renderAt: 'pieContainer',
width: '400',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Company Revenue",
"enableMultiSlicing": "0",
"bgcolor": "FFFFFF",
"showvalues": "1",
"showpercentvalues": "1",
"showborder": "0",
"showplotborder": "0",
"showlegend": "1",
"legendborder": "0",
"legendposition": "bottom",
"enablesmartlabels": "1",
"use3dlighting": "0",
"showshadow": "0",
"legendbgcolor": "#CCCCCC",
"legendbgalpha": "20",
"legendborderalpha": "0",
"legendshadow": "0",
"legendnumcolumns": "3",
"palettecolors": "#f8bd19,#e44a00,#008ee4,#33bdda,#6baa01,#583e78"
},
"data": [{
"label": "Services",
"value": "26"
}, {
"label": "Hardware",
"value": "32"
}, {
"label": "Software",
"value": "42"
}]
}
}).render();
var stackedBar = new FusionCharts({
type: 'stackedBar2D',
renderAt: 'barContainer',
width: '400',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Company Revenue",
"xaxisname": "Month",
"yaxisname": "Revenue",
"bgcolor": "FFFFFF",
"outcnvbasefontcolor": "666666",
"numberprefix": "$",
"showvalues": "0",
"numvdivlines": "10",
"showalternatevgridcolor": "1",
"alternatevgridcolor": "e1f5ff",
"divlinecolor": "e1f5ff",
"vdivlinecolor": "e1f5ff",
"basefontcolor": "666666",
"tooltipbgcolor": "F3F3F3",
"tooltipbordercolor": "666666",
"canvasbordercolor": "666666",
"canvasborderthickness": "1",
"showplotborder": "1",
"plotfillalpha": "80",
"showborder": "0",
"legendbgcolor": "#CCCCCC",
"legendbgalpha": "20",
"legendborderalpha": "0",
"legendshadow": "0",
"legendnumcolumns": "3"
},
"categories": [{
"category": [{
"label": "Jan"
}, {
"label": "Feb"
}, {
"label": "Mar"
}, {
"label": "Apr"
}, {
"label": "May"
}, {
"label": "Jun"
}, {
"label": "Jul"
}, {
"label": "Aug"
}, {
"label": "Sep"
}, {
"label": "Oct"
}, {
"label": "Nov"
}, {
"label": "Dec"
}]
}],
"dataset": [{
"seriesname": "Product A",
"data": [{
"value": "27400"
}, {
"value": "29800"
}, {
"value": "25800"
}, {
"value": "26800"
}, {
"value": "29600"
}, {
"value": "32600"
}, {
"value": "31800"
}, {
"value": "36700"
}, {
"value": "29700"
}, {
"value": "31900"
}, {
"value": "34800"
}, {
"value": "24800"
}]
}, {
"seriesname": "Product B",
"data": [{
"value": "10000"
}, {
"value": "11500"
}, {
"value": "12500"
}, {
"value": "15000"
}, {
"value": "11000"
}, {
"value": "9800"
}, {
"value": "11800"
}, {
"value": "19700"
}, {
"value": "21700"
}, {
"value": "21900"
}, {
"value": "22900"
}, {
"value": "20800"
}]
}],
"trendlines": [{
"line": [{
"startvalue": "42000",
"color": "91C728",
"displayvalue": "Target",
"showontop": "1"
}]
}],
"styles": {
"definition": [{
"name": "CanvasAnim",
"type": "animation",
"param": "_xScale",
"start": "0",
"duration": "1"
}],
"application": [{
"toobject": "Canvas",
"styles": "CanvasAnim"
}]
}
}
}).render();
});
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<div>
<span id="barContainer">FusionCharts XT will load here!</span>
<span id="pieContainer">FusionCharts XT will load here!</span>
</div>
Now how to update the other chart on interacting one of the chart? Say by clicking or hovering plots on one of the chart, has its visual update in another chart.
**Note: ** The data is not relevant in this case. Only the chart to chart interactivity needs to be established. There is no restriction on JS library being used and can be entirely based on the responder choice.Any help is highly appreciable.
With highcharts, you could override the click function, then update whichever properties you want.
See: http://api.highcharts.com/highcharts#chart.events
I do not know how it is with FusionCharts, although I think syncing data between different type of charts should be possible, but I was using a lot amCharts and if you have no restriction on library then I put this quick tips link to show you what you can fairly quickly implement there.
http://www.amcharts.com/tips/automatically-syncing-pie-chart-data-column-chart-hover/
I am relatively new to both MVC and FusionCharts. I Have a View where the Model contains all the data I need, I need to pass this(or rather specific data from the model) to the FusionChart.
I have a FusionChart that I got from their site(FusionCharts), which has hard coded values, but have no idea how to replace this with the data from my model. Below is my FusionChart :
FusionCharts.ready(function () {
var hourlySalesChart = new FusionCharts({
type: 'multiaxisline',
renderAt: 'chart-container2',
width: '600',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Revenue Analysis",
"subcaption": "Last 12 weeks",
"baseFontColor": "#333333",
"baseFont": "Helvetica Neue,Arial",
"xaxisname": "Week of Year",
"showvalues": "0",
"numvdivlines": "2",
"paletteColors": "#0075c2,#1aaf5d,#f2c500,#f45b00",
"bgColor": "#ffffff",
"canvasBgColor": "#ffffff",
"captionFontSize": "13",
"subcaptionFontSize": "13",
"subcaptionFontBold": "0",
"showBorder": "0",
"showPlotBorder": "0",
"showXAxisLine": "1",
"showShadow": "0",
"showCanvasBorder": "0",
"showAlternateHGridColor": "0",
"showalternatevgridcolor": "1",
"usePlotGradientColor": "0",
"divlineColor": "#999999",
"divlineThickness": "1",
"divLineIsDashed": "1",
"divLineDashLen": "1",
"divLineGapLen": "1",
"xAxisLineThickness": "1",
"xAxisLineColor": "#999999",
"legendBorderAlpha": "0",
"legendShadow": "0",
"alignCaptionWithCanvas": "0"
},
"categories": [
{
"category": [
{ "label": "0" },
{ "label": "5000.00" },
{ "label": "4000.00" },
{ "label": "6000.00" },
{ "label": "8000.00" },
{ "label": "10000.00" },
{ "label": "12000.00" },
{ "label": "14000.00" },
{ "label": "16000.00" }
]
}
],
"axis": [
{
"title": "Revenue",
"titlepos": "left",
"tickwidth": "10",
"numberPrefix": "$",
"divlineisdashed": "1",
"dataset": [
{
"seriesname": "Revenue",
"linethickness": "3",
"data": [
{ "value": "137500" },
{ "value": "124350" },
{ "value": "156700" },
{ "value": "131450" },
{ "value": "208300" },
{ "value": "219900" },
{ "value": "227500" },
{ "value": "254300" },
{ "value": "155900" },
{ "value": "105650" },
{ "value": "120950" },
{ "value": "127500" }
]
}
]
}, {
"title": "Orders",
"axisonleft": "0",
"titlepos": "right",
"numdivlines": "8",
"tickwidth": "10",
"divlineisdashed": "1",
"dataset": [
{
"seriesname": "Orders",
"data": [
{ "value": "22567" },
{ "value": "21348" },
{ "value": "24846" },
{ "value": "19237" },
{ "value": "20672" },
{ "value": "23403" },
{ "value": "30278" },
{ "value": "26719" },
{ "value": "21940" },
{ "value": "24396" },
{ "value": "22340" },
{ "value": "25439" }
]
}
]
},
{
"title": "Footfalls",
"titlepos": "RIGHT",
"axisonleft": "0",
"numdivlines": "5",
"tickwidth": "10",
"numberSuffix": "",
"divlineisdashed": "1",
"dataset": [
{
"seriesname": "Footfalls",
"data": [
{ "value": "68473" },
{ "value": "57934" },
{ "value": "78925" },
{ "value": "69213" },
{ "value": "74892" },
{ "value": "81123" },
{ "value": "90086" },
{ "value": "91174" },
{ "value": "68934" },
{ "value": "80934" },
{ "value": "73634" },
{ "value": "84453" }
]
}
]
}
]
}
}).render();
});
I have also tried populating a string with the XML data and then did the following :
FusionCharts.ready(function () {
var hourlySalesChart = new FusionCharts({
type: 'multiaxisline',
renderAt: 'chart-container2',
width: '600',
height: '350'
});
hourlySalesChart.setXMLData(#Model.strChartData); // - This gives an error : Incorrect Syntax
hourlySalesChart.render();
If anyone could help point me to the right direction, I would greatly appreciate it.
Thanks!