9 | Swapping to Development environment will display more detailed information about the error that occurred.
10 |
11 |
12 | The Development environment shouldn't be enabled for deployed applications.
13 | It can result in displaying sensitive information from exceptions to end users.
14 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
15 | and restarting the app.
16 |
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:62575",
7 | "sslPort": 44373
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "HighchartsUsingBlazor": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
22 | "environmentVariables": {
23 | "ASPNETCORE_ENVIRONMENT": "Development"
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | There are loads of Blazor 3rd party vendors, but it is still very early and some features are missing.
3 | Before we started porting our sites to Blazor we used Highcharts and we decided that we want to continue using Highcharts for a little bit longer (until the vendors add what we need).
4 |
5 | I have seen other projects trying to port Highcharts to .NET classes (or at least for the configuration) but the downside is that you can't use the documentation to figure out how to create a chart.
6 | I wanted my solution to be simple to use (if you already used Highcharts or want to use their documentation), no need to convert from JSON to .NET.
7 | I didn't want to involve NPM (one of the things I love most about Blazor is that I don't need NPM).
8 |
9 | You can read more on how to use it here: http://engstromjimmy.se/post/2020-03-21-UsingHighchartsWithBlazor
10 |
11 |
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.Hosting;
10 | using Microsoft.Extensions.Logging;
11 |
12 | namespace HighchartsUsingBlazor
13 | {
14 | public class Program
15 | {
16 | public static void Main(string[] args)
17 | {
18 | CreateHostBuilder(args).Build().Run();
19 | }
20 |
21 | public static IHostBuilder CreateHostBuilder(string[] args) =>
22 | Host.CreateDefaultBuilder(args)
23 | .ConfigureWebHostDefaults(webBuilder =>
24 | {
25 | webBuilder.UseStartup();
26 | });
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/Shared/NavMenu.razor:
--------------------------------------------------------------------------------
1 |
17 |
18 | @code {
19 | private bool collapseNavMenu = true;
20 |
21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
22 |
23 | private void ToggleNavMenu()
24 | {
25 | collapseNavMenu = !collapseNavMenu;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/wwwroot/css/open-iconic/ICON-LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/HighchartsUsingBlazor.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29521.150
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighchartsUsingBlazor", "HighchartsUsingBlazor.csproj", "{D94AA22C-9D82-45E9-ABFF-1C026E5B141D}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D94AA22C-9D82-45E9-ABFF-1C026E5B141D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {D94AA22C-9D82-45E9-ABFF-1C026E5B141D}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {D94AA22C-9D82-45E9-ABFF-1C026E5B141D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {D94AA22C-9D82-45E9-ABFF-1C026E5B141D}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {BFCEA833-4409-4969-B2A5-4B28ADA87440}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/Pages/_Host.cshtml:
--------------------------------------------------------------------------------
1 | @page "/"
2 | @namespace HighchartsUsingBlazor.Pages
3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4 | @{
5 | Layout = null;
6 | }
7 |
8 |
9 |
10 |
11 |
12 |
13 | HighchartsUsingBlazor
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | An error has occurred. This application may no longer respond until reloaded.
26 |
27 |
28 | An unhandled exception has occurred. See browser dev tools for details.
29 |
30 | Reload
31 | 🗙
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/compilerconfig.json.defaults:
--------------------------------------------------------------------------------
1 | {
2 | "compilers": {
3 | "less": {
4 | "autoPrefix": "",
5 | "cssComb": "none",
6 | "ieCompat": true,
7 | "strictMath": false,
8 | "strictUnits": false,
9 | "relativeUrls": true,
10 | "rootPath": "",
11 | "sourceMapRoot": "",
12 | "sourceMapBasePath": "",
13 | "sourceMap": false
14 | },
15 | "sass": {
16 | "autoPrefix": "",
17 | "includePath": "",
18 | "indentType": "space",
19 | "indentWidth": 2,
20 | "outputStyle": "nested",
21 | "Precision": 5,
22 | "relativeUrls": true,
23 | "sourceMapRoot": "",
24 | "lineFeed": "",
25 | "sourceMap": false
26 | },
27 | "stylus": {
28 | "sourceMap": false
29 | },
30 | "babel": {
31 | "sourceMap": false
32 | },
33 | "coffeescript": {
34 | "bare": false,
35 | "runtimeMode": "node",
36 | "sourceMap": false
37 | },
38 | "handlebars": {
39 | "root": "",
40 | "noBOM": false,
41 | "name": "",
42 | "namespace": "",
43 | "knownHelpersOnly": false,
44 | "forcePartial": false,
45 | "knownHelpers": [],
46 | "commonjs": "",
47 | "amd": false,
48 | "sourceMap": false
49 | }
50 | },
51 | "minifiers": {
52 | "css": {
53 | "enabled": true,
54 | "termSemicolons": true,
55 | "gzip": false
56 | },
57 | "javascript": {
58 | "enabled": true,
59 | "termSemicolons": true,
60 | "gzip": false
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/Pages/Index.razor:
--------------------------------------------------------------------------------
1 | @page "/"
2 |
3 |
4 |
5 |
6 | @code{
7 | string chartjson = @" {
8 |
9 | title: {
10 | text: 'Solar Employment Growth by Sector, 2010-2016'
11 | },
12 |
13 | subtitle: {
14 | text: 'Source: thesolarfoundation.com'
15 | },
16 |
17 | yAxis: {
18 | title: {
19 | text: 'Number of Employees'
20 | }
21 | },
22 |
23 | xAxis: {
24 | accessibility: {
25 | rangeDescription: 'Range: 2010 to 2017'
26 | }
27 | },
28 |
29 | legend: {
30 | layout: 'vertical',
31 | align: 'right',
32 | verticalAlign: 'middle'
33 | },
34 |
35 | plotOptions: {
36 | series: {
37 | label: {
38 | connectorAllowed: false
39 | },
40 | pointStart: 2010
41 | }
42 | },
43 |
44 | series: [{
45 | name: 'Installation',
46 | data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
47 | }, {
48 | name: 'Manufacturing',
49 | data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
50 | }, {
51 | name: 'Sales & Distribution',
52 | data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387]
53 | }, {
54 | name: 'Project Development',
55 | data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227]
56 | }, {
57 | name: 'Other',
58 | data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
59 | }],
60 |
61 | responsive: {
62 | rules: [{
63 | condition: {
64 | maxWidth: 500
65 | },
66 | chartOptions: {
67 | legend: {
68 | layout: 'horizontal',
69 | align: 'center',
70 | verticalAlign: 'bottom'
71 | }
72 | }
73 | }]
74 | }
75 | }";
76 | }
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/wwwroot/js/JSInterop.min.js:
--------------------------------------------------------------------------------
1 | "use strict";function loadHighchart(n,t){loadScript("https://code.highcharts.com/stock/highstock.js").then(function(){waitForGlobal("Highcharts",function(){var i=looseJsonParse(t);Highcharts.chart(n,i);SetLanguage()})},function(){})}function looseJsonParse(n){return Function('"use strict";return ('+n+")")()}function loadStockchart(n,t){loadScript("https://code.highcharts.com/stock/highstock.js").then(function(){loadScript("https://code.highcharts.com/stock/modules/data.js").then(function(){waitForGlobal("Highcharts",function(){var i=looseJsonParse(t);Highcharts.stockChart(n,i);SetLanguage()})},function(){})},function(){})}function SetLanguage(){Highcharts.setOptions({lang:{contextButtonTitle:"Diagram-meny",decimalPoint:",",downloadJPEG:"Ladda ned JPEG-bild",downloadPDF:"Ladda ned PDF-dokument",downloadPNG:"Ladda ned PNG-bild",downloadSVG:"Ladda ned SVG-vektorgrafik",drillUpText:"Tillbaka till {series.name}",invalidDate:"",loading:"Laddar...",months:["Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December"],noData:"Ingen data att visa",numericSymbols:["k","M","G","T","P","E"],printChart:"Skriv ut diagram",resetZoom:"Återställ zoom",resetZoomTitle:"Återställ zoomnivå 1:1",shortMonths:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec"],thousandsSep:" ",weekdays:["Söndag","Måndag","Tisdag","Onsdag","Torsdag","Fredag","Lördag"],rangeSelectorZoom:"Zoom",rangeSelectorFrom:"Från",rangeSelectorTo:"Till"}})}function loadScript(n){return new Promise(function(t,i){for(var e,u,o=!1,f=document.getElementsByTagName("script"),r=0;r
52 | {
53 | endpoints.MapBlazorHub();
54 | endpoints.MapFallbackToPage("/_Host");
55 | });
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/Scripts/JSInterop.js:
--------------------------------------------------------------------------------
1 | window.loadHighchart = loadHighchart;
2 |
3 | function loadHighchart(id, json) {
4 | loadScript("https://code.highcharts.com/highcharts.js")
5 | .then(() => {
6 | waitForGlobal("Highcharts", function () {
7 | var obj = looseJsonParse(json);
8 | Highcharts.chart(id, obj);
9 | });
10 | }, () => {
11 | // error loading file
12 | });
13 | };
14 |
15 | var waitForGlobal = function (key, callback) {
16 | if (window[key]) {
17 | callback();
18 | } else {
19 | setTimeout(function () {
20 | waitForGlobal(key, callback);
21 | }, 100);
22 | }
23 | };
24 |
25 | function looseJsonParse(obj) {
26 | return Function('"use strict";return (' + obj + ')')();
27 | }
28 |
29 | function loadStockchart(id, json) {
30 | loadScript("https://code.highcharts.com/stock/highstock.js")
31 | .then(() => {
32 | loadScript("https://code.highcharts.com/stock/modules/data.js")
33 | .then(() => {
34 | waitForGlobal("Highcharts", function () {
35 | var obj = looseJsonParse(json);
36 | Highcharts.stockChart(id, obj);
37 | SetLanguage();
38 | });
39 | }, () => {
40 | // error loading file
41 | });
42 |
43 | }, () => {
44 | // error loading file
45 | });
46 | }
47 |
48 |
49 | function loadScript(url) {
50 | return new Promise(function (resolve, reject) {
51 | var isFound = false;
52 | var scripts = document.getElementsByTagName("script")
53 | for (var i = 0; i < scripts.length; ++i) {
54 | if (scripts[i].getAttribute('src') != null && scripts[i].getAttribute('src') == url) {
55 | isFound = true;
56 | resolve();
57 | }
58 | }
59 |
60 | if (!isFound) {
61 | var dynamicScripts = [url];
62 | for (var i = 0; i < dynamicScripts.length; i++) {
63 | let node = document.createElement('script');
64 | node.src = dynamicScripts[i];
65 | node.type = 'text/javascript';
66 | node.onload = resolve;
67 | node.onerror = reject;
68 | node.async = false;
69 | node.charset = 'utf-8';
70 | document.getElementsByTagName('head')[0].appendChild(node);
71 | }
72 | }
73 | });
74 | }
--------------------------------------------------------------------------------
/HighchartsUsingBlazor/wwwroot/css/open-iconic/README.md:
--------------------------------------------------------------------------------
1 | [Open Iconic v1.1.1](http://useiconic.com/open)
2 | ===========
3 |
4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons)
5 |
6 |
7 |
8 | ## What's in Open Iconic?
9 |
10 | * 223 icons designed to be legible down to 8 pixels
11 | * Super-light SVG files - 61.8 for the entire set
12 | * SVG sprite—the modern replacement for icon fonts
13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats
14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats
15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px.
16 |
17 |
18 | ## Getting Started
19 |
20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections.
21 |
22 | ### General Usage
23 |
24 | #### Using Open Iconic's SVGs
25 |
26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute).
27 |
28 | ```
29 |
30 | ```
31 |
32 | #### Using Open Iconic's SVG Sprite
33 |
34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack.
35 |
36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `