How do I position the legend below my chart? RRS feed

  • Question

  • using System;
    using System.Web.Helpers;
    using System.Web.Mvc;

    public ActionResult RespondentStatusChart(int id) {
                var data = dataDAO.GetData(id);
                var sent = (double)data.TotalSent;
                int notOpenedRate = (int)Math.Round((data.NotOpened / sent) * 100.0);
                int openedRate = (int)Math.Round((data.Opened / sent) * 100.0);
                int startedRate = (int)Math.Round((data.Started / sent) * 100.0);
                int completedRate = (int)Math.Round((data.Completed / sent) * 100.0);

                new Chart(width: 270, height: 300, theme: PurpleThemeWithLegend)
                        chartType: "Pie",
                        name: "Status",
                        xValue: new[] { $"Not Opened ({notOpenedRate}%)", $"Opened ({openedRate}%)", $"Started ({startedRate}%)", $"Completed ({completedRate}%)" }, xField: "%",
                        yValues: new[] { notOpenedRate, openedRate, startedRate, completedRate }, yFields: "Rate")
                return null;

    string PurpleThemeWithLegend = @"
            <Chart BackColor=""#6f42c1"" BackGradientStyle=""TopBottom"" BackSecondaryColor=""White"" BorderColor=""26, 59, 105"" BorderlineDashStyle=""Solid"" BorderWidth=""2"" Palette=""Berry"">
                    <ChartArea Name=""Default"" _Template_=""All"" BackColor=""64, 165, 191, 228"" BackGradientStyle=""TopBottom"" BackSecondaryColor=""White"" BorderColor=""64, 64, 64, 64"" BorderDashStyle=""Solid"" ShadowColor=""Transparent"">
                <BorderSkin SkinStyle=""Emboss"" />
                    <Legend _Template_=""All"" BackColor=""Transparent"" Font=""Trebuchet MS, 8.25pt, style=Bold"" IsTextAutoFit=""False"" /> 

    Monday, April 22, 2019 5:44 PM

All replies

  • Hi Alyson88,

    Thank you for posting here.

    Since your question is more related to MVC, you could post a new thread in MVC forum.


    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 23, 2019 1:58 AM