0
가로 막 대형 차트를 그릴 때 일부 항목이 X 축에 제대로 플롯되지 않는 반면 동등한 Y 축은 문제가 없습니다. 내 사용자 정의 컨트롤 코드를 다음했다 .NET 막대 차트 올바르게 플롯되지 않음
,
<asp:Chart ID="Chart1" runat="server" Width="850px" Height="600px">
<Series>
<asp:series Name="Series1"></asp:series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
코드 데이터 테이블을 채우는
,protected DataTable GetGroupExperienceData(PickerEntity pickerEntity)
{
DataTable table;
table = new DataTable();
table.Columns.Add("Participant", typeof(string));
table.Columns.Add("Experience", typeof(Int32));
table.Columns.Add("Question", typeof(string));
DataRow row;
if (collListItems2.Count > 0 && collListItems2 != null)
{
for (int i = 0; i < collListItems2.Count; i++)
{
row = table.NewRow();
row["Participant"] = user.Name;
SPFieldLookupValue lpkFieldQName = new SPFieldLookupValue(itemRep["SurveyQuestion"].ToString());
string lkpQNameVal = lpkFieldQName.LookupValue;
row["Question"] = lkpQNameVal;
SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("(Error)", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ">" + row["Question"].ToString(), "");
if (itemRep["Experience"] !=null)
{
row["Experience"] = itemRep["Experience"];
}
else
{
row["Experience"] = Convert.ToInt32("0");
}
table.Rows.Add(row);
}
}
return dt;
}
마지막
protected void DrawExperienceChart(DataTable dt)
{
Chart1.Series["Series1"].ChartType = SeriesChartType.Bar;
Chart1.Series["Series1"]["DrawingStyle"] = "Emboss";
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
Chart1.Series["Series1"].IsValueShownAsLabel = true;
Chart1.DataSource = dt;
Chart1.Series["Series1"].XValueMember = "Question";
Chart1.Series["Series1"].YValueMembers = "Experience";
Chart1.DataBind();
}
이러한 모든 기능
가 버튼에서 호출, 그리기 코드를 차트 클릭,protected void btnGetReport_Click(object sender, EventArgs e)
{
DataTable dt = GetGroupExperienceData(pickerEntity);
DrawExperienceChart(dt);
}
다음은 출력입니다. X asix에는 많은 "Questions"데이터가 있지만 Y 축에는 동등한 "Experience"가 잘 그려져 있습니다. 나는 데이터 테이블 있지만 데이터 테이블에 오지 않아 데이터가 될 수있다 생각
내가 SPDiagnosticsService.Local.WriteTrace()
를 사용하여 참조 할 수있는 데이터,