Add slider to line chart fusion chart - slider

I am using Fusion Chart library for building line chart. I want a slider at the bottom of the chart so values can change when slider is moved back and forth. How can we achieve this in fusion charts ?

Are you looking for a solution like this ? http://jsfiddle.net/subramaniashiva/anrsydf7/
I have used the getJSONData and setJSONData of FusionCharts and updated the line chart based on the value from slider.
FusionCharts.ready(function() {
var chartConfig = {
"caption": "Total footfall in Bakersfield Central - Admin View",
"subCaption": "Year 2014",
"xAxisName": "Month",
"yAxisName": "No. of Visitors",
//Cosmetics
"lineThickness": "2",
"paletteColors": "#0075c2",
"baseFontColor": "#333333",
"baseFont": "Helvetica Neue,Arial",
"captionFontSize": "14",
"subcaptionFontSize": "14",
"subcaptionFontBold": "0",
"showBorder": "0",
"bgColor": "#ffffff",
"showShadow": "0",
"canvasBgColor": "#ffffff",
"canvasBorderAlpha": "0",
"divlineAlpha": "100",
"divlineColor": "#999999",
"divlineThickness": "1",
"divLineIsDashed": "1",
"divLineDashLen": "1",
"divLineGapLen": "1",
"showXAxisLine": "1",
"xAxisLineThickness": "1",
"xAxisLineColor": "#999999",
"showAlternateHGridColor": "0",
"yAxisMinValue": "0",
"yAxisMaxValue": "100",
"animation": "0"
},
chartData = [{
"label": "Jan",
"value": "42"
}, {
"label": "Feb",
"value": "81"
}, {
"label": "Mar",
"value": "36"
}],
revenueChart = new FusionCharts({
type: 'line',
renderAt: 'chart-container',
width: '550',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": chartConfig,
"data": chartData
}
});
revenueChart.render();
document.getElementById('slider').oninput = function() {
var currentData = revenueChart.getJSONData(),
selectedMonth = document.getElementById("monthSelector").selectedIndex;
currentData.data[selectedMonth].value = this.value.toString();
revenueChart.setJSONData(currentData);
};
});

Related

QuickBooks Online API - Sales tax: trying to override automatic sales tax, but it's not respecting my inputs

QBOnline API: Problems with overriding Sales Tax - passed in values not respected on Invoice (AST seems to override my override)
Hi all,
Yes, I'm new to the API. Diving in head first! :)
I'm trying to troubleshoot a problem with my app. It's submitting new Invoices to the QBOnline API, and passing in all the line item information. We aren't trying to use the AST system - so I was trying to set the override values. (Documentation: https://developer.intuit.com/app/developer/qbo/docs/workflows/manage-sales-tax-for-us-locales#specifying-sales-tax)
I think that I am providing the values correctly, but the system is still calculating it's own sales tax amount.
Target API URL:
https://sandbox-quickbooks.api.intuit.com/v3/company/4620816365232674520/Invoice?minorversion=4
Here's an example of the object we are passing in (edited for privacy, expanded for human readability):
{
"BillAddr": {
"City": "AnywhereVille",
"Country": "USA",
"CountrySubDivisionCode": "CA",
"Line1": "",
"Line2": "Customer Name LLP",
"Line3": "45 E. Pacific Coast Highway",
"Line4": "",
"PostalCode": "90804"
},
"CustomField": [{
"DefinitionId": "1",
"Name": "P.O. Number",
"StringValue": "",
"Type": "StringType"
}, {
"DefinitionId": "2",
"Name": "Sales Rep",
"StringValue": "TY",
"Type": "StringType"
}],
"CustomerMemo": {
"value": "Pay your invoice online at: ..."
},
"CustomerRef": {
"value": "60"
},
"DocNumber": "11111",
"DueDate": "2022-08-01",
"Line": [{
"Amount": 576,
"Description": "",
"DetailType": "SalesItemLineDetail",
"LineNum": 1,
"SalesItemLineDetail": {
"ClassRef": {
"name": "3 Studios",
"value": "1111111111111"
},
"ItemRef": {
"name": "16GBUSBFLASH",
"value": "21"
},
"Qty": 48,
"TaxCodeRef": {
"value": "TAX"
},
"UnitPrice": 12
}
}, {
"Amount": 168,
"Description": "",
"DetailType": "SalesItemLineDetail",
"LineNum": 4,
"SalesItemLineDetail": {
"ClassRef": {
"name": "3 Studios",
"value": "1111111111111"
},
"ItemRef": {
"name": "DVDMEDIA",
"value": "23"
},
"Qty": 12,
"TaxCodeRef": {
"value": "TAX"
},
"UnitPrice": 14
}
}, {
"Amount": 600,
"Description": "",
"DetailType": "SalesItemLineDetail",
"LineNum": 6,
"SalesItemLineDetail": {
"ClassRef": {
"name": "3 Studios",
"value": "1111111111111"
},
"ItemRef": {
"name": "DIGITALDEL30",
"value": "25"
},
"Qty": 12,
"TaxCodeRef": {
"value": "TAX"
},
"UnitPrice": 50
}
}],
"SalesTermRef": {
"value": "8"
},
"TxnDate": "2022-08-01",
"TxnTaxDetail": {
"TaxLine": [{
"Amount": 130.98,
"DetailType": "TaxLineDetail",
"TaxLineDetail": {
"NetAmountTaxable": 576,
"PercentBased": true,
"TaxPercent": 0.0925,
"TaxRateRef": {
"value": "4"
}
}
}],
"TotalTax": 130.98,
"TxnTaxCodeRef": {
"value": "4"
}
}
}

