Flipping a chart upside-down

Some of you have asked for instructions on how to flip the chart rendering upside-down.

Here is the general code you can use.

Please note that you may need to add additional logic for handling your menus, and drawings will not be inverted; so turn them off while flipped!

This is only an outline provided as guidance and not intended to be inserted as-is into your library.


// call something like this form your 'Flip Chart' menu button
function flip(){
 if(stxx.layout.flipped){
  stxx.layout.flipped=false;
 }else{
  stxx.layout.flipped=true;
 }
 stxx.createDataSet();
 stxx.draw();
 stxx.changeOccurred("layout");
 configureMenu();  // use this to turn on or off your drawing menu or anything else you want to change when flipped....
}


// don't want to display drawings  when flipped....
function prependDrawVectors(){
 if(stxx.layout.flipped){
  stxx.chart.hideDrawings=true;
 } else {
  stxx.chart.hideDrawings=false;
 }
}
CIQ.ChartEngine.prototype.prepend("drawVectors", prependDrawVectors);

// this does the flipping of the dataset so it renders up-side down.
// it is a post transformation function called from CIQ.ChartEngine.prototype.createDataSet
stxx.transformDataSetPost=function(self, dataSet, min, max){
 if(self.layout.flipped){
  var tmp
  for(var i=0;i<dataSet.length;i++){
   p=dataSet[i];
   p.Close=min+(max-p.Close);
   p.Open=min+(max-p.Open);
   tmp=min+(max-p.Low);
   p.Low=min+(max-p.High);
   p.High=tmp;
  }
 }
}

Good Luck!