Highcharts dataLabels in OutSystems

  

Hi all!

I'm doing a Line Chart using the HighCharts component in OS 10, and I need to add dataLabels to a specific dataPoint. 

To do it, I'm iterating over a list and calling the DataPoint_Init to get the data point record. Then I'm doing some validations and according with that I'll show a dataLabel with a specific style. To do it, I'm creating an AdvancedDataPointFormat record, setting the AdvancedDataPointFormat.DataPoint and then the AdvancedDataPointFormat.DataPointJSON with the following value:

"dataLabels: {
    enabled: true,
    verticalAlign: 'middle',
    align: 'right',
    backgroundColor: '#D21242',
    borderRadius: '2',
    padding: 10,
    style: {
        color: '#fff',
        textShadow: 0
    }
}"

After this, I'm adding it to the AdvanceFormat.DataPointFormats structure and this structure is being passed in the chart block.

This is a mobile application, and for that reason, this logic is being called after fetch the data in the aggregate. The line chart is generated and I can see it, but for some reason the dataLabels don't show up. What am I missing?


Thank you all in advance,

Filipa Rebelo

Solution

Hello Filipa,

Instead of doing the configuration on the DataPointJSON, try setting the parameter AdvancedFormat on the line chart block with the following value:

AdvancedFormat_Init(DataPointFormats:,DataSeriesFormats:, XAxisJSON:,YAxisJSON:,HighchartsJSON:
"
plotOptions: {
   series: {
      dataLabels: {
         enabled: true,
         verticalAlign: 'middle',
         align: 'right',
         backgroundColor: '#D21242',
         borderRadius: '2',
         padding: 10,
         style: {
            color: '#fff',
            textShadow: 0
         }
      }}
   }")

Does that work?

This will give you the same label for all points. From what I understand you need different labels for different points, so you'll need a formatter. If you can explain the rules for the different labels, I can try to give you an example.

Cheers,
R

Solution