我使用System.Web.UI.DataVisualization.Charting创建了一个图表。这些图表显示在Google Chrome和safari上。但这在Windows XP IE8上不可见。我真的不知道如何解决这个问题。
这是我创建图表时的代码段。
<img src="/ConvertFiles/CreateActualsVsForecastChart/?actuals=@(thisMonth)&forecast=@(prevMonth)" />
public FileResult CreateActualsVsForecastChart(string actuals, string forecast, string chartName)
{
//IList<ResultModel> peoples = _resultService.GetResults();
if (actuals.Equals(""))
actuals = "0";
if (forecast.Equals(""))
forecast = "0";
Chart chart = new Chart();
chart.Width = 350;
chart.Height = 400;
chart.BackColor = Color.FromArgb(211, 223, 240);
chart.BorderlineDashStyle = ChartDashStyle.Solid;
chart.BackGradientStyle = GradientStyle.TopBottom;
chart.BorderlineWidth = 1;
chart.Palette = ChartColorPalette.BrightPastel;
chart.BorderlineColor = Color.FromArgb(26, 59, 105);
chart.RenderType = RenderType.BinaryStreaming;
chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
chart.AntiAliasing = AntiAliasingStyles.All;
chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal;
chart.Titles.Add(CreateTitle(chartName));
chart.Legends.Add(CreateLegend());
chart.Series.Add(CreateSeries4(new List<ChartKeyValue>()
{
new ChartKeyValue(){ Lable = "Forecast", Value = Convert.ToDouble(forecast), IsCurrent=true},
}, SeriesChartType.Column, "Forecast", "pink"));
chart.Series.Add(CreateSeries4(new List<ChartKeyValue>()
{
new ChartKeyValue(){ Lable = "Actual", Value = Convert.ToDouble(actuals), IsCurrent=true}
}, SeriesChartType.Column, "Actual", "blue"));
chart.ChartAreas.Add(CreateChartArea());
MemoryStream ms = new MemoryStream();
chart.SaveImage(ms);
return File(ms.GetBuffer(), @"image/png");
}
有关导致此操作无法在IE8上显示的任何想法?感谢。
答案 0 :(得分:1)
在对此疯狂之后,我发现IE8在创建图表时没有调整父容器的大小。 您需要将其明确地放在DOM中。 例如:
<div>
<asp:Chart ID="Chart1" runat="server" SuppressExceptions="True" Width="1000px" Height="600px">
</asp:Chart>
</div>
不会在IE8中呈现任何内容(div的宽度将为0px),但是:
<div style="width: 1100px">
<asp:Chart ID="Chart1" runat="server" SuppressExceptions="True" Width="1000px" Height="600px">
</asp:Chart>
</div>
意愿。只需将容器宽度设置为大于图表宽度的某个像素。