Create a Chart Bind multible series, axis labels and add scrollbar

Posted by: hmmftg on 15 April 2019, 5:36 pm EST

    • Post Options:
    • Link

    Posted 15 April 2019, 5:36 pm EST

    Hi, I’m trying to create a sample form which displays a line chart from random data in several series(changing runtime) and their labels, and also display an scrollbar for chart.

    My Data is:

    public class ChartPoint
            {
                public DateTime Value { get; set; }
                public string Time { get; set; }
                public int CountOk { get; set; }
                public int CountFail { get; set; }
                public ChartPoint(DateTime value, int countOk, int countFail)
                {
                    Time = value.ToString("T");
                    CountOk = countOk;
                    CountFail = countFail;
                    Value = value;
                }
            }
            public static ObservableCollection<ChartPoint> TimeData;
    
            public ObservableCollection<ChartPoint> ChartBindingData
            {
                get
                {
                    if (TimeData == null)
                        TimeData = new ObservableCollection<ChartPoint>();
                    return TimeData;
                }
            }
    

    My DataContext in Window Tag:

    DataContext = "{Binding RelativeSource={RelativeSource Self}}"
    

    I have tried c1flexchart, and it was like this:

    <c1:C1FlexChart BindingX="Time" ChartType="Line" 
                                        x:Name="myChart"
                                        HorizontalAlignment="Stretch" 
                                        VerticalAlignment="Stretch" Palette="Light"
                                        ItemsSource="{Binding Path=ChartBindingData}"
                                        LegendTitle="title" 
                                        ScrollViewer.CanContentScroll="True" 
                                        ScrollViewer.VerticalScrollBarVisibility="Disabled" 
                                        ScrollViewer.HorizontalScrollBarVisibility="Visible" LegendToggle="True" SelectionMode="Point" AnimationSettings="AxesUpdate">
                            <c1:Series x:Name="SeriesFail" Binding="CountFail" SeriesName="Fail"/>
                            <c1:Series x:Name="SeriesOk" Binding="CountOk" SeriesName="Ok"/>
                        </c1:C1FlexChart>
    

    but legend is empty, and I cannot add scrollbar for it, should I use C1Chart instead of C1FlexChart? I couln’t apply data binding in C1Chart.

    Please help.

    Thanks

  • Posted 15 April 2019, 11:31 pm EST

    >>For Scrollbar:

    It seems like you have misinterpreted the ScrollViewer.Vertical/HorizontalScrollBarVisibility with AxisScrollbar for FlexChart. I have replied to your query regarding adding scrollbar for chart axis in your previous query at “https://www.grapecity.com/en/forums/wpf-edition/c1flexchart-series-binding”. So, please have a look into the sample attached there and let me know if you still face some issue.

    >> but legend is empty

    I could not reproduce this issue as setting the SeriesName for Series displays the legend properly (refer sample I provided recently). Let me know if they are not being generated at your end by using the same sample. Also, if this is the case then please provide the version information of FlexChart that you are using.

    >>should I use C1Chart instead of C1FlexChart?

    C1Chart is in maintenance now so, I won’t suggest you to use that until it is very much required.

    Thanks,

    Basant

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels