Blazor.ECharts
1.0.7
dotnet add package Blazor.ECharts --version 1.0.7
NuGet\Install-Package Blazor.ECharts -Version 1.0.7
<PackageReference Include="Blazor.ECharts" Version="1.0.7" />
<PackageVersion Include="Blazor.ECharts" Version="1.0.7" />
<PackageReference Include="Blazor.ECharts" />
paket add Blazor.ECharts --version 1.0.7
#r "nuget: Blazor.ECharts, 1.0.7"
#:package Blazor.ECharts@1.0.7
#addin nuget:?package=Blazor.ECharts&version=1.0.7
#tool nuget:?package=Blazor.ECharts&version=1.0.7
Blazor.ECharts
介绍
Blazor版本的ECharts图表组件
重新出发
本项目源自https://github.com/caopengfei/BlazorECharts,由于原作者有好长一段时间没有更新和处理PR,故在此基础上,重新做了这个
开源地址:https://github.com/lishewen/Blazor.ECharts
国内镜像:https://gitee.com/lishewen/Blazor.ECharts
ECharts配置请参考:
https://echarts.apache.org/examples/zh/index.html
使用方式
- 创建Blazor项目。
- 在NuGet中安装包
Blazor.ECharts。
- 在
_Imports.razor中添加@using Blazor.ECharts.Components。 - 在
wwwroot/index.html文件的Head中引入:
<script src="https://cdn.bootcdn.net/ajax/libs/echarts/6.1.0/echarts.min.js"></script>
选项模型按照 ECharts 6.1 的配置项手册补全。手册中标注"从 v6.0.0 开始支持"的配置项(matrix、thumbnail 等)在 5.x 中不可用。
需要使用地图相关功能的则需要额外添加地图js的引用
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=[Your Key Here]"></script>
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/echarts/6.1.0/extension/bmap.min.js"></script>
- 在
wwwroot/index.html文件的Body中引入:
<script type="module" src="_content/Blazor.ECharts/core.js"></script>
- 修改
Program.cs增加
builder.Services.AddECharts();
- 在页面中使用组件(可参考Demo项目)。
注意:因为没有设置默认的样式,所以需要在组件上设置Class或者Style来控制宽度和高度
Demo中也提供示范样式
.chart-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
padding-left: 20px;
padding-bottom: 20px;
padding-right: 0px;
padding-top: 0px;
height: 95%;
width: 95%;
}
.chart-normal {
border-radius: 4px;
height: 300px;
width: 400px;
margin-top: 20px;
}
.chart-fill {
width: 100%;
height: 720px;
margin-top: 20px;
margin-right: 20px;
}
JS function的输出问题
由于function不是json的标准数据类型,所以json数据中若含function,则转换后,function会丢失。此库为解决这个问题通过JFuncConverter来实现转译输出。使用时传入一个JFunc对象即可。例如:
Position = new JFunc()
{
RAW = """
function (pt) {
return [pt[0], '10%'];
}
"""
}
功能实现进度
选项模型按照 ECharts 配置项手册 的数据核对并补全:手册里列出的组件、系列和配置项,在 Blazor.ECharts.Options 下都有对应的类型或属性。补全的部分位于 Blazor.ECharts/Options/Generated,属性的 XML 注释取自手册,并附有文档链接。
data 数据项的内部结构、rich 富文本、格式化函数等取值形态不固定的配置保持为 object,按手册中的写法直接赋值即可。
- 公共配置
- title
- legend
- grid
- xAxis
- yAxis
- polar
- radiusAxis
- angleAxis
- radar
- dataZoom
- visualMap(
VisualMapContinuous/VisualMapPiecewise) - tooltip
- axisPointer
- toolbox
- brush
- geo
- parallel
- parallelAxis
- singleAxis
- timeline
- graphic
- calendar
- dataset
- aria
- matrix(v6)
- thumbnail(v6)
- series
- color / backgroundColor / textStyle
- animation / animationThreshold / animationDuration / animationEasing / animationDelay
- animationDurationUpdate / animationEasingUpdate / animationDelayUpdate / stateAnimation
- blendMode / hoverLayerThreshold / useUTC / darkMode / media
- 图表
- 折线图 line
- 柱状图 bar
- 饼图 pie
- 散点图 scatter
- 涟漪散点图 effectScatter(
EEffectScatter) - 地理坐标/地图 map
- K线图 candlestick
- 雷达图 radar
- 盒须图 boxplot
- 热力图 heatmap(
EHeatmap) - 关系图 graph
- 路径图 lines
- 树图 tree
- 矩形树图 treemap
- 旭日图 sunburst
- 平行坐标系 parallel(
EParallel) - 桑基图 sankey
- 漏斗图 funnel
- 仪表盘 gauge
- 象形柱图 pictorialBar(
EPictorialBar) - 主题河流图 themeRiver(
EThemeRiver) - 和弦图 chord(
EChord) - 自定义系列 custom(
ECustom) - 词云图(使用方法:Blazor.ECharts.WordCloud/README.md)
Nuget Package中没有打包echarts.js的原因
- 减少包的体积
- 方便自由更换cdn
- 方便echarts小版本更新时,作者没有来得及更新Package内的js时,可自行在页面上更换
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.15)
-
net11.0
- Microsoft.AspNetCore.Components.Web (>= 11.0.0)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.34)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.23)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Blazor.ECharts:
| Package | Downloads |
|---|---|
|
Blazor.ECharts.WordCloud
Blazor版本的ECharts词云组件 开源地址:https://github.com/lishewen/Blazor.ECharts 使用方式见Demo项目 |
|
|
Ruth.JYC.ELSA.RazorLib
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.7 | 61 | 11/28/2026 |
| 1.0.6 | 2,685 | 11/27/2025 |
| 1.0.5 | 4,318 | 4/2/2025 |
| 1.0.4 | 4,021 | 11/18/2024 |
| 1.0.3 | 1,791 | 7/4/2024 |
| 1.0.2 | 2,496 | 3/17/2024 |
| 1.0.1 | 557 | 1/21/2024 |
| 1.0.0 | 725 | 1/10/2024 |
| 0.9.9 | 411 | 1/10/2024 |
| 0.9.8 | 915 | 11/17/2023 |
| 0.9.7 | 1,280 | 8/9/2023 |
| 0.9.6 | 474 | 7/26/2023 |
| 0.9.5 | 673 | 6/15/2023 |
| 0.9.4 | 479 | 5/24/2023 |
| 0.9.3 | 759 | 5/4/2023 |
| 0.9.2 | 385 | 5/4/2023 |
| 0.9.1 | 452 | 4/22/2023 |
| 0.9.0 | 394 | 4/20/2023 |
| 0.8.9 | 421 | 4/19/2023 |
| 0.8.8 | 436 | 4/19/2023 |