Skip to content

DevExpress-Examples/web-forms-dashboard-custom-format-for-axis-labels-in-charts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dashboard for Web Forms - How to use a custom format for axis labels in the Chart Item


Update: Starting with version 18.2, we introduced the capability to format any Numeric or Date-Time Value. So, you can set formats demonstrated in this example via the Design mode's UI using the X and Y axis formatting settings without writing additional code.
However, you can still use approaches demonstrated in this example if you wish to implement your custom formatting not supported by the control.


This example illustrates how to format axis labels in a custom manner. For this, access the underlying dxChart widget in the ItemWidgetCreated and ItemWidgetUpdated event handlers and customize axis labels in the dxChart.argumentAxis.label.customizeText or dxChart.valueAxis.label.customizeText callback function.
Note that printed or exported documents containing a dashboard/dashboard item do not reflect appearance settings applied using the events for accessing of underlying widgets.

The following two most frequently asked scenarios are represented in this example:

1. Add the currency sign.

        function onItemWidgetCreated(s, e) {
            if (e.ItemName == "chartDashboardItem1") {
                var widget = e.GetWidget();
                var customizeText = widget.option('valueAxis[0].label.customizeText');
                widget.option('valueAxis[0].label.customizeText', function (args) {
                    var defaultText = $.proxy(customizeText, args)(args);
                    return '$' + defaultText;
                });
            }
            ...            
        }

2. Use the ones unit format.

        function onItemWidgetCreated(s, e) {
            ...
            if (e.ItemName == "chartDashboardItem2") {
                var widget = e.GetWidget();
                widget.option('valueAxis[0].label.customizeText', function (args) {
                    return args.value.toLocaleString();
                });
            }
        }
 

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Contributors 7