簡體   English   中英

Syncfusion餅圖錯誤

[英]Syncfusion Pie chart error

我有一個餅圖的要求。 我使用syncfusion,並在.aspx頁中注冊,並在.aspx.cs頁中使用庫。 雖然我嘗試運行它顯示錯誤。 我該如何解決? 在此處輸入圖片說明

我的.aspx代碼:

        <%@ Page Title="" Language="C#" 
         MasterPageFile="~/MasterPages/MasterPage.master" 
        AutoEventWireup="true" 
        CodeBehind="MasterReport.aspx.cs" 
        Inherits="AHS.LegalLink.UI.MasterReport" %>

  <%@ Register Assembly="Syncfusion.Shared.Web, Version=6.403.0.15, 
   Culture=neutral, PublicKeyToken=3d67ed1f87d44c89"
   Namespace="Syncfusion.Web.UI.WebControls.Shared" TagPrefix="syncfusion" 
    %>
    <%@ Register Assembly="Syncfusion.Grid.Grouping.Web, Version=6.403.0.15, 
    Culture=neutral, PublicKeyToken=3d67ed1f87d44c89"
     Namespace="Syncfusion.Web.UI.WebControls.Grid.Grouping" 
      TagPrefix="syncfusion" %>
      <%@ Register Assembly="Syncfusion.Tools.Web, Version=6.403.0.15, 
       Culture=neutral, PublicKeyToken=3d67ed1f87d44c89"
      Namespace="Syncfusion.Web.UI.WebControls.Tools" TagPrefix="syncfusion" 
      %>
      <%@ Register Assembly="Syncfusion.Shared.Web, Version=6.403.0.15, 
      Culture=neutral, PublicKeyToken=3d67ed1f87d44c89"
      Namespace="Syncfusion.Web.UI.WebControls.Shared" 
      TagPrefix="syncfusion" 
       %>
      <%@ Register Assembly="Syncfusion.Shared.Web, Version=6.403.0.15, 
       Culture=neutral, PublicKeyToken=3d67ed1f87d44c89"
      Namespace="Syncfusion.Web.UI.WebControls.Shared" 
       TagPrefix="syncfusion" %>
       <%@ Register Assembly="Syncfusion.Chart.Web, Version=6.403.0.15, 
        Culture=neutral, PublicKeyToken=3d67ed1f87d44c89"
         Namespace="Syncfusion.Web.UI.WebControls.Chart" 
         TagPrefix="syncfusion" %>

     <td class="LabelCol">
                     <syncfusion:ChartWebControl ID="mastReportChart" runat="server" Width="550px" Height="350px"
                                ChartArea-BackColor="Blue">
                                <Legend Style="position: absolute; display: block; left: 0px; top: 10px; width: 77px;
                                    height: 28px; z-index: 300;"></Legend>
                                <ToolBar Caption="ToolBar">
                                </ToolBar>
                                <%--<PrimaryXAxis LineType-BackColor="Pink" />--%>
                               <ChartArea TextRenderingHint="SystemDefault" ID="ChartArea31" BackColor="Brown">
                                    <ChartAreaMargins Bottom="0" Right="20"></ChartAreaMargins>
                                    <ChartPlotAreaMargins Bottom="0" Right="20"></ChartPlotAreaMargins>
                            </ChartArea>
                       </syncfusion:ChartWebControl>
                </td>
    </tr>
  </table>

我的代碼背后:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
 using System.Web.UI.HtmlControls;
  using System.Drawing;
  using System.Drawing.Drawing2D;
 using AHS.LegalLink.BO;
 using Syncfusion.Web.UI;
 using Syncfusion.Drawing;
