Displaying text on a chart with opaque background - page 2

 


Text Overridden



My Text is overridden with Price Graph. Please help how I can box it so the text z-Order is above the chart.

My code as below:

         string lineText = "";
         int yDistance = 20;
     
         yDistance = yDistance + 30;
         lineText = PadLeft(" Account Info", 36);
         ObjectCreate("AccountInfo", OBJ_LABEL, 0, 0, 0);
         ObjectSetText("AccountInfo", lineText, FontSize, FontType, FontColor);
         ObjectSet("AccountInfo", OBJPROP_XDISTANCE, 5);
         ObjectSet("AccountInfo", OBJPROP_YDISTANCE, yDistance);
         ObjectCreate("AccountInfo", OBJ_LABEL, 0, 0, 0);
        

         yDistance = yDistance + 20;
         lineText = Replicate("-", 36);
         ObjectCreate("AccountInfoSepStart", OBJ_LABEL, 0, 0, 0);
         ObjectSetText("AccountInfoSepStart", lineText, FontSize, FontType, FontColor);
         ObjectSet("AccountInfoSepStart", OBJPROP_XDISTANCE, 5);
         ObjectSet("AccountInfoSepStart", OBJPROP_YDISTANCE, yDistance);
         ObjectCreate("AccountInfoSepStart", OBJ_LABEL, 0, 0, 0);
        
         yDistance = yDistance + 30;
         lineText = PadLeft(" Balance: ", 15) + PadRight(DoubleToStr(AccountBalance(), 2), 21);
         ObjectCreate("Balance", OBJ_LABEL, 0, 0, 0);
         ObjectSetText("Balance", lineText, FontSize, FontType, FontColor);
         ObjectSet("Balance", OBJPROP_XDISTANCE, 5);
         ObjectSet("Balance", OBJPROP_YDISTANCE, yDistance);
         ObjectCreate("Balance", OBJ_LABEL, 0, 0, 0);
 
May you please share your PadLeft and PadRight function
 
dilipray: My Text is overridden with Price Graph. Please help how I can box it so the text z-Order is above the chart.

Create a black rectangle first to hide the chart, then create the text.

Always specify

 
twostarii: May you please share your PadLeft and PadRight function

When in doubt, think!

Not compiled, not tested, just typed.

string PadRight(string text, int len){
   int    size = StringLen(text);
   string spaces; StringInit(spaces, len-size, ' ');
   return text+spaces;
}
string PadLeft(string text, int len){
   int    size = StringLen(text);
   string spaces; StringInit(spaces, len-size, ' ');
   return spaces+text;
}
string PadCenter(string text, int len){
   return PadRight( PadLeft(text, len/2), len);
}

Not compiled, not tested, just typed.

Was that so hard you couldn't do it?

Reason: