FlexChart DataLabel custom Format

Posted by: david.cunningham on 1 February 2021, 1:46 am EST

  • Posted 1 February 2021, 1:46 am EST

    Hello,

    i need to format my Datalabel on my FlexChart DataLabel:

    <c1:FlexChart.DataLabel>
    <c1:ChartDataLabel
    Position="Bottom"
    Angle="90"
    Content="{}{y}"/>
    </c1:FlexChart.DataLabel>

    My y Value is an int for the number of Operation Seconds which is really high and has to be formatted so that it's human readable with months day seconds etc.
    How can i do so?

    Kind Regards
    David
  • Replied 1 February 2021, 11:30 pm EST

    Hi David

    To achieve this capture the "LabelLoading" event of AxisY of the FlexrGrid.
      Convert the Seconds of your data into the TimeSpan.
      Convert the timeSpan into the DateTime.
      Create a new Label and set the datetime as the text of the label.
      Assign this label to the Label property of the "AxisLabelLoadingEventArgs".


     private void AxisY_LabelLoading(object sender, AxisLabelLoadingEventArgs e)
    {
    Label label = new Label();
    TimeSpan t = TimeSpan.FromSeconds(_list[e.Index].Expenses);
    DateTime dateTime = DateTime.Now + t;
    label.Text = dateTime.ToShortDateString();
    e.Label = label;
    }


    For reference please have a look at the "GettingStartedSample" sample of the attached FlexGrid101 sample.

    Please let me know if you need any other help.

    ThanksFlexChart101.zip
  • Replied 2 February 2021, 1:39 am EST

    Hello Abhishek,

    i made it exactly like in the attached Example but the LabelLoading event isn't firing for any reason.
    Also tried to update but still it doesn't fire t he event.

    And please don't get me wrong, i want to format the datalabel wich is the value on the bar, not the axis label text.

    Kind regards,
    david
  • Replied 2 February 2021, 1:29 am EST

    Hi David

    Can you please try updating to the latest version of the C1Xamarin(4.8.20203.495), and try executing your project?

    If you still face any issue(with the latest build of C1Xamarin), please share a small sample replicating the issue that will help us to assist you better.

    Please let me know if you need any other help.

    Thanks
  • Replied 2 February 2021, 1:41 am EST

    Hello Abhishek,

    I updated to the latest version but it doesn't fire the event.

    And please don't get me wrong, i want to format the datalabel wich is the value on the bar, not the axis label text.
  • Replied 3 February 2021, 7:54 pm EST

    Hello Abhishek,

    i'm still trying to achieve a custom DataLabel and found the following Event:

    this.chart.DataLabelsLoading += chart_DataLabelsLoading;

    private void chart_DataLabelsLoading(object sender, DataLabelLoadingEventArgs e)
    {
    Label label = new Label();
    label.Text = secondsToHumanReadable((int)e.DataPoint.DataY);
    e.View = label;
    }

    The method is getting invoked but unfortunately the label isn't showing in the Diagram.
    I tried settings Position and Align but it didn't work.
    I am on the newest version of c1Xamarin.
    What am i doing wrong?

    Kind regards
    David
  • Replied 4 February 2021, 2:20 am EST

    Hi David

    I can observe this behavior with the ".DataLabelsLoading" event of the FlexChart, I am confirming this behavior with the concerned team. I will let you know as soon as I get any update from them.

    Please let me know if you need any other help.

    Thanks
  • Replied 4 February 2021, 3:10 am EST

    Thanks! I'm looking forward to it!
    I think the TooltipIsLoading also doesn't get executed.
  • Replied 7 February 2021, 9:51 pm EST

    Hi David

    Thanks for sharing this information with us, I am able to replicate the ToolTipLoading issue at my end, I have escalated it to the concerned team. I will let you know as soon as I get any update from them.

    Please let me know if you need any other help.

    Thanks
Need extra support?

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

Learn More

Forum Channels