Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can I place an image over a chart at a specific position?

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

    Can I place an image over a chart at a specific position?

    Is there a way to place an image (say a jpeg) over a chart at a specific bar and price?

    #2
    Hello AnotherTrader , thanks for your question.

    This is possible with the use of SharpDX in the OnRender method. You can place any bitmap image onto a chart.

    We have an example that I have attached to this post. This example draws a SharpDX Bitmap onto the RenderTarget. First, the images are loaded into Bitmap objects in the UpdateImage method, then the image is drawn to the RenderTarget with the SharpDX “DrawBitmap” method. Note that RenderTarget dependent resources must be disposed and recreated when the RenderTarget changes, or with each OnRender pass. Use OnRenderTargetChange as demonstrated for better performance.
    The Bitmap should be updated in OnRender, and any signals to change the Bitmap should be signaled in OnBarUpdate, and then changed in the next OnRender pass.

    Please let me know if you have any questions on this material.
    Attached Files

    Comment


      #3
      How could I set it up so that additional text appears if the user runs their mouse over the image?

      Comment


        #4
        Hi AnotherTrader, thanks for your reply.

        I am not sure if these support tool tips, that would be a C# concept that would need to be researched more on your own.

        Best regards,
        -ChrisL

        Comment


          #5
          you can try this code to place an image over a chart at a specific position
          Step 1
          HTML Code:
            	var chart = new CanvasJS.Chart("chartContainer",{ 	title :{ 	text: "Position Image over chart" 	}, 	data: [{ 	type: "column", 	dataPoints : [ 	{ label: "apple", y: 10 }, 	{ label: "orange", y: 15 }, 	{ label: "banana", y: 25 }, 	{ label: "mango", y: 30 }, 	{ label: "grape", y: 28 } 	] 	}] 	}); 	chart.render();
          Step2:

          HTML Code:
            	$('img').attr('src', url) 	.attr("class", label) 	.css({"display": "none"}) 	.appendTo($('#chartContainer>.canvasjs-chart-container'));

          Step3:

          HTML Code:
            	imageBottom = chart.axisX[0].bounds.y1; 	imageCenter = chart.axisX[0].convertValueToPixel(chart.data[0].dataPoints[0].x); 	  	image.css({"position": "absolute", 	"display": "block", 	"top": imageBottom - fruit.height(), 	"left": imageCenter - fruit.width()/2 	});

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X