Image Labels in between ticks on vertical axis

Hello,

I have a requirement to replace the string labels on the vertical axis with an image and to have this image positioned in the middle between ticks.  How would I achieve this? Please see attached image. (Please ignore incorrect image spacing, the numbered images are supposed to be in the middle of ticks)

CategoryAxis is not available for the vertical axis and the LabelContent property is set to string in ChartAxisLabelEventArgs.  

Thanks!


Attachment: Screen_Shot_20171011_at_4.09.33_PM_f8d2aad6.zip

3 Replies

PS Parthiban Sundaram Syncfusion Team October 16, 2017 12:47 PM UTC

Hi Tiff Napolitano,  
  
Thanks for the using Syncfusion products.  
  
You can achieve this requirement with the help of LabelCreated event in secondary axis and positioning the image using AbsoluteLayout. Please refer the following code snippet for details.  
  
Code Snippet:  
  
  
    private void SecondaryAxis_LabelCreated(object sender, ChartAxisLabelEventArgs e)  
        {  
            ChartAxis axis = (sender as ChartAxis);  
  
            if (axis is NumericalAxis)  
            {  
                double y = myChart.ValueToPoint(axis, e.Position);  
                double x = 5;  
                image = new Image();             
                int pos = (int)e.Position % 4;   
 
               image.Source = ImageSource.FromFile("icon.png"); // position the required image  
 
                secondaryAbsLayout.Children.Add(image, new Rectangle(x, y - 20, 30, 30));  
            }  
        }  
  
  
Please download the sample from following location.  
  
  
Please let us know, if you need further assistance on this.  
  
Regards,  
Parthiban S   
 
 
 
 



TN Tiff Napolitano October 16, 2017 03:39 PM UTC

Thank you, I will give it a shot.



PS Parthiban Sundaram Syncfusion Team October 17, 2017 11:18 AM UTC

Hi Tiff Napolitano,

Thanks for your response and we will wait to hear from you.

Regards,
Parthiban S

Loader.
Up arrow icon