jQWidgets Forums

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts

  • zert
    Participant

    Hi Dimitar,

    I tried to adapt your code on my page but no success, the color scheme isn’t applied on the chart. The colorarry is well formatted : #5ade7b,#db3939,#ffb33b,#5ade7b,#ffb33b,#5ade7b but all columns are on #5ade7b color.

    Here is my code, am I missing something? :

    var source3 =
    {
    	datatype: "json",
    	datafields: [
    			 { name: 'Mois'},
    			 { name: 'Nombre'}
    		],
    		url: 'source.php?filtre=2'
    		};
    var dataAdapter = new $.jqx.dataAdapter(source3, { async: false, autoBind: true, beforeLoadComplete: function (records) {
    		var colorsArray = new Array();
    		for (var i = 0; i < records.length; i++) {
    			switch (true) {
    				case (records[i].Nombre <= 80):
    					colorsArray.push("#db3939");
    					break;
    				case (records[i].Nombre > 80 && records[i].Nombre < 90):
    					colorsArray.push("#ffb33b");
    					break;
    				case (records[i].Nombre >= 90):
    					colorsArray.push("#5ade7b");
    					break;
    					};
    				};
    				$.jqx._jqxChart.prototype.colorSchemes.push({ name: 'myScheme', colors: colorsArray });
    				}, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); }
    			});
    var settings3 = {
                    title: "Sante du SI (%)",
                    description: "<?php echo $date;?>",
                    enableAnimations: true,
    				showLegend: false,
                    padding: { left: 10, top: 5, right: 20, bottom: 5 },
                    titlePadding: { left: 0, top: 0, right: 0, bottom: 10 },
                    source: dataAdapter,
    				showToolTips: false,
                    categoryAxis:
                        {
                            dataField: 'Mois',
                            flip: false,
    						textRotationAngle: 75,
                            horizontalTextAlignment: 'right',
                            verticalTextAlignment: 'top',
                            textRotationPoint: 'right',
                            textOffset: { x: -5, y: +5 }
                        },
                    colorScheme: 'myScheme',
                    seriesGroups:
                        [
                            {
                                type: 'column',
                                orientation: 'horizontal',
    							//mouseover: myEventHandler2Before,
    							//click: myEventHandler,
                                valueAxis:
                                {
                                    flip: true,
                                    displayValueAxis: false,
                                    description: '',
    								unitInterval: 1,
                                    minValue: 0
                                },
                                series: [
                                        { dataField: 'Nombre', showLabels: true }
                                    ]
                            }
                        ]
                };
Viewing 1 post (of 1 total)