Morris line chart y axis going beyond 100% - morris.js

I am using Morris line chart but my y axis is going beyond 100%.
Below is my json data:
[
{"y":"20/03","Threshold":"70","x TV":"0","x CA":"100","x Retail":"0","x Mobility":"100","x Media":"0"},
{"y":"21/03","Threshold":"70","x TV":"100","x CA":"87.69","x Retail":"100","x Mobility":"70","x Media":"86.67"},
{"y":"22/03","Threshold":"70","x TV":"0","x CA":"87.5","x Retail":"100","x Mobility":"93.42","x Media":"82.14"},
{"y":"23/03","Threshold":"70","x TV":"0","x CA":"0","x Retail":"0","x Mobility":"0","x Media":"0"},
{"y":"24/03","Threshold":"70","x TV":"0","x CA":"0","x Retail":"0","x Mobility":"0","x Media":"0"},
{"y":"25/03","Threshold":"70","x TV":"0","x CA":"0","x Retail":"0","x Mobility":"0","x Media":"0"},
{"y":"26/03","Threshold":"70","x TV":"0","x CA":"0","x Retail":"0","x Mobility":"0","x Media":"0"}
]
Please find below Morris line chart code:
Morris.Line({
element: 'morris-line-chart',
data: jsonData,
xkey: 'y',
xLabels: 'day',
ykeys: ['x TV', 'x CA', 'x Retail', 'x Mobility', 'x Media', 'Threshold'],
ymax: 100,
ymin:0,
labels: ['x TV', 'x CA', 'x Retail', 'x Mobility', 'x Media', 'Threshold'],
hideHover: 'auto',
resize: false,
parseTime: false,
lineColors: ['#C91530', '#871A35', '#E25D00', '#8EADB8', '#F2A200', '#D4D4D4'],
//yLabelFormat: function (y) { return y.toString(); },
postUnits: '%'
});
For date 21/03 and 22/03 x Retail has value as 100% my observation that path element not drawing the straight line.

