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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ TradingView [Charting Library](https://www.tradingview.com/HTML5-stock-forex-bit

TradingView [Charting Library](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/) and [Angular 5](https://angular.io/) Integration Example

### blazor-wasm

TradingView [Charting Library](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/) and [Blazor](https://blazor.net/) [WebAssembly](https://docs.microsoft.com/en-gb/aspnet/core/blazor/hosting-models#blazor-webassembly) Integration Example

### ios-swift

TradingView [Charting Library](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/) integration into iOS WKWebView
Expand Down
10 changes: 10 additions & 0 deletions blazor-wasm/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
13 changes: 13 additions & 0 deletions blazor-wasm/Components/TradingViewChart.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@inject IJSRuntime JSRuntime

<div id="tv_chart_container" class="TradingViewChart"></div>

@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await JSRuntime.InvokeAsync<object>("tradingViewChartWrapper.initialize");
}
}
}
3 changes: 3 additions & 0 deletions blazor-wasm/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/"

<TradingViewChart />
16 changes: 16 additions & 0 deletions blazor-wasm/Program.cs
Original file line number Diff line number Diff line change
@@ -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

{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) =>
BlazorWebAssemblyHost.CreateDefaultBuilder()
.UseBlazorStartup<Startup>();
}
}
19 changes: 19 additions & 0 deletions blazor-wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# TradingView Charting Library and Blazor WebAssembly Integration Example

## How to start

1. Copy `charting_library` folder from https://github.com/tradingview/charting_library/ to `/wwwroot` folder. The earliest supported version of the Charting Library is 1.12. If you get 404 then you need to [request an access to this repository](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/).
1. Copy `datafeeds` folder from https://github.com/tradingview/charting_library/ to `/wwwroot`.
1. Run `dotnet run`. It will build the project and run a server on http://localhost:5000 where you may navigate to in your browser.

## What is Charting Library

Charting Library is a standalone solution for displaying charts. This free, downloadable library is hosted on your servers and is connected to your data feed to be used in your website or app. [Learn more and download](https://www.tradingview.com/HTML5-stock-forex-bitcoin-charting-library/).

## What is Blazor WebAssembly

Blazor WebAssembly is a single-page app framework for building interactive client-side web apps with .NET. Blazor WebAssembly uses open web standards without plugins or code transpilation and works in all modern web browsers, including mobile browsers.

## About This Project

This project was created with [.NET Core CLI](https://docs.microsoft.com/en-gb/aspnet/core/blazor/get-started?view=aspnetcore-3.0&tabs=netcore-cli).
15 changes: 15 additions & 0 deletions blazor-wasm/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@inherits LayoutComponentBase

<div class="sidebar">
<NavMenu />
</div>

<div class="main">
<div class="top-row px-4">
<a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a>
</div>

<div class="content px-4">
@Body
</div>
</div>
27 changes: 27 additions & 0 deletions blazor-wasm/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="top-row pl-4 navbar navbar-dark">
<a class="navbar-brand" href="">WebApplication1</a>
<button class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<ul class="nav flex-column">
<li class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</li>
</ul>
</div>

@code {
private bool collapseNavMenu = true;

private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;

private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
}
17 changes: 17 additions & 0 deletions blazor-wasm/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Components.Builder;
using Microsoft.Extensions.DependencyInjection;

namespace WebApplication1
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}

public void Configure(IComponentsApplicationBuilder app)
{
app.AddComponent<App>("app");
}
}
}
15 changes: 15 additions & 0 deletions blazor-wasm/WebApplication1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<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>

<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<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" />
Comment on lines +9 to +12
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

</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions blazor-wasm/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using WebApplication1
@using WebApplication1.Components
@using WebApplication1.Shared
5 changes: 5 additions & 0 deletions blazor-wasm/obj/WebApplication1.csproj.nuget.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"dgSpecHash": "NDuF6YjtcCoYqH0XbROA+FgH7zDmqssPRAdSQCy8cZ7aXxpdQUXARuoTOz6FDYThRBRWOs3lpPIjDvsFSuQF3A==",
"success": true
}
Comment on lines +1 to +5
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