using Syncfusion.Windows.Forms.Chart;
 using Syncfusion.Web.UI.WebControls.Chart;
  using Syncfusion.Web.UI.WebControls.Shared;
   using AHS.Core;
  using System.Collections.Generic;
  using AHS.Web.Core;



  namespace AHS.LegalLink.UI
     {
       public partial class MasterReport : BasePage
       {

      #region page events
        protected void Page_Load(object sender, EventArgs e)
        {

            InitializeControlBar();
        }

  #endregion
  #region methods
    public void InitializeControlBar()
    {

        this.mastReportChart.Legend.Visible = true;

        this.mastReportChart.BorderAppearance.FrameThickness = new Syncfusion.Windows.Forms.Chart.ChartThickness(1F, 1F, 2F, 2F);
        this.mastReportChart.BorderAppearance.Interior.ForeColor = System.Drawing.Color.Red;
        this.mastReportChart.BorderAppearance.Interior.Width = 1F;
        this.mastReportChart.BorderAppearance.SkinStyle = ChartBorderSkinStyle.Frame;
        this.mastReportChart.BorderAppearance.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(209)))), ((int)(((byte)(220)))), ((int)(((byte)(231)))));

        this.mastReportChart.BackInterior = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(193))))), System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(242)))), ((int)(((byte)(226))))));
        this.mastReportChart.ChartArea.BackInterior = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.Color.Transparent, System.Drawing.Color.Transparent);
        this.mastReportChart.ChartInterior = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Horizontal, System.Drawing.Color.Transparent, System.Drawing.Color.Transparent);
        this.mastReportChart.BorderAppearance.SkinStyle = ChartBorderSkinStyle.Emboss;


        this.mastReportChart.BorderStyle = BorderStyle.None;
        this.mastReportChart.ElementsSpacing = 0;


        this.mastReportChart.AutoTempFileCleanUp = true;
        this.mastReportChart.OutputFormat = ImageProviderOutputFormat.DiskFile;

        DataSet ds = new AgreementCollection().LoadAllMasterReportData(Convert.ToDateTime(ddcFromDate.Text), Convert.ToDateTime(ddcToDate.Text));

           ChartSeries series1 = new ChartSeries("LegalLink");
           series1.Type = ChartSeriesType.Pie;
            series1.ConfigItems.PieItem.LabelStyle = ChartAccumulationLabelStyle.Inside;
            series1.ConfigItems.PieItem.PieWithSameRadius = true;
            this.mastReportChart.Series.Add(series1);

            for (int i = 0; i < series1.Points.Count; i++)
                series1.Styles[i].Border.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;

            double xValue = 0;
            foreach (DataRow myRow in ds.Tables[0].Rows)
            {
                double totala = Convert.ToInt32(myRow["Total"]);
                double totalna = Convert.ToInt32(myRow["Department"]);
                series1.Points.Add(xValue, totala);
                xValue++;
                series1.Points.Add(xValue, totalna);
                series1.Styles[0].Text = "(Amend," + series1.Points[0].YValues[0] + "%)";
                series1.Styles[1].Text = "Renew";


            }
            series1.Style.DisplayText = true;
            series1.LegendItem.Visible = true;
            series1.LegendName = "MyLedgend";

            ChartLegendItem item1 = new ChartLegendItem();

            item1.Text = "Amend:" + ds.Tables[0].Rows[0]["Amend"].ToString() + " mn"; ;
            item1.ItemStyle.TextColor = Color.DarkMagenta;
            item1.ItemStyle.ShowSymbol = true;
            item1.ItemStyle.Symbol.Color = Color.AliceBlue;
            item1.ItemStyle.Interior = new BrushInfo(GradientStyle.Horizontal, color2);
            item1.ItemStyle.Symbol.Shape = ChartSymbolShape.Cross;

            ChartLegendItem item2 = new ChartLegendItem();

            item2.Text = "Renew:" + ds.Tables[0].Rows[0]["Renew"].ToString() + " mn";
            item2.ItemStyle.TextColor = Color.DarkMagenta;
            item2.ItemStyle.ShowSymbol = true;
            item2.ItemStyle.Symbol.Color = Color.AliceBlue;
            item2.ItemStyle.Interior = new BrushInfo(GradientStyle.Horizontal, color3);
            item2.ItemStyle.Symbol.Shape = ChartSymbolShape.Cross;


            this.mastReportChart.Legend.CustomItems = new ChartLegendItem[] { item1, item2 };
            // Adding it into chart legend
            #endregion

            this.mastReportChart.Text = "LegalLink";
            // this.TargetVSSavingGraph.Font.Bold = true;

            this.mastReportChart.TextAlignment = StringAlignment.Near;
            this.mastReportChart.Series[0].ConfigItems.PieItem.PieType = ChartPieType.None;
            this.mastReportChart.Series[0].ConfigItems.PieItem.FillMode = ChartPieFillMode.AllPie;
            this.mastReportChart.Series[0].ConfigItems.PieItem.HeightByAreaDepth = false;
            this.mastReportChart.Series[0].ConfigItems.PieItem.HeightCoeficient = 0.1f;
            //this.mastReportChart.Series[0].PrepareStyle += new ChartPrepareStyleInfoHandler(series_PrepareStyle);

    }
    private void series_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
    {
        ChartSeries series = sender as ChartSeries;
        if (series != null)
        {

            if (series.Points[args.Index].YValues[0] > 200)
            {
                args.Style.Interior = new Syncfusion.Drawing.BrushInfo(GradientStyle.Vertical, Color.Green, Color.Green);
                args.Style.Border.Color = Color.Green;
            }
            else
            {
                args.Style.Interior = new Syncfusion.Drawing.BrushInfo(GradientStyle.Vertical, Color.Red, Color.Red);
                args.Style.Border.Color = Color.Red;
            }
        }
    }

