aspx code
<
asp:Panel
ID
=
"TrendPanel"
runat
=
"server"
Enabled
=
"True"
>
<
telerik:radchart
ID
=
"RadChart1"
runat
=
"server"
Height
=
"780px"
Width
=
"950px"
Skin
=
"Vista"
>
<
Appearance
Corners
=
"Round, Round, Round, Round, 7"
>
<
FillStyle
FillType
=
"ComplexGradient"
>
<
FillSettings
>
<
ComplexGradient
>
<
telerik:GradientElement
Color
=
"243, 253, 255"
/>
<
telerik:GradientElement
Color
=
"White"
Position
=
"0.5"
/>
<
telerik:GradientElement
Color
=
"243, 253, 255"
Position
=
"1"
/>
</
ComplexGradient
>
</
FillSettings
>
</
FillStyle
>
<
Border
Color
=
"212, 221, 222"
/>
</
Appearance
>
</
telerik:radchart
>
c# code
private
void
UpdateRadChart(wchart wc)
{
string
d1 = wc.d1.ToString(
"yyyy/MM/dd"
).Replace(
"."
,
"/"
);
string
d2 = wc.d2.ToString(
"yyyy/MM/dd"
).Replace(
"."
,
"/"
);
TrendPanel.Visible =
true
;
RadChart1.Visible =
true
;
RadChart1.Series.Clear();
RadChart1.Series.ClearItems();
RadChart1.PlotArea.XAxis.Items.Clear();
RadChart1.PlotArea.YAxis.Items.Clear();
RadChart1.PlotArea.YAxis.ScaleBreaks.Segments.Clear();
RadChart1.PlotArea.YAxis.ScaleBreaks.Enabled =
false
;
RadChart1.PlotArea.YAxis.AutoScale =
true
;
RadChart1.PlotArea.XAxis.AutoScale =
true
;
RadChart1.PlotArea.YAxis.Appearance.LabelAppearance.Visible =
true
;
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.AutoSize =
false
;
RadChart1.AutoLayout =
false
;
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Height = Telerik.Charting.Styles.Unit.Pixel(15);
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Width = Telerik.Charting.Styles.Unit.Pixel(150);
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Position.AlignedPosition = AlignedPositions.Top;
string
type = wc.type;
string
sqlString =
null
;
SqlConnection Conn = GetSqlConnection();
if
(type ==
"oil"
)
{
if
(wc.well == 0)
return
;
sqlString = @
"exec dbo.rwell "
+
"'"
+ d1 +
"', '"
+ d2 +
"', "
+ wc.well +
", 0"
;
SqlDataAdapter adapter =
new
SqlDataAdapter(sqlString, Conn);
DataSet ds =
new
DataSet();
adapter.Fill(ds);
ChartSeries currentSeries =
null
;
currentSeries = RadChart1.CreateSeries(
"нефть, м3"
, Color.Empty, Color.Empty, ChartSeriesType.SplineArea);
currentSeries.Appearance.Border.Color = Color.Black;
currentSeries.Appearance.ShowLabels =
false
;
currentSeries.Appearance.FillStyle.MainColor = Color.SaddleBrown;
currentSeries.Appearance.FillStyle.SecondColor = Color.Black;
RadChart1.ChartTitle.TextBlock.Text =
"Тренд по результатам промежуточных замеров по скважине №"
+ wc.well.ToString();
ChartAxisItem xAxis =
new
ChartAxisItem();
RadChart1.PlotArea.XAxis.IsZeroBased =
false
;
RadChart1.PlotArea.XAxis.AutoScale =
false
;
RadChart1.PlotArea.XAxis.Appearance.CustomFormat =
"dd.MM HH:mm"
;
//RadChart1.PlotArea.XAxis.Appearance.MajorTick.Width = 90;
RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime;
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 90;
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Top;
foreach
(DataRow dbRow
in
ds.Tables[0].Rows)
{
DateTime scDate =
new
DateTime();
scDate = Convert.ToDateTime(dbRow[
"e"
]);
ChartAxisItem item =
new
ChartAxisItem();
item.Value = (
decimal
)scDate.ToOADate();
RadChart1.PlotArea.XAxis.AddItem(item);
if
(currentSeries !=
null
)
{
currentSeries.AddItem((
double
)dbRow[
"o"
]);
}
}
Conn.Close();
}
else
if
(type ==
"padu"
)
{
sqlString = @
"exec dbo.cpadu "
+
"'"
+ d1 +
"', '"
+ d2 +
"', "
+ wc.bush +
", 0"
;
SqlDataAdapter adapter =
new
SqlDataAdapter(sqlString, Conn);
DataSet ds =
new
DataSet();
adapter.Fill(ds);
RadChart1.ChartTitle.TextBlock.Text =
"Состояние ПАДУ по скважинам куста №"
+ wc.bush.ToString();
ChartAxisItem xAxis =
new
ChartAxisItem();
RadChart1.PlotArea.XAxis.IsZeroBased =
false
;
RadChart1.PlotArea.XAxis.AutoScale =
false
;
RadChart1.PlotArea.XAxis.Appearance.CustomFormat =
"dd.MM HH:mm"
;
RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime;
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 90;
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Top;
int
w = 0;
int
v = 0;
ChartSeries currentSeries =
null
;
RadChart1.PlotArea.YAxis.Appearance.LabelAppearance.Visible =
false
;
RadChart1.PlotArea.YAxis.AutoScale =
false
;
// это нужно чтобы вручную установить шкалу
ChartAxisItem itemlast =
null
;
int
maxr = 0;
foreach
(DataRow dbRow
in
ds.Tables[0].Rows)
{
w = Convert.ToInt32(dbRow[
"w"
]);
v = Convert.ToInt32(dbRow[
"v"
]);
if
(maxr < Convert.ToInt32(dbRow[
"r"
]))
maxr = Convert.ToInt32(dbRow[
"r"
]);
DateTime scDate =
new
DateTime();
scDate = Convert.ToDateTime(dbRow[
"t"
]);
ChartAxisItem item =
new
ChartAxisItem();
item.Value = (
decimal
)scDate.ToOADate();
if
(itemlast ==
null
)
RadChart1.PlotArea.XAxis.AddItem(item);
else
if
(itemlast.Value != item.Value)
RadChart1.PlotArea.XAxis.AddItem(item);
ChartSeriesItem itm =
new
ChartSeriesItem();
itm.XValue = scDate.ToOADate();
currentSeries = RadChart1.GetSeries(w.ToString());
// пытаемся найти серию по скважине, если не нашлась - создаем новую
if
(currentSeries ==
null
)
{
currentSeries = RadChart1.CreateSeries(w.ToString(), Color.Empty, Color.Empty, ChartSeriesType.Line);
currentSeries.Appearance.LineSeriesAppearance.Width = 3;
}
ChartSeriesItem im =
null
;
// фиктивная точка для рисования лесенок
if
(currentSeries !=
null
)
{
if
(v > 0)
{
if
(v < 2)
// для граничной фиктивной точки 0 устанавливать не нужно, если ПАДУ для скважины до этого была в работе
{
im =
new
ChartSeriesItem();
im.XValue = scDate.ToOADate();
im.YValue = 0;
currentSeries.Items.Add(im);
}
itm.YValue =
double
.Parse(dbRow[
"r"
].ToString());
}
else
{
if
(v == 0)
{
im =
new
ChartSeriesItem();
im.XValue = scDate.ToOADate();
im.YValue =
double
.Parse(dbRow[
"r"
].ToString());
currentSeries.Items.Add(im);
}
itm.YValue = 0;
}
currentSeries.Items.Add(itm);
currentSeries.DefaultLabelValue = String.Empty;
}
itemlast = item;
}
RadChart1.PlotArea.YAxis.AddRange(0, maxr, 1);
Conn.Close();
}
And this is result into attach.
Why this code doesn't work for my case? Why time stamps are cut?
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Height = Telerik.Charting.Styles.Unit.Pixel(15);
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Width = Telerik.Charting.Styles.Unit.Pixel(150);