简体   繁体   English

如何在Asp.Net MVC中显示饼图?

[英]How do I show pie chart in Asp.Net MVC?

I'm trying to show a chart in Asp.Net MVC but it always open in another window. 我试图在Asp.Net MVC中显示一个图表,但它总是在另一个窗口中打开。 I want to show it without opened another window, in the same window. 我想在没有打开另一个窗口的情况下在同一窗口中显示它。

How could I do it ? 我怎么能这样做?

_GraficoPerformance _GraficoPerformance

@model ResumoMovtoTrades

<div class="text-center">
    <p>
        @{ 
            var macChart = new Chart(200,200)
               .AddTitle("Performance")
               .AddSeries(
                name: "Performance",
                chartType: "Pie",
                legend: "Performance",
                xValue: new[] { "Gain", "Loss" },
                yValues: new[] { Model.qtdGain, Model.qtdLoss })
            .Write();
        }
    </p>
</div>

Show _PartialView 显示_PartialView

<div class="panel panel-blue">
            <div class="panel-heading bg-blue">Gráfico de Performance</div>
            <div class="panel-body">
               <img src="@Html.Partial("_GraficoPerformance", @Model.resumoMovtos)"/>
            </div>
        </div><!--/panelchart-->

I decided to use a jquery library to show the graphic and it works well. 我决定使用jquery库来显示图形,它运行良好。

I used this: https://www.chartjs.org/docs/latest/ 我用过这个: https//www.chartjs.org/docs/latest/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM