Announcement

Collapse
No announcement yet.

Preserve drawTextRelative temporal ordering?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Preserve drawTextRelative temporal ordering?

    Advanced Charting temporal ordering of drawn objects.

    If a large opaque object is drawn over a smaller one, then the smaller one is completely obscured. To avoid this, the small one should be drawn after the larger is drawn, so the larger one can still potentially be seen "behind" the smaller one.

    I make a number of drawTextRelative calls to display items of varying sizes in close proximity on the graph. Before doing this, I sort the items from LARGEST to smallest size, so that larger items are drawn FIRST, and smaller items last.

    It seems that this drawn object temporal ordering is not being preserved by the chart. Is charting designed to maintain the order that I've drawn them? I draw them all on the previous bar (offset negative one), when a new bar is created.

    THANKS!

  • #2
    I wish I could get an answer to this question. TIA.

    Comment


    • #3
      Hello bfry,

      It seems that this drawn object temporal ordering is not being preserved by the chart. Is charting designed to maintain the order that I've drawn them?
      The order should be maintained based on the order they were drawn. The last one drawn would be on top unless you used the flag, Text.ONTOP, for some of the calls and not others. Please post a code example and some images that would better demonstrate the problem. Also describe what you are expecting to see.
      Jason K.
      Project Manager
      eSignal - an Interactive Data company

      EFS KnowledgeBase
      JavaScript for EFS Video Series
      EFS Beginner Tutorial Series
      EFS Glossary
      Custom EFS Development Policy

      New User Orientation

      Comment


      • #4
        Run the attached code on INTC 15S, in tick replay mode.
        Read the code for sample values to main for each parameter.

        First, set the variable debug3 to true, and have a formula output window. It will show the order of drawing of the drawTextRelative objects, and the chart does not preserve this ordering. Note that numerical text marks as drawTextRelative (in thousands) are written from largest to smallest volume (mark size) and then some other numbers/text items are drawn over them.

        In particular, the "0" mark is always written last, but when the vertical scale is compressed, it is not always shown as the topmost item visible. eSignal's charting apparently uses some optimization in redrawing, but it does not appear to preserve the order in which item are drawn such that the last item drawn for a given bar is always visible.

        I do not use Text.ONTOP for any of the drawTextRelative calls, and I believe I've tried it with and without that.

        Thanks for your help.
        Attached Files

        Comment


        • #5
          Hello bfry,

          I've confirmed the "temporal order" problem you've discovered. I will report this to our development team. I reproduced the problem using the code example below. You'll notice that drawLineRelative maintains the order properly, but not drawText, drawShape or drawImage. We do have the ".ONTOP" flag that will force the text or image to the foreground, but it only works if you use it on one call. For example, if you add the Text.ONTOP flag to the third drawTextRelative() line in our code example, then all of the 3's will be seen on top of the 2's and 1's. However, if you then add the flag to the second drawTextRelative() line, then the 2's and 3's will appear on top but will not have the proper order between them.


          PHP Code:
          function preMain() {
              
          setPriceStudy(true);
              
          setStudyTitle("test");
              
          setShowCursorLabel(false);
          }


          function 
          main() {
              if (
          getCurrentBarIndex() < -20) return;

              
          // order incorrect with drawText, drawShape, drawImage
              
          if (getBarState() == BARSTATE_NEWBAR) {
                  
          //text
                  
          drawTextRelative(085.00"1"Color.white Color.green nullnull15"1"+getValue("rawtime"));
                  
          drawTextRelative(084.80"2"Color.whiteColor.rednullnull15"2"+getValue("rawtime"));
                  
          drawTextRelative(084.60"3"Color.yellowColor.blacknullnull15"3"+getValue("rawtime"));
                  
          //shapes
                  
          drawShapeRelative(082.00Shape.CIRCLEnullColor.greennull"1"+getValue("rawtime"));
                  
          drawShapeRelative(081.80Shape.CIRCLEnullColor.rednull"2"+getValue("rawtime"));
                  
          drawShapeRelative(081.60Shape.CIRCLEnullColor.blacknull"3"+getValue("rawtime"));
                  
          //Image
                  
          drawImageRelative(079.00"SystemStopGreen"nullnull"1"+getValue("rawtime"));
                  
          drawImageRelative(078.80"SystemStopRed"nullnull"2"+getValue("rawtime"));
                  
          drawImageRelative(078.60"SystemStopBlack"nullnull"3"+getValue("rawtime"));
                  
          //line
                  
          drawLineRelative(-175.00075.00PS_SOLID8Color.green"1"+getValue("rawtime"));
                  
          drawLineRelative(-174.80074.80PS_SOLID8Color.red"2"+getValue("rawtime"));
                  
          drawLineRelative(-174.60074.60PS_SOLID8Color.black"3"+getValue("rawtime"));
              }
              
              return;

          Jason K.
          Project Manager
          eSignal - an Interactive Data company

          EFS KnowledgeBase
          JavaScript for EFS Video Series
          EFS Beginner Tutorial Series
          EFS Glossary
          Custom EFS Development Policy

          New User Orientation

          Comment


          • #6
            Thanks for your fabulous support! What a great product.

            Comment

            Working...
            X