C1FlexChart Series Binding

Posted by: hmmftg on 14 April 2019, 3:07 am EST

  • Posted 14 April 2019, 3:07 am EST

    Hi, Please check this code:


    public class ChartPoint
    public string Time { get; set; }
    public int CountOk { get; set; }
    public int CountFail { get; set; }
    public ChartPoint(string time, int countOk, int countFail)
    Time = time;
    CountOk = countOk;
    CountFail = countFail;
    public static List<ChartPoint> TimeData;

    public List<ChartPoint> ChartBindingData { get { return TimeData; } }

    in Window Tag
    DataContext = "{Binding RelativeSource={RelativeSource Self}}"

    in Grid

    <c1:C1FlexChart BindingX="Time" x:Name="flexChart"
    VerticalAlignment="Stretch" Palette="Light"
    ItemsSource="{Binding Path=ChartBindingData}">
    <c1:Series Binding="CountFail" SeriesName="Fail"/>
    <c1:Series Binding="CountOk" SeriesName="Ok"/>

    and in timer thread
    SyncContext.Send(state => MainWindow.TimeData.Add(new MainWindow.ChartPoint(DateTime.Now.ToString("T"), (int)usedCpu, (int)usedBytesPrivate)), null);

    the binding is not working here and I'm use the code in WPF.FlexChart.pdf document.

    please help
  • Replied 14 April 2019, 4:47 pm EST


    Since you are dynamically adding items to your collection so, you should use a collection which provides such change notifications (e.g. ObservableCollcetion<T>) instead of List<T>.

    Also, since your Binding source is read (get) only so, you should initialize it before/when it gets used by the Binding. For example:

    public ObservableCollection<ChartPoint> ChartBindingData
    if (TimeData == null)
    TimeData = new ObservableCollection<ChartPoint>();
    return TimeData;

    Also, you can refer the attached sample(prj_DynamicFlexChart.zip) for the same.


  • Replied 14 April 2019, 11:00 pm EST

    Hi, thank you for your reply it worked well,
    can you please help me with adding Axis Scrollbar for my flexchart?
  • Marked as Answer

    Replied 15 April 2019, 7:57 pm EST


    AxisScrollbar can be added to a FlexChart Axis simply as follows:
    <c1:C1AxisScrollbar x:Name="axisScrollbar"/>

    However, since you are using dynamic data so, you have to update AxisScrollbar's Minimum and Maximum according to the current data bounds. For example: Since you have categorical data so, X-Axis values for data items will be 0,1,2...n-1 (n= number of data items) and hence we'll update AxisScrollbar bounds using FlexChart.Rendered event accordingly as follows:

    axisScrollbar.Minimum = 0;
    var max = ChartBindingData.Count() - 1;
    axisScrollbar.Maximum = max <= axisScrollbar.Minimum ? axisScrollbar.Maximum : max;

    Please refer the attached modified sample(prj_ScrollDynamicChart.zip) for complete implementation.


  • Replied 20 April 2019, 2:00 am EST

    Hi basant.khatiyan, thanks very much for your help,
    It helps a lot, I have had a problem by which my legends and axises did not show up in the chart, I tried some modifications and understand that the mistake was using
    in main window! it will cause all chart text to disappear! I don't know why but by deleting that tag everything is OK.

    thanks again for your help.
  • Replied 21 April 2019, 4:26 pm EST


    I tried to replicate the behavior by setting "AllowTransparency = true" and "WindowStyle = WindowStyle.None (required for AllowTransparency)" but could not observe any impact on Legend/Axes(or FlexChart Text).

    Also, the AllowTransparency = true allows only the Window's client area to be transparent if specified(using Background property) so, it should not have affected the text on FlexChart. Therefore, I would request you to confirm the behavior by applying the required settings to the earlier provided sample and share your observations.

Need extra support?

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

Learn More

Forum Channels