我們已經分析了查詢。 我們已嘗試使用提供的代碼段復制報告的方案,但是很遺憾,我們無法復制該方案,因為我們懷疑在您的末端未在web.config文件中正確引用了程序集。 我們准備了一個示例,其中已針對您的代碼段繪制了餅圖。 由於我們不知道您的數據源,因此我們將隨機數據提供給圖表並進行了渲染。 請按照以下步驟呈現圖表。

下面列出了呈現圖表控件所需的DLL。

  • Syncfusion.Core.dll
  • Syncfusion.Chart.Base.dll
  • Syncfusion.Chart.Web.dll
  • Syncfusion.Shared.Base.dll
  • Syncfusion.Shared.Web.dll
  • Syncfusion.Tools.Web.dll

然后在Web.config文件中添加以下名稱空間。

<configuration> 
  <system.web> 
    <compilation > 
      <assemblies> 
        <add assembly="Syncfusion.Chart.Web" /> 
        <add assembly="Syncfusion.Chart.Base" /> 
        <add assembly="Syncfusion.Shared.Web" /> 
        <add assembly="Syncfusion.Tools.Web" /> 
        <add assembly="Syncfusion.Shared.Base" /> 
        <add assembly="Syncfusion.Core" /> 
      </assemblies> 
    </compilation> 
  </system.web> 
</configuration> 

在Web.config文件中添加處理程序以在網頁中呈現圖表。

<handlers> 
      <add name="syncfusion_generate" path="syncfusion_generate.ashx" verb="*"  
                type="Syncfusion.Web.UI.WebControls.Chart.ChartWebHandler,Syncfusion.Chart.Web"/> 
</handlers> 

供參考的樣本可以從下面找到。

樣本鏈接

屏幕截圖: 圖片

由於我們不知道您重現該問題的確切情況,因此,我們想了解以下詳細信息,以便我們盡快為您提供解決方案。

  • 修改附件的樣本或為您的樣本提供復制步驟。
  • 您正在使用的當前版本的Essential Studio。

有關安裝的更多信息,請點擊以下鏈接。

幫助Documnet

謝謝,達拉尼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM