How to dynamically change editor text, and put line breaks

Here I have trackballInfo, which is an Editor. I am trying to change the text of the Editor when the trackball changes. I am also trying to make a new line to separate them. I come up with the error that says System.FormatException has been thrown Input string was not in a correct format. What is the issue here?

private
 void TrackballCreated(object sender, ChartTrackballCreatedEventArgs eventArgs) 
{
    var trackballs = eventArgs.ChartPointsInfo;
    string info = "";
    foreach (var trackball in trackballs)
    {
        info += trackball.Label + "\n";
    }
    trackballInfo.Text = info;
}

7 Replies

MP Michael Prabhu M Syncfusion Team July 3, 2018 12:32 PM UTC

 Hi Peter, 
 
Thanks for using Syncfusion products, 
 
We have analyzed your query and created a sample based on it and we are afraid we were not able to reproduce the issue. The sample which used to replicate the issue can be downloaded from the below link. 
 
 
Sample Screenshot:  
 
Code snippet [XAML]:   
<Editor x:Name="trackballInfo" HeightRequest="150"  HorizontalOptions="FillAndExpand" FontSize ="15"/> 
 
  
Code snippet [C#]:    
private void Chart_TrackballCreated(object sender, Syncfusion.SfChart.XForms.ChartTrackballCreatedEventArgs e) 
        { 
            var trackballs = e.ChartPointsInfo; 
            string info = ""; 
 
            foreach (var trackball in trackballs) 
            { 
                info += trackball.Label + "\n"; 
            } 
            
            trackballInfo.Text = info; 
 
        } 
 
 
 
Since we are not able to reproduce this issue can you please modify the provided sample and revert us with replication procedure, this will be helpful for us to serve you better. 
 
Note: You have created this forum based on Xamarin.iOS but the code snippet provided by shows that you have TrackballCreated Event which is available in Xamarin.Forms.iOS so we have prepared a sample based on Xamarin.Forms.iOS. If this is wrong, please revert us.  
 
Thanks, 
Michael 




PC Peter Cardenas July 3, 2018 03:56 PM UTC

Sorry, I meant Xamarin.Forms.iOS. I think it would be easier if I exhibited the XAML that I used.

<ContentPage.Content>
        <Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
            
            <syncfusion:SfChart Grid.Row="0" x:Name="chart1" VerticalOptions="FillAndExpand" TrackballCreated="TrackballCreated">
                
                <syncfusion:SfChart.ChartBehaviors>
                    <syncfusion:ChartTrackballBehavior x:Name="trackball1" ShowLabel="true" ShowLine="true" LabelDisplayMode="FloatAllPoints"> 
                        <syncfusion:ChartTrackballBehavior.LabelStyle>
                            <syncfusion:ChartTrackballLabelStyle LabelFormat="$#,###.##" />
                        </syncfusion:ChartTrackballBehavior.LabelStyle>
                    </syncfusion:ChartTrackballBehavior>
                </syncfusion:SfChart.ChartBehaviors>
                
                <syncfusion:SfChart.PrimaryAxis>
                    <syncfusion:NumericalAxis Name="TimeAxis1" ShowMajorGridLines="false" ShowTrackballInfo="true" />
                </syncfusion:SfChart.PrimaryAxis>
                
                <syncfusion:SfChart.SecondaryAxis>
                    <syncfusion:NumericalAxis Name="PortValAxis1" ShowMajorGridLines="false" ShowTrackballInfo="true">
                        <syncfusion:NumericalAxis.LabelStyle>
                            <syncfusion:ChartAxisLabelStyle LabelFormat="$#,###.##" />
                        </syncfusion:NumericalAxis.LabelStyle>
                    </syncfusion:NumericalAxis>
                </syncfusion:SfChart.SecondaryAxis>
                
                <syncfusion:SfChart.Legend>
                    <syncfusion:ChartLegend DockPosition="Right" />
                </syncfusion:SfChart.Legend>
                
            </syncfusion:SfChart>
            
            <syncfusion:SfChart Grid.Row="0" x:Name="chart2" VerticalOptions="FillAndExpand" TrackballCreated="TrackballCreated">
                
                <syncfusion:SfChart.ChartBehaviors>
                    <syncfusion:ChartTrackballBehavior x:Name="trackball2" ShowLabel="true" ShowLine="true" LabelDisplayMode="FloatAllPoints"> 
                        <syncfusion:ChartTrackballBehavior.LabelStyle>
                            <syncfusion:ChartTrackballLabelStyle LabelFormat="$#,###.##" />
                        </syncfusion:ChartTrackballBehavior.LabelStyle>
                    </syncfusion:ChartTrackballBehavior>
                </syncfusion:SfChart.ChartBehaviors>
                
                <syncfusion:SfChart.PrimaryAxis>
                    <syncfusion:NumericalAxis Name="TimeAxis2" ShowMajorGridLines="false" ShowTrackballInfo="true" />
                </syncfusion:SfChart.PrimaryAxis>
                
                <syncfusion:SfChart.SecondaryAxis>
                    <syncfusion:NumericalAxis x:Name="PortValAxis2" ShowMajorGridLines="false" ShowTrackballInfo="true">
                        <syncfusion:NumericalAxis.LabelStyle>
                            <syncfusion:ChartAxisLabelStyle LabelFormat="$#,###.##" />
                        </syncfusion:NumericalAxis.LabelStyle>
                    </syncfusion:NumericalAxis>
                </syncfusion:SfChart.SecondaryAxis>
                
                <syncfusion:SfChart.Legend>
                    <syncfusion:ChartLegend DockPosition="Right" />
                </syncfusion:SfChart.Legend>
                
            </syncfusion:SfChart>

            <Editor Grid.Row="0" x:Name="trackballInfo" InputTransparent="true" VerticalOptions="StartAndExpand" HorizontalOptions="EndAndExpand" /> 
        </Grid>
    </ContentPage.Content> 
  


PC Peter Cardenas July 4, 2018 04:39 PM UTC

If it is any help, this is the stack trace was thrown in the Main.cs. 

at System.Number.ParseDouble (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) [0x00085] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/number.cs:728 
  at System.Double.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/double.cs:272 
  at System.Double.Parse (System.String s, System.IFormatProvider provider) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/double.cs:255 
  at System.Convert.ToDouble (System.String value) [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/convert.cs:1603 
  at Syncfusion.SfChart.iOS.SFChartTrackballBehavior.SetNativeChartPointsInfo (System.Collections.Generic.List`1[T] chartPointsInfo, System.Collections.Generic.List`1[T] xFormsPointsInfos) [0x00086] in <0eda87787377430989c6d0dec448a8e1>:0 
  at Syncfusion.SfChart.iOS.SFChartTrackballBehavior.UpdateTrackballInLocation (CoreGraphics.CGPoint point) [0x005a6] in <0eda87787377430989c6d0dec448a8e1>:0 
  at Syncfusion.SfChart.iOS.SFChartTrackballBehavior.Show (CoreGraphics.CGPoint point) [0x00016] in <0eda87787377430989c6d0dec448a8e1>:0 
  at Syncfusion.SfChart.iOS.SFChartTrackballBehavior.LongPressWithGestureRecognizer (UIKit.UILongPressGestureRecognizer longPressGestureRecognizer) [0x00066] in <0eda87787377430989c6d0dec448a8e1>:0 
  at UIKit.UILongPressGestureRecognizer+Callback.Activated (UIKit.UILongPressGestureRecognizer sender) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIGestureRecognizer.cs:183 
--- End of stack trace from previous location where exception was thrown ---
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:63 
  at MC_Phone.iOS.Application.Main (System.String[] args) [0x00001] in /Users/petercardenas/Documents/MC_Phone4_1/MC_Phone/MC_Phone.iOS/Main.cs:12 


MP Michael Prabhu M Syncfusion Team July 5, 2018 11:25 AM UTC

Hi Peter, 

Thanks for the update, it was helpful for us to find the issue. This issue is due to invalid label format in the ChartTrackballBehavior.To overcome this, we recommend you to remove the LabelFormat property in the ChartTrackballballBehavior label style and modify the required label format in label created event. Please refer the following code snippet for more details. 

Code snippet: 


        private void Chart_TrackballCreated(object sender, Syncfusion.SfChart.XForms.ChartTrackballCreatedEventArgs e) 
        { 
 
            var trackballs = e.ChartPointsInfo; 
            string info = ""; 
 
            foreach (var trackball in trackballs) 
            { 
                info += trackball.Label + "\n"; 
                trackball.Label = "$" + trackball.Label; 
            } 
 
            trackballInfo.Text = info; 
        } 


Please let us know, if you need further assistance on this. 

Thanks, 
Michael 



PC Peter Cardenas July 6, 2018 12:14 AM UTC

Thank you very much for your aid. There is no longer any errors that pop up, but the Editor is off the edge of the screen. I have linked a screenshot of how it appears, and the changes I made to the function to fit my needs.

https://imgur.com/a/6Azm5EI

private void TrackballCreated(object sender, ChartTrackballCreatedEventArgs eventArgs) 
        {
            var trackballs = eventArgs.ChartPointsInfo;
            string info = "";
            double currNum = 0.0d;
            foreach (var trackball in trackballs)
            {
                Double.TryParse(trackball.Label, out currNum);
                trackball.Label = String.Format("${0:n0}", currNum);
                info += trackball.Label + "\n";
            }
            trackballInfo.Text = info;
        }
  


PC Peter Cardenas July 6, 2018 12:21 AM UTC

I used the following code, and it worked, sorry for the abrupt change. Thanks for your help again.

<Editor Grid.Row="0" x:Name="trackballInfo" InputTransparent="true" Text="LOL" VerticalOptions="StartAndExpand" HorizontalOptions="EndAndExpand" AutoSize="TextChanges" />  


MP Michael Prabhu M Syncfusion Team July 6, 2018 04:47 AM UTC

Hi Peter, 
 
We are glad that you have resolved it, let us know if you need any other assistance from us.  
 
Thanks, 
Michael 



Loader.
Up arrow icon