disable sorting in lineChart series in Primefaces?

1.1k views Asked by At

using Primefaces 5.0.4: consider the below plots:

series4.set(6.63,3000);
series4.set(6.72,2997.61);
series4.set(6.446636814,2877.63);
series4.set(6.334959739,2817.19);
series4.set(6.22,2757.15);
series4.set(6.10,2696.57);
series4.set(5.733552319,2515.440226);
series4.set(5.606696386,2455.409765);
series4.set(5.479072175,2395.397663);
series4.set(5.352603164,2335.233212);
series4.set(4.193900165,1789.978504);
series4.set(4.060604311,1729.807258);
series4.set(3.929124422,1669.649482);
series4.set(3.788668332,1609.300613);
series4.set(2.164222404,1007.059336);
series4.set(1.953838367,946.8072057);
series4.set("0.133522135",-143.4140801);
series4.set(0.066135582,-203.4635544);
series4.set(0.002918748,-263.8554871);
series4.set(-0.066141148,-324.5883882);
series4.set(-0.132174572,-385.96192);
series4.set(-0.921089703,-1172.898889);
series4.set(-0.981256764,-1233.287334);
series4.set(-1.043102173,-1293.57028);
series4.set(-1.106574926,-1353.732824);
series4.set(-1.171650937,-1414.056659);
series4.set(-1.870683363,-1958.84943);
series4.set(-1.994795447,-2019.349098);
series4.set(-2.120681016,-2079.613447);
series4.set(-2.263016586,-2140.611887);
series4.set(-3.903208537,-2926.144838);
series4.set(-3.988282377,-2986.30619);
series4.set(-4.007646719,-3000);
series4.set(-3.980604355,-2926.11742);
series4.set(-3.949245994,-2865.626335);
series4.set(-2.115051141,-1354.208708);
series4.set(-2.002115358,-1294.068933);
series4.set(-1.889545833,-1233.82616);
series4.set(-1.783095962,-1173.504591);
series4.set(-0.09267729,339.9711549);
series4.set(-0.022683854,400.0822902);
series4.set(0.051001135,460.082531);
series4.set(0.130141486,520.4650164);
series4.set(1.946266677,1423.95246);
series4.set(2.127407915,1483.979464);
series4.set(2.30500294,1544.046998);

lineModel1.setStacked(true);
lineModel1.addSeries(series4); 

Axis xAxis=new CategoryAxis("Xdata");

lineModel1.getAxes().put(AxisType.X, xAxis);
Axis yAxis = lineModel1.getAxis(AxisType.Y);
yAxis.setLabel("YData");

Now I want the program to connect the dots in order which I gave, which is the order I added them to my series. But I do get them connected in sorted order. I think it is sorted by x-value. Is there a way to disable this auto sort. Please suggest.

In bean i set the extender to

lineModel1.setExtender("extend");

in xhtml:

<p:lineChart id="linear" value="#{catalogChartBean.lineModel1}" title="Linear Chart" />

in js:

function extend(){
   this.cfg=$.jqplot(this.cfg.id, this.cfg.data, {sortData:false});
   this.cfg.redraw(); 
      }

i don't think so this function is invoked even, because i wrote a simple window.alert and the extender dint invoke it.

1

There are 1 answers

3
Harish Aravind On BEST ANSWER

I figured it out and made it work. I used <p:lineChart /> and it is not able to invoke the extender. Not sure WHY ? But i changed it to <p:chart/> and it worked.

Also to disable sorting i used this below js via extender.

<script language="javascript" type="text/javascript">
    function extnder() {
        this.cfg.sortData = false;
    }
</script>