Giter VIP home page Giter VIP logo

how-to-format-timespanaxis-label-based-on-axis-interval-in-wpf-sfchart's Introduction

How-to-format-TimeSpanAxis-label-based-on-axis-interval-in-WPF-SfChart

This sample demonstrate how to format TimeSpanAxis label based on axis interval in WPF (SfChart) WPF SfChart provides support for formatting axis labels based on axis intervals in TimeSpanAxis. The LabelFormat Property can be used to apply predefined formatting types based on usages. This article explains how to format TimeSpanAxis label based on axis interval in WPF (SfChart)

##[Xaml]

<chart:SfChart>
            <chart:SfChart.DataContext>
                <local:ViewModel/>
            </chart:SfChart.DataContext>
            <chart:SfChart.PrimaryAxis>

                <chart:TimeSpanAxis Minimum="00:00:00" 
                                    EdgeLabelsDrawingMode="Shift" 
                                    Maximum="00:00:10" 
                                    LabelFormat="mm\:ss\:fff">
                    <chart:TimeSpanAxis.Header>
                        <Label FontWeight="Bold"  
                               Content="Time in (mm:ss:fff)"/>
                    </chart:TimeSpanAxis.Header>
                </chart:TimeSpanAxis>
            </chart:SfChart.PrimaryAxis>

            <chart:SfChart.SecondaryAxis  >
                <chart:NumericalAxis Minimum="50" Maximum="700" >
                    <chart:NumericalAxis.Header>
                        <Label Content="Distance in (meters)" 
                               FontWeight="Bold" />
                    </chart:NumericalAxis.Header>
                </chart:NumericalAxis>
            </chart:SfChart.SecondaryAxis>
            
            <chart:SfChart.Series>
                <chart:SplineSeries XBindingPath="Time" 
                                    Interior="Purple" 
                                    YBindingPath="Distance" 
                                    ItemsSource="{Binding Data}" >
                    <chart:SplineSeries.AdornmentsInfo>
                        <chart:ChartAdornmentInfo ShowLabel="True" />
                    </chart:SplineSeries.AdornmentsInfo>
                </chart:SplineSeries>
            </chart:SfChart.Series>
        </chart:SfChart>

##[C#]

  SfChart chart = new SfChart();
            this.DataContext = new ViewModel();

            TimeSpanAxis primaryAxis = new TimeSpanAxis()
            {
                Minimum = new TimeSpan(00, 00, 00),
                Maximum = new TimeSpan(00, 00, 10),
                LabelFormat = "mm\\:ss\\:fff",
                Header = new Label()
                {
                    Content = "Time in (mm:ss:fff)",
                    FontWeight = FontWeights.Bold,
                },
                EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift,

            };
            chart.PrimaryAxis = primaryAxis;

            NumericalAxis secondaryAxis = new NumericalAxis()
            {
                Minimum = 50,
                Maximum = 700,
                Header = new Label()
                {
                    Content = "Distance in (meters)",
                    FontWeight = FontWeights.Bold,
                },

            };
            chart.SecondaryAxis = secondaryAxis;

            SplineSeries series = new SplineSeries()
            {
                XBindingPath = "Time",
                YBindingPath = "Distance",
                ItemsSource = (new ViewModel()).Data,
                AdornmentsInfo = new ChartAdornmentInfo()
                {
                    ShowLabel = true,
                },
                Interior = new SolidColorBrush(Colors.Purple),
                
            };
            chart.Series.Add(series);
            this.Content = chart;

##Output

Output

##See Also

Axis labels for TimeSpanAxis in WPF (SfChart)

How to display the axis labels in a particular format

How to customize label formats of data-time axis during the interval transitions

how-to-format-timespanaxis-label-based-on-axis-interval-in-wpf-sfchart's People

Contributors

edberg-vasan avatar muneeshkumarg avatar nanthinimahalingam avatar sarubala20 avatar vinothkumar-ganesan avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.