86 changes: 86 additions & 0 deletions blazor-wasm/obj/WebApplication1.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"format": 1,
"restore": {
"C:\\Users\\micro\\OneDrive - X-treem Software\\Development\\Repos\\General\\Libraries\\charting-library-examples\\WebApplication1\\WebApplication1.csproj": {}
},
"projects": {
"C:\\Users\\micro\\OneDrive - X-treem Software\\Development\\Repos\\General\\Libraries\\charting-library-examples\\WebApplication1\\WebApplication1.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\micro\\OneDrive - X-treem Software\\Development\\Repos\\General\\Libraries\\charting-library-examples\\WebApplication1\\WebApplication1.csproj",
"projectName": "WebApplication1",
"projectPath": "C:\\Users\\micro\\OneDrive - X-treem Software\\Development\\Repos\\General\\Libraries\\charting-library-examples\\WebApplication1\\WebApplication1.csproj",
"packagesPath": "C:\\Users\\micro\\.nuget\\packages\\",
"outputPath": "C:\\Users\\micro\\OneDrive - X-treem Software\\Development\\Repos\\General\\Libraries\\charting-library-examples\\WebApplication1\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Microsoft\\Xamarin\\NuGet\\",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\micro\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config"
],
"originalTargetFrameworks": [
"netstandard2.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netstandard2.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netstandard2.0": {
"dependencies": {
"Microsoft.AspNetCore.Blazor": {
"target": "Package",
"version": "[3.1.0-preview1.19508.20, )"
},
"Microsoft.AspNetCore.Blazor.Build": {
"suppressParent": "All",
"target": "Package",
"version": "[3.1.0-preview1.19508.20, )"
},
"Microsoft.AspNetCore.Blazor.DevServer": {
"suppressParent": "All",
"target": "Package",
"version": "[3.1.0-preview1.19508.20, )"
},
"Microsoft.AspNetCore.Blazor.HttpClient": {
"target": "Package",
"version": "[3.1.0-preview1.19508.20, )"
},
"NETStandard.Library": {
"suppressParent": "All",
"target": "Package",
"version": "[2.0.3, )",
"autoReferenced": true
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.100-preview1-014459\\RuntimeIdentifierGraph.json"
}
}
}
}
}
24 changes: 24 additions & 0 deletions blazor-wasm/obj/WebApplication1.csproj.nuget.g.props
Original file line number Diff line number Diff line change
@@ -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.

<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\micro\.nuget\packages\;C:\Microsoft\Xamarin\NuGet\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.3.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.blazor.mono\3.1.0-preview1.19503.1\build\netstandard1.0\Microsoft.AspNetCore.Blazor.Mono.props" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.blazor.mono\3.1.0-preview1.19503.1\build\netstandard1.0\Microsoft.AspNetCore.Blazor.Mono.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.blazor.build\3.1.0-preview1.19508.20\build\netstandard1.0\Microsoft.AspNetCore.Blazor.Build.props" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.blazor.build\3.1.0-preview1.19508.20\build\netstandard1.0\Microsoft.AspNetCore.Blazor.Build.props')" />
</ImportGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgMicrosoft_AspNetCore_Blazor_Mono Condition=" '$(PkgMicrosoft_AspNetCore_Blazor_Mono)' == '' ">C:\Users\micro\.nuget\packages\microsoft.aspnetcore.blazor.mono\3.1.0-preview1.19503.1</PkgMicrosoft_AspNetCore_Blazor_Mono>
<PkgMicrosoft_AspNetCore_Blazor_DevServer Condition=" '$(PkgMicrosoft_AspNetCore_Blazor_DevServer)' == '' ">C:\Users\micro\.nuget\packages\microsoft.aspnetcore.blazor.devserver\3.1.0-preview1.19508.20</PkgMicrosoft_AspNetCore_Blazor_DevServer>
<PkgMicrosoft_AspNetCore_Blazor_Build Condition=" '$(PkgMicrosoft_AspNetCore_Blazor_Build)' == '' ">C:\Users\micro\.nuget\packages\microsoft.aspnetcore.blazor.build\3.1.0-preview1.19508.20</PkgMicrosoft_AspNetCore_Blazor_Build>
</PropertyGroup>
</Project>
12 changes: 12 additions & 0 deletions blazor-wasm/obj/WebApplication1.csproj.nuget.g.targets
Original file line number Diff line number Diff line change
@@ -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.

<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.blazor.mono\3.1.0-preview1.19503.1\build\netstandard1.0\Microsoft.AspNetCore.Blazor.Mono.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.blazor.mono\3.1.0-preview1.19503.1\build\netstandard1.0\Microsoft.AspNetCore.Blazor.Mono.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.blazor.devserver\3.1.0-preview1.19508.20\build\Microsoft.AspNetCore.Blazor.DevServer.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.blazor.devserver\3.1.0-preview1.19508.20\build\Microsoft.AspNetCore.Blazor.DevServer.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.blazor.build\3.1.0-preview1.19508.20\build\netstandard1.0\Microsoft.AspNetCore.Blazor.Build.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.blazor.build\3.1.0-preview1.19508.20\build\netstandard1.0\Microsoft.AspNetCore.Blazor.Build.targets')" />
</ImportGroup>
</Project>
Loading