How do I format currency in Vega-Lite?

I'm trying to format values as currency in the Vega-Lite editor. I'm attempting to copy the docs but I'm getting a weird error. The Y axis is a numerical value. Passing in a formatting string gives "value expected".
Here's the json:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Protocol Chart",
"width": 500,
"height": 225,
"data": {
"values": [
{
"asset": "eth",
"time": "2021-06-15T00:00:00Z",
"ReferenceRateUSD": "2577.04473863238"
},
{
"asset": "eth",
"time": "2021-06-16T00:00:00Z",
"ReferenceRateUSD": "2552.74103641146"
},
{
"asset": "eth",
"time": "2021-06-17T00:00:00Z",
"ReferenceRateUSD": "2360.99938690824"
}
]
},
"config": {
"view": {
"stroke": "transparent"
}
},
"mark": "line",
"encoding": {
"x": {
"axis": {
"domainColor": "#DDD",
"grid": false,
"labelColor": "#AEAEAE",
"ticks": false,
"labelPadding": 10
},
"field": "time",
"type": "temporal",
"title": ""
},
"y": {
"axis": {
"labelOffset": 2,
"domainColor": "white",
"labelColor": "#AEAEAE",
"ticks": false,
"labelPadding": 10,
"format": '$.2f'
},
"field": "ReferenceRateUSD",
"type": "quantitative",
"title": "",
"scale": {
"zero": false
}
},
"color": {
"field": "doesntmatter",
"type": "nominal",
"legend": null,
"scale": {
"range": ["#91DB97"]
}
}
}
}
What am I missing here? How do I get it to accept my formatting string?
"$.2f" looks like a the correct d3-format string for currency, but note that this is only valid if the associated formatType is "number" (see axis label docs).
Since you did not include a full reproducible example of the problem you're seeing, I can only venture a guess that your data type is not numeric, and this is why the formatting is failing. If that's not the case, I'd suggest editing your question to provide a complete example of the error you're seeing.
Edit: your full example appears to work correctly with the current version of vega/vega-lite (view in editor):
Perhaps you need to update your vega/vega-lite libraries?

How can I check checkboxes and disabled in jqxTreeGrid

