Skip to content

WPF sample: fix blank chart on non-English locales and related bugs#34

Open
toolsche wants to merge 1 commit into
spotware:masterfrom
toolsche:fix/wpf-sample-bugs
Open

WPF sample: fix blank chart on non-English locales and related bugs#34
toolsche wants to merge 1 commit into
spotware:masterfrom
toolsche:fix/wpf-sample-bugs

Conversation

@toolsche

@toolsche toolsche commented Jun 12, 2026

Copy link
Copy Markdown

A few bug fixes for the WPF sample (Trading.UI.Sample).

Blank chart on non-English locales

Chart.cs built the createChart(...) JavaScript by interpolating double OHLC values with the current culture. On cultures that use , as the decimal separator (e.g. German) this produced invalid JS like o: 1,2345, throwing Uncaught SyntaxError: Unexpected token ',', so createChart never ran and the chart stayed blank. Values are now formatted with InvariantCulture.

Missing chart assets in build output

hammer.js and chartjs-plugin-zoom.min.js are referenced by chart.html but were declared with only CopyToPublishDirectory, so a normal dotnet build did not copy them to the output directory. Added CopyToOutputDirectory.

Robust chart.html loading

ChartingService loaded chart.html from Environment.CurrentDirectory with a raw Windows path. It now resolves the path from the app directory (AppContext.BaseDirectory) and hands CefSharp a proper file:// URI.

Faster account load (N+1 removal)

On account change, FillConversionSymbols issued one ProtoOASymbolsForConversionReq per symbol (hundreds of sequential round-trips). It now requests each distinct quote asset once, bringing account load from minutes to seconds.

How to test

  • Locale fix: run on a machine whose decimal separator is , (e.g. de-DE), or temporarily set CultureInfo.CurrentCulture = new CultureInfo("de-DE") at startup. Authorize an account and select a symbol. Before: the chart area is blank (DevTools/CefSharp console shows Uncaught SyntaxError: Unexpected token ','). After: candles render.
  • Assets: dotnet build the sample and confirm Chart.js\hammer.js and Chart.js\chartjs-plugin-zoom.min.js are present in the output Chart.js folder.
  • Account load: select an account with many symbols; the "Changing Account" step now completes in a few seconds instead of minutes.

🤖 Generated with Claude Code

- Chart.cs: format OHLC values with InvariantCulture. They were interpolated with the current culture, so on cultures using ',' as the decimal separator (e.g. German) createChart received invalid JavaScript and the chart stayed blank.
- WPF.Sample.csproj: add CopyToOutputDirectory for hammer.js and chartjs-plugin-zoom.min.js. They are referenced by chart.html but only had CopyToPublishDirectory, so they were missing from a normal build output.
- ChartingService.cs: load chart.html via a proper file:// URI resolved from the app directory (AppContext.BaseDirectory) instead of Environment.CurrentDirectory plus a raw Windows path.
- ShellViewModel.cs: de-duplicate conversion-symbol requests on account change. Each distinct quote asset is now requested once instead of once per symbol, cutting hundreds of sequential round-trips and bringing account load from minutes to seconds.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant