tags:

views:

90

answers:

1

Hi Guys

I can not seem to get the legend to apear in this chart.

 public ActionResult ServerityGraphicalSummaryReport()
    {
        Chart chart = new Chart();
        chart.Height = 296;
        chart.Width = 412;
        chart.ImageType = ChartImageType.Png;
        chart.Palette = ChartColorPalette.Excel;
        chart.BackColor = Color.White;
        chart.RenderType = RenderType.BinaryStreaming;
        chart.AntiAliasing = AntiAliasingStyles.All;
        chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal;

        Series series1 = chart.Series.Add("Series1");
        series1.ChartType = SeriesChartType.Column;
        series1.YValueType = ChartValueType.Int32;

        foreach(var item in new DataAccess.MaterialIncidentRepository().GetItems())
        {
            if (item.Incident.Serverities.Count > 0)
            {
                string legendText = item.Incident.Supplier.Name;
                Double dataValue = (double)item.Incident.Serverities[0].Score;
                DataPoint point = new DataPoint();
                point.LegendText = legendText;
                point.SetCustomProperty("LegendText", legendText);
                point.YValues = new double[] { dataValue };
                series1.Points.Add(point);
            };
        }

        ChartArea chartArea = chart.ChartAreas.Add("Default");
        chartArea.BackColor = Color.Transparent;
        chartArea.BorderColor = Color.LightBlue;
        chartArea.AxisX.IsMarginVisible = true;
        chartArea.Area3DStyle.Enable3D = false;

        MemoryStream ms = new MemoryStream();
        chart.SaveImage(ms);
        return File(ms.GetBuffer(), @"image/png");
    }
A: 

You have to set AxisLabel on the point