/我正在尝试创建一个简单的 RadHTMLChart(烛台),它工作正常,但由于某种原因,它在我的数据集之间创建了我不想要的日期。例如,我的数据集有 9/17 的记录,但没有 9/18 的记录。
这是原始数据:
- 日期 开盘 高 低 收盘 调整 收盘** 成交量
- 2021 年 10 月 8 日 8.82 11.91 8.22 11.72 11.72 65,867,500
- 2021 年 10 月 7 日 8.07 8.95 7.87 8.04 8.04 15,318,000
- 2021 年 10 月 6 日 8.08 8.45 7.14 7.36 7.36 11,200,000
- 2021 年 10 月 5 日 11.82 12.08 7.38 8.90 8.90 27,974,800
- 2021 年 10 月 4 日 12.00 12.90 11.30 11.69 11.69 6,074,900
- 2021 年 10 月 1 日 13.60 13.67 10.92 11.93 11.93 8,886,900
- 2021 年 9 月 30 日 14.33 14.79 12.92 13.65 13.65 18,243,800
- 2021 年 9 月 29 日 14.17 18.50 12.42 12.93 12.93 53,669,800
- 2021 年 9 月 28 日 11.35 14.64 10.71 14.61 14.61 28,911,400
- 2021 年 9 月 27 日 10.70 12.43 10.61 11.53 11.53 11,621,300
- 2021 年 9 月 24 日 9.98 12.19 9.68 10.99 10.99 22,569,700
- 2021 年 9 月 23 日 8.31 10.39 7.88 10.29 10.29 19,234,100
- 2021 年 9 月 22 日 7.86 8.93 7.85 8.55 8.55 11,615,300
- 2021 年 9 月 21 日 7.62 8.05 7.35 7.80 7.80 3,369,000
- 2021 年 9 月 20 日 7.10 8.07 7.00 7.54 7.54 5,259,300
- 2021 年 9 月 17 日 8.09 9.13 7.35 7.35 7.35 16,531,500
- 2021 年 9 月 16 日 7.04 7.70 6.80 7.68 7.68 3,596,700
- 2021 年 9 月 15 日 7.19 7.37 6.83 7.17 7.17 2,438,100
这是代码,但没什么特别的,如何删除这些空白日期?
string file = @"M:\data.txt";
string[] lines = File.ReadAllLines(file);
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Date", System.Type.GetType("System.DateTime")));
dt.Columns.Add(new DataColumn("High", System.Type.GetType("System.Decimal")));
dt.Columns.Add(new DataColumn("Low", System.Type.GetType("System.Decimal")));
dt.Columns.Add(new DataColumn("Open", System.Type.GetType("System.Decimal")));
dt.Columns.Add(new DataColumn("Close", System.Type.GetType("System.Decimal")));
for (int i = 0; i < lines.Length; i++)
{
string[] split = lines[i].Split('\t');
if(i == 0)
{
/*for (int r = 0; r < split.Length; r++)
dt.Columns.Add(split[r]);*/
continue;
}
DataRow dr = dt.NewRow();
dr["Date"] = split[0];
dr["High"] = split[2];
dr["Low"] = split[3];
dr["Open"] = split[1];
dr["Close"] = split[4];
dt.Rows.Add(dr);
}
dt.DefaultView.Sort = "Date asc";
CandlestickChart.DataSource = dt;
CandlestickChart.DataBind();
<telerik:RadHtmlChart runat="server" ID="CandlestickChart" Skin="Silk"
Transitions="true" OnDataBound="CandlestickChart_DataBound">
<ChartTitle Text="">
<Appearance Align="Center" Position="Top">
</Appearance>
</ChartTitle>
<Legend>
<Appearance Position="Bottom">
</Appearance>
</Legend>
<PlotArea>
<XAxis DataLabelsField="Date" BaseUnit="Days" Justified="false" Step="1"></XAxis>
<Series>
<telerik:CandlestickSeries DownColor="Red" DataCloseField="Close" DataOpenField="Open" DataLowField="Low" DataHighField="High">
<Appearance>
<FillStyle BackgroundColor="Green"></FillStyle>
</Appearance>
<TooltipsAppearance BackgroundColor="LightGray"></TooltipsAppearance>
</telerik:CandlestickSeries>
</Series>
</PlotArea>
</telerik:RadHtmlChart>