jQWidgets Forums
jQuery UI Widgets › Forums › Chart › ColorFunction and RangeColumn
This topic contains 1 reply, has 1 voice, and was last updated by milesd 9 years, 3 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
Author
-
I found this example of the color function.
http://www.jqwidgets.com/community/topic/conditional-bar-color-with-colorfunction/However I’m using it with a rangecolumn and the data adapter
var initChart=function(g_index) { // prepare the data var source = { datatype: "json", datafields: [ { name: 'labelName'}, { name: 'start_time'}, { name: 'end_time'}, { name: 'result'}, { name: 'percent'}, { name: 'bs'}, { name: 'count'}, ], url: 'mcbind.php' }; var dataAdapter = new $.jqx.dataAdapter(source, { autoBind: true, async: false, downloadComplete: function () { }, loadComplete: function () { }, loadError: function () { } }); // prepare jqxChart settings var settings = { title: mkt+' '+ accuracy + ' '+lookback+' '+dis+' '+minutes+' '+tz+' '+show+' '+rank, description: "", enableAnimations: true, showLegend: false, padding: { left: 5, top: 5, right: 10, bottom: 5 }, titlePadding: { left: 90, top: 0, right: 0, bottom: 10 }, source: dataAdapter, xAxis: { dataField: 'labelName', unitInterval: 1, tickMarks: { visible: true, interval: 1, color: '#BCBCBC' } }, colorScheme: 'scheme02', seriesGroups: [ { orientation: 'horizontal', type: 'rangecolumn', columnsGapPercent: 100, valueAxis: { baseUnit: 'minute', unitInterval: 5, flip: true, valuesOnTicks: true, title: { text: 'Day' }, tickMarks: { color: '#BCBCBC' } }, series: [ { dataField: 'bs', dataFieldFrom: 'start_time', dataFieldTo: 'end_time', displayText: 'hello', opacity: 1, toolTipFormatFunction: function (value,itemIndex, serie, group, categoryValue, categoryAxis){ return '<DIV>'+JSON.stringify(value)+' value='+value['']+'</DIV>' }, colorFunction: function(value,itemIndex,serie,group){ return (source[itemIndex]['bs'] < 0) ? '#CC1133' : '#55CC55'; //return '#55CC55'; } } ] } ] }; // setup the chart $('#chart' + g_index).jqxChart(settings); }
I keep getting undefined is not an object. How do I access the other fields from the data adapter that are not the from and to fields of the range column?
Resolved.
apparently
if (isNaN(itemIndex)) return '#55CC55';
this is very important.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.