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();
});
}
}
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
- Global.asax (VB: Global.asax)
- Global.asax.cs (VB: Global.asax.vb)
(you will be redirected to DevExpress.com to submit your response)