Graph Data Label Format

xyba

Registered User.
Local time
Today, 14:43
Joined
Jan 28, 2016
Messages
189
Maybe I'm looking too hard but I can't find a way of changing the format of the data labels in a graph. They default to black but I have a dark background so want to change that.

Does anyone know how to change this value, please?
 
on design view of your form, double click the graph.
double click the labels to see its property.
 
Are you using the 'modern' charts available with Access 365/2019 or the traditional charts available in both earlier versions and current version?
 
Are you using the 'modern' charts available with Access 365/2019 or the traditional charts available in both earlier versions and current version?

I'm not too sure. How would I check?
 
If you are running anything up to and including A2016 retail, it will be a traditional chart.
A2019 retail or 365 has both and it depends which button was used to create the chart:

attachment.php


If its a traditional chart, Arnel's explanation is what you need:

attachment.php


However that doesn't work for modern charts which are easier to create but you have less control over the appearance. Go to the Format tab in the Chart Settings and see if you can find anything there

attachment.php


I don't use them as I find them less useful for my needs so am not an expert on these . However in A365 you can search the Help menu for this item 'Create a chart on a form or report'. Hopefully that will give you the answer you need. If so, please post back for the benefit of others
 

Attachments

  • TwoChartTypes.PNG
    TwoChartTypes.PNG
    20.2 KB · Views: 1,965
  • TraditionalChartDesign.PNG
    TraditionalChartDesign.PNG
    32.7 KB · Views: 2,332
  • ModernChartSettings.PNG
    ModernChartSettings.PNG
    1.7 KB · Views: 1,916
I have 2019 (cracked not retail) but I don't have that.
what is the Class name?

mine is MSGraph.Chart.8
 
Are we talking manual adjustment of color or using VBA?
 
after much googling, finally found it (I hope):
on the Load event of your form, change the color of the data labels.
on VBA you may wish to select a ColorIndex or Color, press F2 and search ColorIndex.
change vbRed to whatever color you want.
change the graph name to your graph name.
the commented line also works if you want ColorIndex.
Code:
Private Sub Form_Load()
Dim s As Variant
For Each s In Me.Graph0.Object.Application.Chart.SeriesCollection
   With s
     '.DataLabels.Font.ColorIndex = 15
     .DataLabels.Font.Color = vbRed
   End With
Next

End Sub
 
Hi
I haven't tested the code Arnel posted as I only saw his reply after checking out the modern chart property sheet in A365

Unlike the old or traditional' charts, you cannot click on items in a modern chart.
Instead you edit it using the Chart Settings tab and/or the Chart Property sheet

This includes several colour properties you can alter:

attachment.php


I couldn't find any method for changing the colour of the chart values.
Although you can change the label fontname & size, I couldn't see how to change the font style (bold/italic etc)

Hope that helps
 

Attachments

  • FormattingModernChart.PNG
    FormattingModernChart.PNG
    57.4 KB · Views: 1,831
Last edited:
Happy New Year all!:)

Can anyone confirm if arnelgp's code worked? I have a similar requirement using the modern chart option, but that code does not work for me. I get Object doesnt support this property or method.
 
Can anyone confirm if arnelgp's code worked? I have a similar requirement using the modern chart option, ...
arnelgp's code is for classic charts (MsGraph.Chart ActiveX) only.

If you are using Modern Charts, rather look at what Isladogs posted.
 
It didn't work for me either (same error).
I tried using intellisense to do variations on that but never found a solution.
If you haven't already done so, have a read ofr the modern charts help article: https://support.office.com/en-gb/article/create-a-chart-on-a-form-or-report-1a463106-65d0-4dbb-9d66-4ecb737ea7f7
If its not covered there, you probably can't do it - ridiculous though that may seem.

However you could go back to using a traditional chart where it is definitely possible to change both colour and position of data labels

EDIT
Forgot to say that I spent some time playing with modern charts in the post https://www.access-programmers.co.uk/forums/showpost.php?p=1656830&postcount=4
It includes some code and an example app but I failed to change the data label colour using code or the interface
 
Last edited:

Users who are viewing this thread

Back
Top Bottom