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

Add chart service #521

Merged
merged 15 commits into from
Oct 19, 2024
2 changes: 1 addition & 1 deletion docs/BlazorApexCharts.Docs.Server/App.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true" AdditionalAssemblies="new [] { typeof(MainLayout).Assembly }">
<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new [] { typeof(MainLayout).Assembly }">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,19 @@
<ProjectReference Include="..\BlazorApexCharts.Docs\BlazorApexCharts.Docs.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>
63 changes: 63 additions & 0 deletions docs/BlazorApexCharts.Docs.Server/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions docs/BlazorApexCharts.Docs.Server/Properties/Resources.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"BlazorApexCharts.Docs.Server": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "features/annotations",
"launchUrl": "chart-service",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
Expand Down
10 changes: 10 additions & 0 deletions docs/BlazorApexCharts.Docs.Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ApexCharts;

namespace BlazorApexCharts.Docs.Server
{
Expand All @@ -24,6 +25,15 @@ public void ConfigureServices(IServiceCollection services)
services.AddServerSideBlazor();
services.AddDocs();
services.AddScoped<ICodeSnippetService, LocalSnippetService>();

services.AddApexCharts(e =>
{
e.GlobalOptions = new ApexChartBaseOptions
{
Debug = true,
Theme = new Theme { Palette = PaletteType.Palette6 }
};
});
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
2 changes: 1 addition & 1 deletion docs/BlazorApexCharts.Docs.Wasm/App.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true" AdditionalAssemblies="new [] { typeof(MainLayout).Assembly }">
<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new [] { typeof(MainLayout).Assembly }">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.10" PrivateAssets="all" />
<PackageReference Include="PublishSPAforGitHubPages.Build" Version="3.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
<PackageReference Include="TabBlazor" Version="0.12.2-alpha" />
<PackageReference Include="TabBlazor" Version="0.12.2-alpha" />

<PackageReference Include="System.Text.Json" Version="8.0.5" />

</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 4 additions & 5 deletions docs/BlazorApexCharts.Docs.Wasm/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ApexCharts;
using BlazorApexCharts.Docs.Services;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.JSInterop;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
Expand All @@ -19,13 +19,12 @@ public static async Task Main(string[] args)
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddDocs();

builder.Services.AddHttpClient("GitHub", client => client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("TabBlazor", "1")));
builder.Services.AddHttpClient("GitHub", client => client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Blazor-ApexCharts", "1")));
builder.Services.AddScoped<ICodeSnippetService, GitHubSnippetService>();

//builder.Services.AddSingleton(serviceProvider => (IJSInProcessRuntime)serviceProvider.GetRequiredService<IJSRuntime>());
builder.Services.AddSingleton(serviceProvider => (IJSUnmarshalledRuntime)serviceProvider.GetRequiredService<IJSRuntime>());
builder.Services.AddApexCharts();

var dummy = new TabBlazor.TablerOptions();


await builder.Build().RunAsync();
}
Expand Down
10 changes: 8 additions & 2 deletions docs/BlazorApexCharts.Docs/BlazorApexCharts.Docs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
<ItemGroup>
<PackageReference Include="Bogus" Version="35.4.1" />
<PackageReference Include="ColorCode.HTML" Version="2.0.15" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="TabBlazor" Version="0.12.2-alpha" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Blazor-ApexCharts\Blazor-ApexCharts.csproj" />
</ItemGroup>

<ItemGroup>
<Content Update="Components\ChartService\Usage.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@page "/chart-service"


<DocExamples Title="Chart Service">
<Description>
ApexChartService is a service that will manage global options, set locales, manage charts on the screen.
</Description>

<ChildContent>
<CodeContainer Title="Installation">
<Installation />
</CodeContainer>
<CodeContainer Title="Usage">
<Usage />
</CodeContainer>
</ChildContent>

</DocExamples>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

<p>
Add Chart Service to the DI container by using the extension AddApexCharts().
This will add a scoped IApexChartService to the container.
</p>

<CodeFormatter Code="@codeMinimal" />
Or, optional add global options
<CodeFormatter Code="@codeGlobalOptions" />




@code {

private string codeMinimal = @"services.AddApexCharts();";


private string codeGlobalOptions = @"services.AddApexCharts(e =>
{
e.GlobalOptions = new ApexChartBaseOptions
{
Debug = true,
Theme = new Theme { Palette = PaletteType.Palette6 }
};
});";


}
Loading
Loading