How to display data labels for only certain values of a candle series

I want to add data labels only for certain values in a candle series, i.e. only for some high or low values (see image below), however I can only find APIs to hide or show data labels for entire points, which makes them show up for every value in the candle (high, low, open, close), even using the builder doesn't work since it is only called once per point, not for each value in the candle.


6 Replies 1 reply marked as answer

DP Dharanitharan Palanisamy Syncfusion Team February 23, 2021 02:43 PM UTC

Hi Eduarado, 
 
Greetings from Syncfusion. We have analyzed your scenario and your requirement can be achieved using the annotation feature in the chart, using this you can place the custom widget in the required place in the chart. To know more refer to the help document.  

Here, we access the high and low values from data source, and  used with that values in the annotation. We attached the sample and screenshot with this and kindly make use of it and this can be changes based on your scenario. 
 
SfCartesianChart( 
// Annotations 
  annotations: <CartesianChartAnnotation>[ 
    CartesianChartAnnotation( 
      widget:Padding( 
        padding: EdgeInsets.only(bottom: 20), 
         // Providing the 7th data value in the data source 
          child:Container( 
          child: Text(chartData[7].high.toString()) 
          ) 
        ), 
      coordinateUnit: CoordinateUnit.point, 
      region: AnnotationRegion.plotArea, 
      x: chartData[7].x, 
      y: chartData[7].high 
    ), 
    CartesianChartAnnotation( 
      widget: Padding( 
      padding: EdgeInsets.only(top: 20), 
       // Providing the 2nd data value in the data source 
        child:Container( 
          child: Text(chartData[2].low.toString()) 
          ) 
        ), 
      coordinateUnit: CoordinateUnit.point, 
      region: AnnotationRegion.plotArea, 
      x: chartData[2].x, 
      y: chartData[2].low 
    ) 
  ], 
) 
  
 
Screenshot:  
 
  
Thanks, 
Dharanitharan. P 



EU Eduardo Urias February 23, 2021 05:19 PM UTC

I had already tried annotations and there are a couple of things that didn't work well with them, maybe you can help me figure out the issue.

1. Annotations can be rendered outside the plot area, I want them to be constrained to just the plot area.
2. When I zoom/pan around the chart the annotations disappear, I want them to remain there.







DP Dharanitharan Palanisamy Syncfusion Team February 24, 2021 02:45 PM UTC

Hi Eduardo, 
  
We have analyzed your scenarios and find the response for queries below. 
  
Query #1: Annotations can be rendered outside the plot area, I want them to be constrained to just the plot area 
We suspect that you have tried with regions property as region: AnnotateRegion.chart in the annotation. If you position the annotation using this, it will position even if it goes out of plot area. If you wish to hide the annotation goes out of plot area, then we suggest to use AnnotationRegion.plotArea. Please find the reference screenshot below, 
  
Screenshot 
 
  
Query #2: When I zoom/pan around the chart the annotations disappear, I want them to remain there. 
We have checked this scenario and in both zoomed state and normal state annotation, while zooming with annotation, it is not get disappeared and it is positioned properly after zooming also. Here, we attached the screenshots for your reference. 
  
Screenshots 
Normal state 
Zoomed state 
 
 
  
If you still face any concerns, kindly make sure you are using the updated version of our chat package and revert us your sample with replication steps. This will be helpful in providing the solution sooner. 

Regards, 
Dharanitharan. P 
 



EU Eduardo Urias February 25, 2021 01:35 AM UTC

For #1 I have tried both, and both render outside the plot area, please note that my axis labels are on the opposite side, maybe that has something to do with it?

For #2, the annotations disappear while I'm zooming or panning, after I finish zooming/panning they come back and are correctly positioned.


DP Dharanitharan Palanisamy Syncfusion Team February 25, 2021 10:25 AM UTC

Hi Eduardo, 
  
The reported scenario for annotations is rendered outside the plot area when axis is in opposed position, and the annotations issues are replicated at our end. We have consider your reported cases as bugs and include the fix for those in our upcoming Vol 1 main release which is expected to be rolled out on the middle of the March 2021. We appreciate your patience until then. 
  
Regards, 
Dharanitharan. P 



DP Dharanitharan Palanisamy Syncfusion Team April 1, 2021 07:03 AM UTC

Hi Eduardo,  
   
Thanks for your patience. We are glad to inform you that the reported annotation issue got resolved and rolled out in our volume1 main release. Now the annotation properly placed inside the plot area also does not disappear while zooming and panning. To resolve this, you can upgrade the package to the latest version from the below link  
  
   
Please revert us if you still have further concerns.  
  
Thanks,  
Dharanitharan. P  



Marked as answer
Loader.
Up arrow icon