Я изменяю программу с использованием Visual Studio 2015 и создал диаграмму с форматированием метки, заданным как:
this.chart1.ChartAreas [0] .AxisX.LabelStyle.Format = "mm: ss ";
Однако на некоторых значениях диаграмма отображается без начальных нулей. См. ниже; «3:07» отображается как «3: 7», et c. Я не волшебник c#, поэтому заранее спасибо за любую помощь!
public string makeCharLabel(double chartTime)
{
string labelBuild;
labelBuild = (((int)(chartTime)) - ((int)(chartTime / 60) * 60)).ToString();
if (labelBuild == "0")
{
labelBuild = "00";
}
labelBuild = ((int)(chartTime/60)).ToString() + ":" + labelBuild;
return labelBuild;
}
{
double chartIncrement;
// holdInterval = 150;
// NumberOfCycles = 3;
chartIncrement = 0;
chart1.Series[0].Points.Clear();
chart1.Series[1].Points.Clear();
chart1.Series[2].Points.Clear();
chart1.Series[3].Points.Clear();
chart1.Series[3].BorderWidth = 5;
chart1.ChartAreas[0].AxisY.Interval = AppliedPressure / 4;
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisY.Minimum = -2 * AppliedPressure / 4;
chart1.ChartAreas[0].AxisY.Maximum = 6 * AppliedPressure / 4;
this.chart1.ChartAreas[0].AxisX.LabelStyle.Format = "mm:ss";
int chartcounter;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1* AppliedPressure/4);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1 * AppliedPressure / 4);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1 * AppliedPressure / 4);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1 * AppliedPressure / 4);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
for (chartcounter = 0; chartcounter < NumberOfCycles; chartcounter++)
{
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1 * AppliedPressure / 4);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1 * AppliedPressure / 4);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1 * AppliedPressure / 4);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
chartIncrement = chartIncrement + holdInterval / 4;
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 4 * AppliedPressure / 4);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", 6 * AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", 2 * AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", 6 * AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 5 * AppliedPressure / 4);
this.chart1.Series["Series4"].Points.AddXY("", 5 * AppliedPressure / 4);
this.chart1.Series["Series4"].Points.AddXY("", 5 * AppliedPressure / 4);
this.chart1.Series["Series4"].Points.AddXY("", 5 * AppliedPressure / 4);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
}
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1 * AppliedPressure / 4);
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1 * AppliedPressure / 4);
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), -1 * AppliedPressure / 4);
this.chart1.Series["Series1"].Points.AddXY(makeCharLabel(chartIncrement), 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series2"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series3"].Points.AddXY("", AppliedPressure / 4);
this.chart1.Series["Series3"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
this.chart1.Series["Series4"].Points.AddXY("", 0);
}