I am trying to make some of checkboxes checked and disabled in jqxTreeGrid in below code:
$("#treegrid_portfolio").jqxTreeGrid(
{
source: dataAdapter,
pageable: true,
pagerMode: 'advanced',
pageSizeMode: 'root',
pageSize: 5,
pageSizeOptions: ['1', '2', '3', '5', '10'],
columnsResize: true,
sortable: true,
filterable: true,
theme: "custom",
filterMode: 'advanced',
altRows: false,
checkboxes: true,
columnsReorder: true,
hierarchicalCheckboxes: true,
width: getWidth("TreeGrid"),
/*width: "100%",*/
ready: function () {
$("#treegrid_portfolio").jqxTreeGrid('expandRow', '1');
$("#treegrid_portfolio").jqxTreeGrid('expandRow', '2');
}
,
columns: [
{
text: "ID", dataField: "formattedID", width: 120, pinned: true, cellclassname: "requestIdCls", resizable: false
}
,
{
text: '', datafield: 'alert', cellsrenderer: linkrendererAlert, width: 60, pinned: true, cellclassname: "alert_column", cellsAlign: 'center', filterable: false, resizable: false
}
,
{
text: "Portfolio Items Name", dataField: "PortfolioItem_Name", width: 200
}
,
{
text: "Agile Central Project Name", dataField: "AC_ProjectName", width: 200
}
]
}
);
Is it possible to make the same on grid ready function. I have done some research on the jqwidget. But didn't got any solution or clues. Please help me any one.
You need to make below changes also just put id attribute for each of your column data .Then put the id for selecting checkbox to set true.
follow this link i have get a fiddle for you Invoke the uncheckRow method.
var data = [{
"id": "1",
"name": "Corporate Headquarters",
"budget": "1230000",
"location": "Las Vegas",
"children": [{
"id": "2",
"name": "Finance Division",
"budget": "423000",
"location": "San Antonio",
"children": [{
"id": "3",
"name": "Accounting Department",
"budget": "113000",
"location": "San Antonio"
}, {
"id": "4",
"name": "Investment Department",
"budget": "310000",
"location": "San Antonio",
children: [{
"id": "5",
"name": "Banking Office",
"budget": "240000",
"location": "San Antonio"
}, {
"id": "6",
"name": "Bonds Office",
"budget": "70000",
"location": "San Antonio"
}, ]
}]
}, {
"id": "7",
"name": "Operations Division",
"budget": "600000",
"location": "Miami",
"children": [{
"id": "8",
"name": "Manufacturing Department",
"budget": "300000",
"location": "Miami"
}, {
"id": "9",
"name": "Public Relations Department",
"budget": "200000",
"location": "Miami"
}, {
"id": "10",
"name": "Sales Department",
"budget": "100000",
"location": "Miami"
}]
}, {
"id": "11",
"name": "Research Division",
"budget": "200000",
"location": "Boston"
}]
}];
var source = {
dataType: "json",
dataFields: [{
name: "name",
type: "string"
}, {
name: "budget",
type: "number"
}, {
name: "id",
type: "number"
}, {
name: "children",
type: "array"
}, {
name: "location",
type: "string"
}],
hierarchy: {
root: "children"
},
localData: data,
id: "id"
};
var dataAdapter = new $.jqx.dataAdapter(source, {
loadComplete: function () {
}
});
// create jqxTreeGrid.
$("#treeGrid").jqxTreeGrid({
source: dataAdapter,
altRows: true,
width: 680,
theme:'energyblue',
checkboxes: true,
ready: function () {
$("#treeGrid").jqxTreeGrid('expandRow', '1');
$("#treeGrid").jqxTreeGrid('expandRow', '2');
},
columns: [{
text: "Name",
align: "center",
dataField: "name",
width: 300
}, {
text: "Budget",
cellsAlign: "center",
align: "center",
dataField: "budget",
cellsFormat: "c2",
width: 250
}, {
text: "Location",
dataField: "location",
cellsAlign: "center",
align: "center"
}]
});
$("#jqxbutton").jqxButton({
theme: 'energyblue',
height: 30
});
$("#treeGrid").jqxTreeGrid('checkRow',2);
The last line of code
$("#treeGrid").jqxTreeGrid('checkRow',2); is reason to check the checkbox true while loading.
Please makesure if any help required.Hope it may help.
To check rows on grid ready function use checkRow method, and lockRow will disable editing of the row and give the row gray style.
3 or 8 are Unique ID which identifies the row Id (data field in data source).
ready: function () {
$("#treeGrid").jqxTreeGrid('checkRow', '3');
$("#treeGrid").jqxTreeGrid('lockRow', '3');
$("#treeGrid").jqxTreeGrid('checkRow', '8');
$("#treeGrid").jqxTreeGrid('lockRow', '8');
},
To disable checkboxes you can use rowUncheck event to prevent uncheck by checking the row again.
$('#treeGrid').on('rowUncheck', function (event) {
$("#treeGrid").jqxTreeGrid('checkRow', '3');
$("#treeGrid").jqxTreeGrid('checkRow', '8');
});
$("#treeGrid").jqxTreeGrid({
// ......
});

Why is my ItemFileReadStore data attribute is null?

