我在asp.net中创建了一个柱形图。我在x轴上显示日期。目前日期显示为dd / mm / yyyy。我只需要将日期显示为dd-mm-yy,理想情况是工作日,dd-mm-yy例如星期一,12-05-15。
<asp:Chart ID="Chart1" runat="server" Height="400px" Width="900px" BorderWidth = "1">
<Series>
<asp:Series Name="Series1" XValueMember="uploaded_date" YValueMembers="value" ChartArea="ChartArea1" ChartType="Line" YValuesPerPoint="6" BorderWidth="6" >
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<AxisY Title="Quantity" TitleForeColor="#ff0000" Interval="20">
<MajorGrid Enabled ="true" />
</AxisY>
<AxisX Title="Date" IsLabelAutoFit="True" TitleForeColor="#ff0000">
<MajorGrid Enabled ="False" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
答案 0 :(得分:1)
使用格式:
public static void main(String[] args) {
int[] a = { 1, 2, 3, 4, 5 };
int[] b = { 6, 7 };
ArrayList<Pair> pairs = new ArrayList<>();
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < b.length; j++) {
pairs.add(new Pair(a[i], b[j]));
}
}
Collections.shuffle(pairs);
Pair[] asArray = pairs.toArray(new Pair[0]); //if you prefer array over ArrayList
}
class Pair {
int a, b;
public Pair(int a, int b) {
this.a = a;
this.b = b;
}
}
输出:
DateTime.Now.ToString("dddd, dd-MM-yy");
要编辑轴标签,您可以在代码隐藏文件中执行此操作:
Montag, 15-06-15 //Written day of week in your local culture.
或者在你的标记中:
Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "dddd, dd-MM-yy";
参考:https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
答案 1 :(得分:0)
您可以使用以下内容:
将此放在aspx页面(html端)
<asp:Literal runat="server" ID="ltrDate"/>
并在backend(cs文件)的page_load中使用它
ltrDate.Text = DateTime.Now.ToString("ddd") + ", " + DateTime.Now.ToString("dd-MM-yy");