The line goes beyond 100% because, by default, Morris.Line is set to draw curved lines (smooth: true). That's why, even if you don't have values greater than 100%, the line goes beyond 100%.
If you don't want to have curved lines, you can set the smooth property to false:
smooth: false
But there's no property in the latest Morris version (0.5.1) to not curve the line if the value reaches the ymax.
var jsonData = [
{ "y": "20/03", "Threshold": "70", "x TV": "0", "x CA": "100", "x Retail": "0", "x Mobility": "100", "x Media": "0" },
{ "y": "21/03", "Threshold": "70", "x TV": "100", "x CA": "87.69", "x Retail": "100", "x Mobility": "70", "x Media": "86.67" },
{ "y": "22/03", "Threshold": "70", "x TV": "0", "x CA": "87.5", "x Retail": "100", "x Mobility": "93.42", "x Media": "82.14" },
{ "y": "23/03", "Threshold": "70", "x TV": "0", "x CA": "0", "x Retail": "0", "x Mobility": "0", "x Media": "0" },
{ "y": "24/03", "Threshold": "70", "x TV": "0", "x CA": "0", "x Retail": "0", "x Mobility": "0", "x Media": "0" },
{ "y": "25/03", "Threshold": "70", "x TV": "0", "x CA": "0", "x Retail": "0", "x Mobility": "0", "x Media": "0" },
{ "y": "26/03", "Threshold": "70", "x TV": "0", "x CA": "0", "x Retail": "0", "x Mobility": "0", "x Media": "0" }]
Morris.Line({
element: 'morris-line-chart',
data: jsonData,
xkey: 'y',
xLabels: 'day',
ykeys: ['x TV', 'x CA', 'x Retail', 'x Mobility', 'x Media', 'Threshold'],
ymax: 100,
ymin:0,
labels: ['x TV', 'x CA', 'x Retail', 'x Mobility', 'x Media', 'Threshold'],
hideHover: 'auto',
resize: false,
parseTime: false,
smooth: false,
lineColors: ['#C91530', '#871A35', '#E25D00', '#8EADB8', '#F2A200', '#D4D4D4'],
//yLabelFormat: function (y) { return y.toString(); },
postUnits: '%'
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css" rel="stylesheet"/>
<div id="morris-line-chart"></div>

Related

Sql Json - Update Json Property within an Array using SQL Server 2017 Express

i Have this Json:
{
"pType": "1",
"pTitle": "A Product",
"pProds": [{
"formM": 1,
"sDesc": "A Product",
"lDesc": "A Product",
"pColor": "#000000",
"pSize": "L",
"postage": "2",
"quatity": 2,
"aPrice": "2",
"rPrice": "2",
"Discounted": "2",
"Price": "2",
"p_Num": "466ff237439a44be9d8fcc4725c28e4c",
"images": [{
"mN": 1,
"idImage": "image1",
"fileName": "39b06cc1aeb94e0c868d9b4e8174e2d5.jpeg",
"bytes": "/img/ProdImages/466ff237439a44be9d8fcc4725c28e4c/39b06cc1aeb94e0c868d9b4e8174e2d5.jpeg"
}]
}, {
"formM": 0,
"sDesc": "",
"lDesc": "",
"pColor": "",
"pSize": "0",
"postage": "0",
"quatity": 0,
"aPrice": "0",
"rPrice": "0",
"Discounted": "0",
"Price": "0",
"p_Num": "b8cf1caa638b48a2a3111b6d78c90b74",
"images": []
}]
}
What i would like to do is update the quatity (miss spelled) value by a given id which is p_Num.
So if i needed to update quatity from 2 to 55 by p_Num equalling '466ff237439a44be9d8fcc4725c28e4c'
How would i achieve this?

Vega-lite difference between Firefox and Chrome

I have a vega-lite chart that shows up as expected in Chrome (72.0.3626.96), but not in Firefox (70.0.1). I have checked the spec in the Vega Editor. Does anyone know why this might be?
Here are the rendered charts:
Firefox:
Chrome:
Here is the spec:
Any help you might be able to give would be much appreciated.
Apologies, but I do not know how to collapse this code.
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.2.1.json",
"background": "white",
"config": {"mark": {"tooltip": null}, "view": {"height": 300, "width": 400}},
"datasets": {
"data-511198e25d4dbee99248144390684caa": [
{
"counts": 338,
"filter_method": "greater than",
"grade": "9",
"index": 3,
"perc": 0.2669826224328594,
"school_code": "Board",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 414,
"filter_method": "greater than",
"grade": "9",
"index": 4,
"perc": 0.30689399555226093,
"school_code": "Board",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
}
],
"data-72a083843a98847e44077116c495e448": [
{
"counts": 49,
"filter_method": "greater than",
"grade": "9",
"index": 0,
"perc": 0.3356164383561644,
"school_code": "KING",
"threshold": "8",
"year": 20142015,
"year_lab": "2014/15",
"year_lab_q": "2014"
},
{
"counts": 62,
"filter_method": "greater than",
"grade": "9",
"index": 5,
"perc": 0.3668639053254438,
"school_code": "MLTS",
"threshold": "8",
"year": 20162017,
"year_lab": "2016/17",
"year_lab_q": "2016"
},
{
"counts": 53,
"filter_method": "greater than",
"grade": "9",
"index": 6,
"perc": 0.29608938547486036,
"school_code": "KING",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 44,
"filter_method": "greater than",
"grade": "9",
"index": 7,
"perc": 0.25882352941176473,
"school_code": "MLTS",
"threshold": "8",
"year": 20172018,
"year_lab": "2017/18",
"year_lab_q": "2017"
},
{
"counts": 53,
"filter_method": "greater than",
"grade": "9",
"index": 8,
"perc": 0.3212121212121212,
"school_code": "KING",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
},
{
"counts": 61,
"filter_method": "greater than",
"grade": "9",
"index": 9,
"perc": 0.25206611570247933,
"school_code": "MLTS",
"threshold": "8",
"year": 20182019,
"year_lab": "2018/19",
"year_lab_q": "2018"
}
]
},
"height": 400,
"layer": [
{
"data": {"name": "data-72a083843a98847e44077116c495e448"},
"encoding": {
"color": {
"field": "school_code",
"legend": {"labelFontSize": 15, "titleFontSize": 20},
"title": null,
"type": "nominal"
},
"tooltip": [
{
"field": "perc",
"format": ".2%",
"title": "percentage",
"type": "quantitative"
},
{
"field": "counts",
"title": "number",
"type": "quantitative"
},
{"field": "year_lab", "title": "school year", "type": "nominal"},
{"field": "school_code", "title": "level", "type": "nominal"},
{"field": "grade", "type": "nominal"},
{"field": "filter_method", "type": "nominal"},
{"field": "threshold", "type": "nominal"}
],
"x": {
"axis": {"format": "%Y", "tickCount": 5},
"field": "year_lab_q",
"scale": {"domain": ["2013.9", "2018.5"]},
"title": "School Year (beginning)",
"type": "temporal"
},
"y": {
"axis": {"format": ".0%"},
"field": "perc",
"title": "Percentage",
"type": "quantitative"
}
},
"mark": {"point": true, "type": "line"},
"selection": {
"selector001": {
"bind": "scales",
"encodings": ["x", "y"],
"type": "interval"
}
}
},
{
"data": {"name": "data-511198e25d4dbee99248144390684caa"},
"encoding": {
"color": {
"field": "school_code",
"legend": {"labelFontSize": 15, "titleFontSize": 20},
"scale": {"domain": ["Board"], "range": ["black"]},
"title": null,
"type": "nominal"
},
"tooltip": [
{
"field": "perc",
"format": ".2%",
"title": "percentage",
"type": "quantitative"
},
{
"field": "counts",
"title": "number",
"type": "quantitative"
},
{"field": "year_lab", "title": "school year", "type": "nominal"},
{"field": "school_code", "title": "level", "type": "nominal"},
{"field": "grade", "type": "nominal"},
{"field": "filter_method", "type": "nominal"},
{"field": "threshold", "type": "nominal"}
],
"x": {"field": "year_lab_q", "type": "temporal"},
"y": {"field": "perc", "type": "quantitative"}
},
"mark": {"point": true, "type": "line"}
}
],
"resolve": {"scale": {"color": "independent"}},
"title": "A title!",
"width": 700
}
It appears that your temporal values are not being parsed correctly in firefox (details of javascript date parsing behavior is often browser-dependent). You could try forcing the correct parsing by changing your data specification (in both places) to:
"data": {
"name": "data-72a083843a98847e44077116c495e448",
"format": {"parse": {"year_lab_q": "date:%Y"}}
}
This should ensure that the year string is parsed as a year, rather than e.g. a unix timestamp.
The other place date parsing is happening is in your domain specification. You might try changing those to a more standard time format, e.g.
"domain": ["2013-11-01", "2018-06-01"]

Add slider to line chart fusion chart

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);
};
});

