pablofrommars / GGNet

GG.Net Data Visualization
https://pablofrommars.github.io
MIT License
80 stars 11 forks source link

Examples are not working #1

Closed netcorefan closed 4 years ago

netcorefan commented 4 years ago

Hi Pablo,

@pablofrommars, I have downloaded project to test in local and examples are not working. It's same with your wensite https://pablofrommars.github.io/

I have seen your example project is a blazor wasm project, Can your project work on blazor server side project?

tia!

P.s. Project sounds interesting.

pablofrommars commented 4 years ago

Hi,

The library should work on both wasm and server side hosting.

Can you please provide further details on what’s not working for you? Error messages would help.

Happy to assist!

netcorefan commented 4 years ago

Hi @pablofrommars ,

Do you have any example to evaluate Interactivity? I have visited https://pablofrommars.github.io/examples/interactivity but I can't see events working.

In all examples if you press view button, graphs appear empty.

tia!

pablofrommars commented 4 years ago

Well that's embarassing. Found a major bug that probably explains the issue your are experiencing. It has to do with the CultureInfo used by the Blazor rendering engine and more specifically how the decimal separator gets formatted.

I forced the website to use 'en-GB' with the following:

 public static void Main(string[] args)
 {
   CultureInfo.CurrentCulture = new CultureInfo("en-GB");
   CreateHostBuilder(args).Build().Run();
 }

I understand that globally setting CultureInfo cannot fit all use cases so I will have to come up with a better solution in the following days and release an update.

Website should work as expected though.

Thanks for reporting.

netcorefan commented 4 years ago

@pablofrommars,

That's was exactly the problem! good catch!

Yes, as you said, it's better to find other solution for CultureInfo!

good job!

netcorefan commented 4 years ago

hi @pablofrommars ,

I have downloaded project, I have needed to change :

 public static void Main(string[] args)
 {
   CultureInfo.CurrentCulture = new CultureInfo("en-GB");
   CreateHostBuilder(args).Build().Run();
 }

by

        public static void Main(string[] args)
        {
            CultureInfo cultureInfo = new CultureInfo("en-GB");
            CultureInfo.CurrentCulture = cultureInfo;
            CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            CreateHostBuilder(args).Build().Run();
        }

On the other hand, It could be interesting to add server side project to your sample sln, sharing pages, shared pages, ...

and finally, How to do a logaritmic line graph in X axis or Y axis or both?

TIA!

pablofrommars commented 4 years ago

Hi @netcorefan ,

I am still working on a solution that does not require to set any culture info upfront. Any attempt so far has resulted in some performance penalty that I want to avoid.

Server side vs client side are just different Blazor deployment models that do not affect how GG.NET functions. I suggest you download the Blazor server side template and experiment with it. What about adding a chart to the FetchData.razor page? Cool be cool to plot the time serie of temperature forecasts returned by the WeatherForcastService. Let me know if you need assistance.

GG.Net Scales support user defined transformation functions. For logarithmic scales, Scale_X_Log10 Scale_Y_Log10 does the trick.

Thanks for your interest in the Project!

jan-ai commented 4 years ago

I am still working on a solution that does not require to set any culture info upfront. Any attempt so far has resulted in some performance penalty that I want to avoid.

Do you think that that a conversion as mentioned in #6 with ToString (CultureInfo.InvariantCulture) takes longer than ToString (), which in fact is probably internally is a ToString (CultureInfo.CurrentCulture) anyway?

pablofrommars commented 4 years ago

Thanks for your feedback. This is unfortunately an issue that goes beyond GGNet in my opinion. Blazor should Indeed be able to render valid code while maintaining localization capability.

See https://github.com/dotnet/aspnetcore/issues/18271

For the time being, the recommended workaround is to unfortunately set CultureInfo as previously suggested.

jan-ai commented 4 years ago

See dotnet/aspnetcore#18271

Interessting. Let's see if they find a way to better handle it. But it will be complicated for them not getting it more worse. Let have a look at your code:

                    <g clip-path="url(#@(Id)-plot)">
                        <text x=@(Legend.X.ToString (CultureInfo.InvariantCulture)) 
                              y=@((offset + l.Title.Height).ToString (CultureInfo.InvariantCulture)) 
                              class="legendTitle">@l.Title.Value</text>
                    </g>

To get correct output here, two cultures will be needed. The title should use CurrentUICulture, while x and y should use InvariantCulture as already added in my local clone of your repository.

See also https://docs.microsoft.com/visualstudio/code-quality/ca1305-specify-iformatprovider as the "answer" from blazor dev team might also included specifiying the correct IFormatProvider as already suggest for any object to string conversion.