Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
975
how do I format numbers to 2 decimal places in a chart ?
posted

series.Column("ClosePrice")
                                        .XAxis("EnergyProductAxis")
                                        .YAxis("PriceAxis")
                                        .IsHighlightingEnabled(true)
                                        .IsTransitionInEnabled(true)
                                        .ValueMemberPath(v => v.CurrentMidPrice).to
                                        .ShowTooltip(true)
                                        .Brush("#F50512")
                                        .TransitionInMode(CategoryTransitionInMode.FromZero)
                                        .TransitionDuration(1000)
                                        .TransitionInDuration(1000)
                                        .TransitionInSpeedType(TransitionInSpeedType.Normal)
                                        .Title("Close Price (£/MWh)").Legend(legend => legend.ID("legend1"));

this sometimes displays no decimal places and sometime 2, I need it to consistently show 2 decimal places

so

54.00

65.35

etc

Parents
No Data
Reply
  • 16310
    Offline posted

    Hi Mark,

    If you want to format numbers that are displayed as labels, then you need to use the formatLabel method:

    axes.FormatLabel("function(item) { return formatCurrency(item); }");

    function formatCurrency(item) {

    // code to format the value
    return formattedVal;
    }

    If you would rather want to format the series values that are being displayed in a tooltip, you can format those in the tooltipShowing or tooltipShown event.

    Please let me know if you have further questions on the matter, I will be glad to help

Children