Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create example Blazor WebAssembly project #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

NeoXtreem
Copy link

Add example checklist

  • Any commit does not contain the charting library's code
  • Addresses an existing issue: Blazor Sample #132
  • The example is added to README.md
  • The example is self-sufficient and contains only necessary files/changes

@NeoXtreem NeoXtreem changed the title Create example Blazor WebAssembly project #132 Create example Blazor WebAssembly project Nov 4, 2019
@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Blazor.Hosting;

namespace WebApplication1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be clearer if the project's name matches the language of an example

Suggested change
namespace WebApplication1
namespace BlazorWasmExample

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>WebApplication1</title>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need change project's name string everywhere in the code

Suggested change
<title>WebApplication1</title>
<title>BlazorWasmExample</title>

<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the time being the current version of Blazor supports netstandard2.1

Suggested change
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>

Comment on lines +27 to +70
var tvWidget = null;
window.tradingViewChartWrapper = {

initialize: function () {
const widgetOptions = {
symbol: 'AAPL',
// BEWARE: no trailing slash is expected in feed URL
datafeed: new window.Datafeeds.UDFCompatibleDatafeed('https://demo_feed.tradingview.com'),
interval: 'D',
container_id: 'tv_chart_container',
library_path: '/charting_library/',
locale: getLanguageFromUrl() || 'en',
disabled_features: ['use_localstorage_for_settings'],
enabled_features: ['study_templates'],
charts_storage_url: 'https://saveload.tradingview.com',
charts_storage_api_version: '1.1',
client_id: 'tradingview.com',
user_id: 'public_user_id',
fullscreen: false,
autosize: true,
studies_overrides: {}
};

tvWidget = new TradingView.widget(widgetOptions);

tvWidget.onChartReady(() => {
tvWidget.headerReady().then(() => {
const button = tvWidget.createButton();
button.setAttribute('title', 'Click to show a notification popup');
button.classList.add('apply-common-tooltip');
button.addEventListener('click',
() => tvWidget.showNoticeDialog({
title: 'Notification',
body: 'TradingView Charting Library API works correctly',
callback: () => {
console.log('Noticed!');
}
}));

button.innerHTML = 'Check API';
});
});
}
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better place to store the initialization script is a separate javascript file.

Comment on lines +9 to +12
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.1.0-preview1.19508.20" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.1.0-preview1.19508.20" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.1.0-preview1.19508.20" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.1.0-preview1.19508.20" PrivateAssets="all" />
Copy link

@hmG3 hmG3 Jan 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And all NuGet packages can be upgraded to latest preview 3.1.0-preview4.19579.2

Comment on lines +1 to +5
{
"version": 1,
"dgSpecHash": "NDuF6YjtcCoYqH0XbROA+FgH7zDmqssPRAdSQCy8cZ7aXxpdQUXARuoTOz6FDYThRBRWOs3lpPIjDvsFSuQF3A==",
"success": true
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/obj/ is a dynamically generated folder and should not be committed to a source control

Copy link

@hmG3 hmG3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried this example, everything works. Nice to see that Blazor is growing and gaining popularity.

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is generated during package restore, it should be ignored from version control.

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the files in obj subdirectory are usually ignored from git.

@grammy-work
Copy link

Please, anyone, finish the merging.

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.

4 participants