簡體   English   中英

ASP.NET 條形圖標簽

[英]ASP.NET Bar Chart labels

在我的項目中,我有一個包含 12 個條形圖的條形圖。 該圖表每 2 條柱線顯示一次 x 軸標簽。 我想要每個酒吧的標簽。 我怎樣才能做到這一點 ?

public ActionResult TekenGrafiek(ApplicationUser user, string naam)
    {
        Product p = user.Verlanglijst.Producten.First(pr=>pr.Artikelnaam == naam);
        int totaal = p.AantalInCatalogus;
        DateTime[] weken = new DateTime[12];
        int[] aantal = new int[12];
        DateTime nu = DateTime.Now.StartOfWeek(DayOfWeek.Monday);
        for (int j = 0; j < 11; j++)
        {
            weken[j] = nu;
            aantal[j] = p.GeefAantalReserveerbaarInPeriode(nu, nu.AddDays(7));
            nu = nu.AddDays(7);
        }
        Bitmap image = new Bitmap(300, 50);
        Graphics g = Graphics.FromImage(image);
        Chart c = new Chart();
        ChartArea a = new ChartArea();

        a.AxisX.MajorGrid.Enabled = false;
        a.ShadowColor = Color.DeepSkyBlue;
        a.BackColor = Color.AliceBlue;
        c.Titles.Add("Aantal beschikbaar komende weken");
        c.ChartAreas.Add(a);
        c.Width = 1000;
        c.Height = 250;
        Series mySeries = new Series();
        mySeries.Points.DataBindXY(weken, aantal);
        mySeries.IsValueShownAsLabel = true;
        c.Series.Add(mySeries);

        MemoryStream imageStream = new MemoryStream();
        c.SaveImage(imageStream, ChartImageFormat.Png);
        c.TextAntiAliasingQuality = TextAntiAliasingQuality.SystemDefault;
        Response.ContentType = "image/png";
        imageStream.WriteTo(Response.OutputStream);
        g.Dispose();
        image.Dispose();
        return null;
    }

代碼是用 C# ASP.NET MVC 編寫的。這是此時的圖表在此處輸入圖片說明

之前也有人問過類似的問題
嘗試使用

a.AxisX.Interval = 1;

我相信它會有所幫助。 祝你好運。

暫無
暫無

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

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