Docusign List Population with Rest Endpoint (Modify Existing Recipient Tabs)

We are trying to populate an existing empty list on a DocuSign Template with some contact methods. The list needs to be populated on the fly since the number and default selected contact method varies with each recipient.
Here is our JSON request we PUT to https://demo.docusign.net/restapi/v2/accounts/:accountId/envelopes/:envelopeId/recipients/:recipientId/tabs (we have confirmed at the necessary variables in the URL have been filled in).
{
"accountId":"163051",
"checkboxTabs":[],
"companyTabs":[],
"dateTabs":[],
"emailTabs":[],
"envelopeId":"048f9ee2-df6e-482d-9e04-abb5e630bf83",
"fullNameTabs":[],
"initialHereTabs":[],
"listTabs":[{
"documentId":"1",
"locked":"False",
"name":"Preferred Contact Method",
"pageNumber":"1",
"tabId":"661499f2-4dda-419d-82ad-f943871407e9",
"tabLabel":"Preferred Contact Method",
"value":"Any",
"listItems":[{
"selected":"True",
"text":"Any",
"value":"1"},{
"selected":"False",
"text":"E-mail",
"value":"2"},{
"selected":"False",
"text":"Phone",
"value":"3"},{
"selected":"False",
"text":"Fax",
"value":"4"},{
"selected":"False",
"text":"Mail",
"value":"5"},{
"selected":"False",
"text":"Home Phone",
"value":"6"},{
"selected":"False",
"text":"Mobile Phone",
"value":"7"},{
"selected":"False",
"text":"Text",
"value":"8"},{
"selected":"False",
"text":"Facebook",
"value":"9"}]
}],
"noteTabs":[],
"radioGroupTabs":[],
"recipientId":"1",
"signHereTabs":[],
"textTabs":[],
"titleTabs":[],
"zipTabs":[]
}
And the response we are getting back:
The remote server returned an error: (500) Internal Server Error.
{
"errorCode": "INVALID_TAB_OPERATION",
"message": "The Tab specified is not valid for the requested operation. Attempt to create 'text' tab from invalid tab type.
}
There are no text tabs in our request. There is a tab with ID 661499f2-4dda-419d-82ad-f943871407e9 of type List on the template.
We were able to get this working a few months ago but fear a new version may have broken this functionality.
In case it is needed here is the "Get Recipient Tabs" response for the same envelope we are trying to modify. The list tab in question is at the bottom.
{
"signHereTabs": [
{
"name": "Sign Here",
"tabLabel": "Signature 12",
"scaleValue": 1,
"optional": "false",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "106",
"yPosition": "270",
"tabId": "00de6704-729d-4726-b102-829f914fda56"
}
],
"dateSignedTabs": [
{
"name": "Date Signed",
"value": "",
"tabLabel": "Date Signed",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "385",
"yPosition": "303",
"tabId": "6236a6cc-2d13-452e-af9b-6fe9706ff500"
}
],
"textTabs": [
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Last Name",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "36",
"yPosition": "146",
"tabId": "5aaee6db-a26a-4102-b77e-2eb4fb6e0c5b"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "First Name",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "224",
"yPosition": "147",
"tabId": "999d3f04-99b5-4fae-b69f-bd3e6b27e30d"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"maxLength": 1,
"tabLabel": "Middle Initial",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "368",
"yPosition": "145",
"tabId": "fdb77bb3-bbe0-4a0c-bf66-ac9fbaa4bb26"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Maiden Name",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "427",
"yPosition": "145",
"tabId": "ae99f579-0016-4839-b179-444fae166f71"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Address Street",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "36",
"yPosition": "175",
"tabId": "506abe87-b144-4d93-8576-b33a2abc4d85"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Apt",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "367",
"yPosition": "173",
"tabId": "7eaa32ef-b9b3-40e5-a5d3-5975134fb90d"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "DOB",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "429",
"yPosition": "175",
"tabId": "8f895bec-4f7a-4040-be77-f17374b30765"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Address City",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "36",
"yPosition": "202",
"tabId": "af6cbd27-072f-494d-8cb0-f60578b5e6c9"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Address State",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "212",
"yPosition": "202",
"tabId": "1ecc4a85-5252-4f4f-97d8-22238f46aae5"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Address Zip",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "368",
"yPosition": "202",
"tabId": "0dfb3731-7ce4-4c10-81f2-784428427ee7"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 17",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "446",
"yPosition": "256",
"tabId": "cb9a86c5-6ecf-4593-8c54-4b7e7d08ffb8"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 18",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "497",
"yPosition": "270",
"tabId": "0fc2dc21-7916-431f-aa38-a3b4df6c7bcf"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "",
"width": 42,
"required": "false",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 19",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "498",
"yPosition": "283",
"tabId": "e0f8676f-6f98-43ee-81db-63734bfe3155"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "I am willing to travel.",
"width": 162,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 49",
"documentId": "1",
"recipientId": "1",
"pageNumber": "5",
"xPosition": "55",
"yPosition": "15",
"tabId": "5c3ddd45-c36c-4214-8b80-d800e0fa5b61"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "I am NOT willing to travel.",
"width": 162,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 50",
"documentId": "1",
"recipientId": "1",
"pageNumber": "5",
"xPosition": "56",
"yPosition": "41",
"tabId": "47d7d2ff-2a4f-4de7-9f67-311cd0b172c8"
},
{
"height": 11,
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "Text",
"value": "Preferred Contact Method",
"width": 138,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "Data Field 52",
"documentId": "1",
"recipientId": "1",
"pageNumber": "1",
"xPosition": "81",
"yPosition": "21",
"tabId": "75b83aa1-c906-4827-9fc2-6cc4177843c6"
}
],
"ssnTabs": [
{
"validationPattern": "",
"validationMessage": "",
"shared": "false",
"requireInitialOnSharedChange": "false",
"name": "SSNTOOLTIP",
"value": "",
"width": 48,
"required": "true",
"locked": "false",
"concealValueOnDocument": "false",
"disableAutoSize": "false",
"tabLabel": "SSN",
"documentId": "1",
"recipientId": "1",
"pageNumber": "4",
"xPosition": "429",
"yPosition": "204",
"tabId": "11b62284-7613-48df-8498-fa019f3a42a3"
}
],
"radioGroupTabs": [
{
"documentId": "1",
"recipientId": "1",
"groupName": "Radio Button 13",
"radios": [
{
"pageNumber": "4",
"xPosition": "297",
"yPosition": "229",
"value": "Radio",
"selected": "false",
"tabId": "2b2312d2-3ed6-469e-8aeb-8de588ae16d3"
},
{
"pageNumber": "4",
"xPosition": "297",
"yPosition": "243",
"value": "Radio",
"selected": "false",
"tabId": "1a997301-f5d8-4e86-8ead-9d706490faf2"
},
{
"pageNumber": "4",
"xPosition": "297",
"yPosition": "256",
"value": "Radio",
"selected": "false",
"tabId": "705df9df-9e1d-478b-b991-9b31e919c85c"
},
{
"pageNumber": "4",
"xPosition": "297",
"yPosition": "271",
"value": "Radio",
"selected": "false",
"tabId": "d74742c2-742e-43d5-b1c5-04854ec8a7c5"
}
]
},
{
"groupName": "Radio Button Group Test",
"radios": [
{
"pageNumber": "5",
"xPosition": "28",
"yPosition": "15",
"value": "TravelYes",
"selected": "false",
"tabId": "30962105-0337-4d98-b4dd-058ae736d6fb"
},
{
"pageNumber": "5",
"xPosition": "27",
"yPosition": "40",
"value": "TravelNo",
"selected": "false",
"tabId": "351ba656-80dd-43ea-936a-fd322d63c0c0"
}
]
}
],
"listTabs": [
{
"listItems": [
{
"text": "",
"value": "",
"selected": "true"
},
{
"text": "",
"value": "",
"selected": "true"
}
],
"value": "",
"width": 77,
"shared": "false",
"requireInitialOnSharedChange": "false",
"tabLabel": "Preferred Contact Method",
"documentId": "1",
"recipientId": "1",
"pageNumber": "1",
"xPosition": "220",
"yPosition": "20",
"tabId": "661499f2-4dda-419d-82ad-f943871407e9"
}
]
}
This is a confirmed bug with DocuSign. I'm hoping this will get fixed in the next release but can't confirm yet. Once fixed I will update this answer to include the elements of a proper api call to modify an existing listTab, which I believe you're currently doing.

