我希望有人可以帮我理解这个图表行为。 基于下面的XML
<ChartData>
<ChartData Count="157">
<Year>2012</Year>
<MonthString>April</MonthString>
<Month>4</Month>
</ChartData>
<ChartData Count="196">
<Year>2012</Year>
<MonthString>May</MonthString>
<Month>5</Month>
</ChartData>
<ChartData Count="181">
<Year>2012</Year>
<MonthString>June</MonthString>
<Month>6</Month>
</ChartData>
<ChartData Count="222">
<Year>2012</Year>
<MonthString>July</MonthString>
<Month>7</Month>
</ChartData>
<ChartData Count="261">
<Year>2012</Year>
<MonthString>August</MonthString>
<Month>8</Month>
</ChartData>
<ChartData Count="163">
<Year>2012</Year>
<MonthString>September</MonthString>
<Month>9</Month>
</ChartData>
<ChartData Count="161">
<Year>2012</Year>
<MonthString>October</MonthString>
<Month>10</Month>
</ChartData>
<ChartData Count="181">
<Year>2012</Year>
<MonthString>November</MonthString>
<Month>11</Month>
</ChartData>
<ChartData Count="184">
<Year>2012</Year>
<MonthString>December</MonthString>
<Month>12</Month>
</ChartData>
<ChartData Count="227">
<Year>2013</Year>
<MonthString>January</MonthString>
<Month>1</Month>
</ChartData>
<ChartData Count="194">
<Year>2013</Year>
<MonthString>February</MonthString>
<Month>2</Month>
</ChartData>
<ChartData Count="177">
<Year>2013</Year>
<MonthString>March</MonthString>
<Month>3</Month>
</ChartData>
<ChartData Count="74">
<Year>2013</Year>
<MonthString>April</MonthString>
<Month>4</Month>
</ChartData>
</ChartData>
到这个C#图表代码
chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Interval = 1;
chart1.Series["Series1"].IsVisibleInLegend = false;
chart1.Series["Series1"].Font = new
System.Drawing.Font("Arial", 10.0F, System.Drawing.FontStyle.Italic);
chart1.Series[0].IsValueShownAsLabel = true;
chart1.Series["Series1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
chart1.DataBindCrossTable(chartgrouped, "Year", "MonthString", "Count", "");
当我查看图表时,我发现了两个不同的问题。
这是我用来查询数据并获取XML的查询
var chartgrouped = (from x in data group x by new { x.DateOpened.Month, x.DateOpened.Year } into g
select new ChartData
{
Year = g.Key.Year,
Month = g.Key.Month,
MonthString = string.Format("{0}",
CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(g.Key.Month)),
Count = g.Count()
}) .ToList();
这是我得到的屏幕截图