基本信息
源码名称:.net core 调用Nodejs函数(INodeServices)绘图示例源码
源码大小:1.22M
文件格式:.zip
开发语言:C#
更新时间:2018-09-17
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.NodeServices;
using ServerSideRendering.Models;
namespace ServerSideRendering.Controllers
{
public class HomeController : Controller
{
public async Task<IActionResult> Index([FromServices] INodeServices nodeServices)
{
var chartOptions = new
{
width = 500,
height = 250,
showArea = true
};
// for line chart
var data = new
{
// x-axis
labels = new[] {"Q1", "Q2", "Q3", "Q4"},
// y-axis
series = new[]
{
new[] {70, 80, 60, 100},
new[] {88, 90, 99, 66},
new[] {100, 80, 60, 111}
}
};
var lineResult = await nodeServices.InvokeAsync<string>( "./JavaScripts/demo" ,
"line", chartOptions, data);
ViewData["lineResult"] = lineResult;
// for pie chart
var data2 = new { series = new[]
{
new {name = "New York", value = 20},
new {name = "Boston", value = 20},
new {name = "San Francisco", value = 55},
new {name = "Charlotte", value = 5}
}
};
var pieResult = await nodeServices.InvokeAsync<string>( "./JavaScripts/demo" ,
"pie" , chartOptions , data2 );
ViewData["pieResult"] = pieResult;
return View();
}
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}