iOS: Programmatically add different tableviewcells

I would like to know what the best approach would be for creating and adding rows to a uitableview based on data from an API. The data returned from the API would look like the below. Some fields will need to be standard text, some would need to by password text fields, some number fields and some would be switches and date picker fields.
I'm guessing I need to add a field one of each cells to my UITableView in order to have the cell base. Then depending on the cell I am adding at the time I will retrieve that cell and add it to the table.
How would I keep track of the data? When the user submits the info how will I know which field is which?
The fields returned by the API will depend on which settings they have enabled within our site. And the order will vary depending on what sort_order they have set.
"data": [
{
"field_name": "location_id",
"display_name": "Home Location",
"page_cust": "O",
"sort_order": "10"
},
{
"field_name": "first_name",
"display_name": "First Name1",
"page_cust": "R",
"sort_order": "20"
},
{
"field_name": "middle_name",
"display_name": "Middle Name",
"page_cust": "O",
"sort_order": "25"
},
{
"field_name": "last_name",
"display_name": "Last Name1",
"page_cust": "R",
"sort_order": "30"
},
{
"field_name": "address1",
"display_name": "Address",
"page_cust": "O",
"sort_order": "40"
},
{
"field_name": "address2",
"display_name": "Address 2",
"page_cust": "O",
"sort_order": "45"
},
{
"field_name": "city",
"display_name": "City",
"page_cust": "O",
"sort_order": "50"
},
{
"field_name": "state",
"display_name": "State",
"page_cust": "O",
"sort_order": "60"
},
{
"field_name": "zip",
"display_name": "Zip Code",
"page_cust": "O",
"sort_order": "70"
},
{
"field_name": "day_phone",
"display_name": "Daytime Phone",
"page_cust": "O",
"sort_order": "80"
},
{
"field_name": "night_phone",
"display_name": "Evening Phone",
"page_cust": "O",
"sort_order": "90"
},
{
"field_name": "cell_phone",
"display_name": "Cell Phone",
"page_cust": "O",
"sort_order": "100"
},
{
"field_name": "email",
"display_name": "eMail",
"page_cust": "O",
"sort_order": "110"
},
{
"field_name": "login",
"display_name": "Login",
"page_cust": "O",
"sort_order": "120"
},
{
"field_name": "password",
"display_name": "Password",
"page_cust": "O",
"sort_order": "130"
},
{
"field_name": "lead_id",
"display_name": "Heard Via?",
"page_cust": "O",
"sort_order": "140"
},
{
"field_name": "contact_okay",
"display_name": "Contact Okay",
"page_cust": "O",
"sort_order": "170"
},
{
"field_name": "call_okay",
"display_name": "Call Okay",
"page_cust": "O",
"sort_order": "180"
},
{
"field_name": "email_okay",
"display_name": "E-mail Okay",
"page_cust": "O",
"sort_order": "190"
},
{
"field_name": "mail_okay",
"display_name": "Mail Okay",
"page_cust": "O",
"sort_order": "200"
},
{
"field_name": "payment_type_id",
"display_name": "Payment Method",
"page_cust": "O",
"sort_order": "210"
},
{
"field_name": "employer",
"display_name": "Company",
"page_cust": "O",
"sort_order": "260"
},
{
"field_name": "occupation",
"display_name": "Occupation",
"page_cust": "O",
"sort_order": "270"
},
{
"field_name": "birth_date",
"display_name": "Birth Date",
"page_cust": "O",
"sort_order": "280"
},
{
"field_name": "gender",
"display_name": "Gender",
"page_cust": "O",
"sort_order": "290"
},
{
"field_name": "status_id",
"display_name": "Status",
"page_cust": "O",
"sort_order": "340"
},
{
"field_name": "allow_login",
"display_name": "Allow to Log In",
"page_cust": "O",
"sort_order": "350"
},
{
"field_name": "customer_type_id",
"display_name": "Customer Type",
"page_cust": "O",
"sort_order": "360"
},
{
"field_name": "rep_id",
"display_name": "Assigned To",
"page_cust": "O",
"sort_order": "370"
},
{
"field_name": "account",
"display_name": "Account Number",
"page_cust": "O",
"sort_order": "380"
},
{
"field_name": "needs",
"display_name": "Special Needs",
"page_cust": "O",
"sort_order": "390"
}
]
You are consuming a web-service. Based on user setting you get back a JSON response in some particular order and composed by particular fields.
You already parsed the JSON, and you get a dictionary with one key ("data") for an array of dictionaries, right ?
The simplest approach is to store these dictionaries in a mutable array, NSMutableArray.
You know which cell is which object, because the datasource will be asked for the cell at a particular row number. Cell for row 0 will display fields of the first dictionary in the array, and so on.
NSDictionary *dictAtRow0 = [mySourceArray objectAtIndex:0];
If you wonder how to know if a particular field is present in the dictionary, test the presence of the corresponding key in the dictionary, something like this :
if([[dictAtRow0 allKeys] containsObject:#"field_name"]) {
// here you know the dictionary has an entry for the key "field_name"
}
It is also possible to reorder the array content based on the value for the "sort_order" key. Although the web-service seems to respect that order, you might want to do it programmatically. What I recommend is to do it before populating the source array :
// you parsed JSON and get the dictionary
NSArray *sortedArray = [[mainDict objectForKey:#"data"] sortedArrayUsingComparator: ^(id a, id b) {
NSNumber *first = [NSNumber numberWithInteger:[[a objectForKey:#"sort_order"] integerValue]];
NSNumber *second = [NSNumber numberWithInteger:[[b objectForKey:#"sort_order"] integerValue]];
return [first compare:second];
}];
mySourceArray = [[NSMutableArray alloc] initWithArray:sortedArray];
I didn't test that code, the comparator is maybe buggy but you got the idea.