I am using Dojo 1.10 to create an ItemFileReadStore object using AMD. Though the console did not report any error while creating the store, I could see from the debugger that the store.data is null. I tried the same code on my browser console (both chrome and firefox) but there too its the same issue (store data is null). Could someone please help me figure out if am I missing something?
require(["dojo/ready",
"dojo/on",
"dijit/registry",
"dojo/data/ItemFileReadStore"
], function(ready, on, registry, ItemFileReadStore) {
var resultTablecolumns = [{
label: 'ID',
attr: 'id',
sortable: true,
sorted: 'ascending',
width: 60,
vAlignment: "middle",
alignment: "right"
}, {
label: 'Hop',
attr: 'hop',
sortable: true,
sorted: 'ascending',
width: 100,
vAlignment: "middle",
alignment: "right"
}, {
label: 'Role',
attr: 'role',
sortable: true,
sorted: 'ascending',
width: 100,
vAlignment: "middle",
alignment: "right"
}, {
label: 'Status',
attr: 'status',
sortable: true,
sorted: 'ascending',
width: 100,
vAlignment: "middle",
alignment: "right"
}];
var storeItems = {
"identifier": "id",
"items": [{
"id": "1",
"hop": "first",
"role": "classification",
"status": ""
}, {
"id": "2",
"hop": "second",
"role": "propagation",
"status": "info"
}, {
"id": "3",
"hop": "third",
"role": "propagation",
"status": "warning"
}, {
"id": "4",
"hop": "fourth",
"role": "propagation",
"status": "error"
}, {
"id": "5",
"hop": "fifth",
"role": "enforcement",
"status": ""
}]
};
var resultTableStore = new ItemFileReadStore({
data: storeItems
});
console.log("resultTableStore === ", resultTableStore);
});
Can you show us your HTML?
Here is a working jsFiddle.
require(["dojo/data/ItemFileReadStore","dojo/dom", "dojo/domReady!"], function(ItemFileReadStore, dom ){
var storeItems = {
"identifier": "id",
"items": [{
"id": "1",
"hop": "first",
"role": "classification",
"status": ""
}]
};
var store = new ItemFileReadStore({data: storeItems});
console.log("ItemFileReadStore",ItemFileReadStore);
dom.byId('store').innerHTML = store ;
});
There is a new kid on the block which replaces the above store i.e dstore. Try it.
Ok, I figured out with the help of a co-worker.
I am actually creating a ItemFileReadStore and using it in constructing a data-grid. The grid was not showing up because its parent was hid when it got created, and hence got its width set to zero.
I understood from him that the data argument is processed on first fetch and used to populate internal structures. It is then nulled out as it is no longer used.
So in this case, what was happening is ItemFileReadStore's data argument was processed on first-fetch while creating the grid and then got set to null.

dojo how to get all tree node of specific type?

I wrote the following code to create a dojo tree.
store = new dojo.data.ItemFileWriteStore({url: link});
treeModel = new dijit.tree.TreeStoreModel({
store: store,
query: {
"type": "ROOT"
},
rootId: "newRoot",
childrenAttrs: ["children"]
});
tree= new dijit.Tree({model: treeModel},"treeOne");
Following is my JSON file structure :
{
identifier: "id",
label: "name",
items: [
{id: "ROOT",name: "Change Windows",type: "ROOT"},
]}
I want to get all the nodes (basically their 'id' part)of specific 'type',lets say type= "ROOT". Is there anyway to get all those node? I thought of doing this using tree._itemNodeMap, but don't know any way to iterate through this whole item map,because it need a id as a input to return any specific node.
If you're talking about obtaining the data items programatically, you can get them straight from the store using fetch.
Sample JSON for ItemFile*Store:
{
"identifier": "id",
"label": "name",
"items": [{
"id": "ROOT",
"name": "Root",
"type": "ROOT",
"children": [{
"id": "P1",
"name": "StackExchange",
"type": "website",
"children": [{
"id": "C1",
"name": "StackOverflow",
"type": "website"
},
{
"id": "C2",
"name": "ServerFault",
"type": "website"
}]
},
{
"id": "P2",
"name": "Sandwich",
"type": "food",
"children": [{
"id": "C3",
"name": "Ham",
"type": "food"
},
{
"id": "C4",
"name": "Cheese",
"type": "food"
}]
},
{
"id": "P3",
"name": "Potluck",
"type": "mixed",
"children": [{
"id": "C5",
"name": "Google",
"type": "website"
},
{
"id": "C6",
"name": "Banana",
"type": "food"
}]
}]
}]
}
Sample code:
dojo.require('dojo.data.ItemFileReadStore');
dojo.ready(function() {
var store = new dojo.data.ItemFileReadStore({
url: 'so-data.json'
});
store.fetch({
query: {
type: 'food'
},
queryOptions: {
deep: true
},
onItem: function(item) {
console.log(store.getLabel(item));
}
});
});
This will log Sandwich, Ham, Cheese, and Banana.