Page 1 of 3
Bottom and Custom Vertical Axis Label Start Position
Posted: Mon May 02, 2016 12:15 pm
by 15676891
Hi,
I am facing issue of starting the X-axis label value from the leftmost position of the chart and same for all Y-axis.
I have checked below request and implemented same. However, it doesn't solve my issue. Please suggest.
http://www.teechart.net/support/viewtop ... 74&p=70489
Attached sample project for your reference.
Thanks
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Tue May 03, 2016 9:12 am
by Christopher
Hello Priyanka,
Unfortunately your sample project is not a
Minimal, Complete, and Verifiable example because it uses data to which we do not have access. Would you please be so kind as to create a Minimal, Complete, and Verifiable example which includes your attempts to implement
the solution you saw in these forums?
Many thanks.
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Tue May 03, 2016 9:09 pm
by 15676891
Hi Christopher,
Attached modified sample project. However, the data is kept as is to show another issue of setting min and max at Y-axis. You can see data point values in legend.
Thanks.
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Wed May 04, 2016 9:53 am
by Christopher
Hello,
I'm using the latest version of TeeChart.dll in Windows Forms with this code:
Code: Select all
private void InitializeChart()
{
string strTrenddata = string.Empty;
try
{
string chart_title = "";
// Set chart basic properties
tChart1.Chart.Aspect.View3D = false;
tChart1.Chart.Header.Visible = true;
tChart1.Chart.Header.Text = chart_title;
tChart1.Chart.Legend.Alignment = LegendAlignments.Bottom;
tChart1.Chart.Legend.Visible = true;
Steema.TeeChart.Axis bottomAxis = tChart1.Chart.Axes.Bottom;
bottomAxis.Grid.Visible = false;
tChart1.Chart.Panel.Gradient.Visible = false;
tChart1.Chart.Panel.Color = Color.White;
//Do doesn't visible Wall Back
tChart1.Chart.Walls.Back.Visible = false;
tChart1.Chart.Walls.Back.Color = Color.White;
new Steema.TeeChart.Styles.Line(tChart1.Chart);
double maxvalue = 0;
strTrenddata = "<TrendData xmlns='http://www.test.com/TrendData.xsd'><TrendDataSet><TimeStamp>2016-04-06T10:53:12+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:54:04+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:54:57+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:55:50+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:56:42+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:57:35+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:58:28+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:59:20+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:00:13+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:01:06+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:01:58+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:02:51+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:03:44+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:04:37+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:05:29+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:06:22+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:07:15+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:08:07+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:09:00+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:09:53+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:10:45+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:11:38+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:12:31+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:13:23+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:14:16+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:15:09+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:16:02+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:16:54+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:17:47+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:18:40+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:19:32+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:20:25+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:21:18+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:22:10+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>85.41893</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:23:03+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:23:56+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:24:48+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:25:41+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:26:34+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:27:27+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:28:19+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:29:12+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:30:05+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:30:57+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:31:50+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:32:43+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:33:35+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:34:28+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:35:21+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:36:14+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet></TrendData>";
tChart1.Chart[0].DataSource = GetData("_x0031_120BXA001_x002F_OUT.CV", strTrenddata, out maxvalue);//Add values using DataSource
// X-axis setting
tChart1.Chart[0].XValues.DataMember = "DateTime";
tChart1.Chart[0].XValues.DateTime = true;
tChart1.Chart.Axes.Custom.Add(new Steema.TeeChart.Axis(tChart1.Chart));
tChart1.Chart[0].CustomVertAxis = tChart1.Chart.Axes.Custom[0];
bottomAxis.Labels.DateTimeFormat = "yyyy-dd-MM\nHH:mm";
bottomAxis.Labels.Angle = 90;
tChart1.Chart.Axes.Custom[0].AxisPen.Width = 1;
tChart1.Chart.Axes.Custom[0].AxisPen.Color = tChart1.Chart[0].Color;
tChart1.Chart.Axes.Custom[0].Grid.Visible = false;
tChart1.Chart.Axes.Custom[0].Title.Visible = false;
tChart1.Chart[0].CustomVertAxis.Automatic = true;
tChart1.Chart[0].CustomVertAxis.SetMinMax(0, maxvalue);
tChart1.Chart.Axes.Custom[0].Title.Caption = "";
tChart1.Chart.Axes.Custom[0].Title.Angle = 90;
tChart1.Chart[0].YValues.DataMember = "SystemName";
tChart1.Chart[0].CustomVertAxis.Labels.ValueFormat = "####;{####}";
tChart1.Chart.Axes.Custom[0].PositionUnits = PositionUnits.Pixels;
panel1.Width = 1100;
panel1.Height = 600;
tChart1.Chart.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels;
PlaceAxes(0, 0, 0, 0, 0);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
}
catch (Exception ex)
{
}
}
private DataSet GetData(string TagName, string strTrenddata, out double maxvalue)
{
XmlDocument doc = new XmlDocument();
DataSet TeeDataSet = new DataSet();
DateTime dt = DateTime.Today;
Int32 maxVal = 0;
try
{
doc.LoadXml(strTrenddata);
maxvalue = 0;
DataTable TeeDataTable = new DataTable("DataTable1");
DataColumn xval = new DataColumn("DateTime", typeof(DateTime));
DataColumn yval = new DataColumn("SystemName", typeof(double));
TeeDataTable.Columns.Add(xval);
TeeDataTable.Columns.Add(yval);
TagName = TagName.Split('/')[0];
XmlDocument pardoc = new XmlDocument();
foreach (XmlNode xnList in doc.SelectNodes("/*[local-name()='TrendData']/*[local-name()='TrendDataSet']"))
{
foreach (XmlNode xnList1 in xnList.ChildNodes)
{
string str = xnList1.Name;
XmlNode parentnode = xnList1.ParentNode;
pardoc.LoadXml(parentnode.OuterXml);
if (str == TagName)
{
//add
DataRow newRow = TeeDataTable.NewRow();
newRow[xval] = pardoc.SelectSingleNode("/*[local-name()='TrendDataSet']/*[local-name()='TimeStamp']").InnerText;
newRow[yval] = xnList1.InnerText;
TeeDataTable.Rows.Add(newRow);
}
}
}
TeeDataSet.Tables.Add(TeeDataTable);
var maxVal1 = TeeDataTable.AsEnumerable()
.Max(r => r.Field<double>("SystemName"));
maxVal = Convert.ToInt32(maxVal1);
}
catch (Exception ex)
{
}
maxvalue = maxVal;
return TeeDataSet;
}
protected void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
PlaceAxes(0, 0, 0, 0, 0);
//set x position for new label
int x = tChart1.Chart.Axes.Bottom.CalcPosValue(tChart1.Chart.Axes.Bottom.Minimum);
AxisLabels tmpLabels = new AxisLabels(tChart1.Chart.Axes.Bottom);
FieldInfo privateField = tmpLabels.GetType().GetField("position", BindingFlags.NonPublic | BindingFlags.Instance);
int y = (int)privateField.GetValue(tChart1.Chart.Axes.Bottom.Labels);
string label = tChart1.Chart.Axes.Bottom.Minimum.ToString("#");
//output text
//g.TextOut(x - ((int)Math.Round(g.TextWidth(label) / 2)), y, label);
// It print to number. I need it to shift the start date??
}
private void PlaceAxes(int nSeries, int NextXLeft, int NextXRight, int MargLeft, int MargRight)
{
const int extraPos = 12;
const int extraMargin = 50;
Steema.TeeChart.Chart ch1 = tChart1.Chart;
//Variable
int MaxLabelsWidth;
int lenghtTicks;
int extraSpaceBetweenTitleAndLabels;
foreach (Steema.TeeChart.Styles.Line s in ch1.Series)
{
if (s.CustomVertAxis != null)
{
MaxLabelsWidth = s.CustomVertAxis.MaxLabelsWidth();
lenghtTicks = s.CustomVertAxis.Ticks.Length;
extraSpaceBetweenTitleAndLabels = (s.CustomVertAxis.Title.Width);//- tChart1.Axes.Custom[nSeries].MaxLabelsWidth());
if (s.CustomVertAxis.Title.Visible)
{
s.CustomVertAxis.RelativePosition = NextXLeft;
NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraSpaceBetweenTitleAndLabels + extraPos);
MargLeft = MargLeft + extraMargin;
}
else
{
s.CustomVertAxis.RelativePosition = NextXLeft;
if (ch1.Series.Count == 3)
NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraPos);
else
NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraPos + 25);
MargLeft = MargLeft + extraMargin;
}
}
ch1.Panel.MarginLeft = MargLeft;
}
}
And the result is this:
- export635979521062817694.png (15.38 KiB) Viewed 19543 times
Is this what you would expect?
Also, I cannot see in this code any attempt to implement the solution you mentioned in your first message in this thread - should I be able to see in this code where you have attempted to implement it?
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Wed May 04, 2016 4:02 pm
by 15676891
Hi Christopher,
The issue is starting position of X-axis and Y-axis values. I would expect the chart as per attached. Also, the code I tried is in tChart1_AfterDraw method.
Thanks.
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Thu May 05, 2016 10:27 am
by Christopher
Priyanka wrote:
The issue is starting position of X-axis and Y-axis values. I would expect the chart as per attached. Also, the code I tried is in tChart1_AfterDraw method.
Yes, okay. What I'm trying to say is that I would expect you to have tried coding the technique specified in the reply to this message
here, but I can't see any code in your example which makes any attempt to do so.
Have you tried using this technique to resolve the problem? If so, do you have an example of the problems you encountered?
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Wed May 11, 2016 12:55 pm
by 15676891
Hi Christopher,
I tried to implement technique as mentioned in your reply. However, it is showing just one value as shown in the screenshot. Also, Y-axis values are not started from the same position.
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Wed May 11, 2016 2:07 pm
by Christopher
Priyanka wrote:
I tried to implement technique as mentioned in your reply. However, it is showing just one value as shown in the screenshot. Also, Y-axis values are not started from the same position.
Could you please pass me your code so I can try and reproduce your issues here?
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Thu May 12, 2016 10:37 am
by 15676891
Hi Christopher,
Please find attached code for your reference. Also, can you check the issue of displaying 0 value on Y-axis.
Thanks
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Tue May 17, 2016 4:48 pm
by Christopher
Priyanka wrote:
Please find attached code for your reference. Also, can you check the issue of displaying 0 value on Y-axis.
Many apologies for the delay in this reply - Friday and Monday were holidays here.
I'm using the following code and the latest version of TeeChart.dll in a Windows Forms project:
Code: Select all
private void InitializeChart()
{
string strTrenddata = string.Empty;
try
{
string chart_title = "";
// Set chart basic properties
tChart1.Chart.Aspect.View3D = false;
tChart1.Chart.Header.Visible = true;
tChart1.Chart.Header.Text = chart_title;
tChart1.Chart.Legend.Alignment = LegendAlignments.Bottom;
tChart1.Chart.Legend.Visible = true;
Steema.TeeChart.Axis bottomAxis = tChart1.Chart.Axes.Bottom;
bottomAxis.Grid.Visible = false;
tChart1.Chart.Panel.Gradient.Visible = false;
tChart1.Chart.Panel.Color = Color.White;
//Do doesn't visible Wall Back
tChart1.Chart.Walls.Back.Visible = false;
tChart1.Chart.Walls.Back.Color = Color.White;
new Steema.TeeChart.Styles.Line(tChart1.Chart);
double maxvalue = 0;
strTrenddata = "<TrendData xmlns='http://www.test.com/TrendData.xsd'><TrendDataSet><TimeStamp>2016-04-06T10:53:12+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:54:04+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:54:57+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:55:50+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:56:42+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:57:35+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:58:28+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T10:59:20+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:00:13+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:01:06+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:01:58+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:02:51+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:03:44+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:04:37+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:05:29+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:06:22+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:07:15+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:08:07+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:09:00+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:09:53+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:10:45+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:11:38+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:12:31+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:13:23+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:14:16+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:15:09+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:16:02+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:16:54+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:17:47+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:18:40+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:19:32+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:20:25+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:21:18+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:22:10+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>85.41893</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:23:03+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:23:56+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:24:48+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>36</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:25:41+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:26:34+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:27:27+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:28:19+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:29:12+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:30:05+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:30:57+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:31:50+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:32:43+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:33:35+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:34:28+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:35:21+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet><TrendDataSet><TimeStamp>2016-04-06T11:36:14+02:00</TimeStamp><_x0031_120BXA001_x002F_OUT.CV>96</_x0031_120BXA001_x002F_OUT.CV><_x0031_120BXA001_x002F_OUT.CV_Status>0</_x0031_120BXA001_x002F_OUT.CV_Status></TrendDataSet></TrendData>";
tChart1.Chart[0].DataSource = GetData("_x0031_120BXA001_x002F_OUT.CV", strTrenddata, out maxvalue);//Add values using DataSource
// X-axis setting
tChart1.Chart[0].XValues.DataMember = "DateTime";
tChart1.Chart[0].XValues.DateTime = true;
tChart1.Chart.Axes.Custom.Add(new Steema.TeeChart.Axis(tChart1.Chart));
tChart1.Chart[0].CustomVertAxis = tChart1.Chart.Axes.Custom[0];
bottomAxis.Labels.DateTimeFormat = "yyyy-dd-MM\nHH:mm";
bottomAxis.Labels.Angle = 90;
tChart1.Chart.Axes.Custom[0].AxisPen.Width = 1;
tChart1.Chart.Axes.Custom[0].AxisPen.Color = tChart1.Chart[0].Color;
tChart1.Chart.Axes.Custom[0].Grid.Visible = false;
tChart1.Chart.Axes.Custom[0].Title.Visible = false;
tChart1.Chart[0].CustomVertAxis.Automatic = true;
tChart1.Chart[0].CustomVertAxis.SetMinMax(0, maxvalue);
tChart1.Chart.Axes.Custom[0].Title.Caption = "";
tChart1.Chart.Axes.Custom[0].Title.Angle = 90;
tChart1.Chart[0].YValues.DataMember = "SystemName";
tChart1.Chart[0].CustomVertAxis.Labels.ValueFormat = "####;{####}";
tChart1.Chart.Axes.Custom[0].PositionUnits = PositionUnits.Pixels;
tChart1.Chart.Width = 1100;
tChart1.Chart.Height = 600;
tChart1.Chart.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels;
PlaceAxes(0, 0, 0, 0, 0);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(WebChart1_AfterDraw);
tChart1.Chart.Export.Image.PNG.Save(@"D:\tmp\Trend.png");
}
catch (Exception ex)
{
}
}
private DataSet GetData(string TagName, string strTrenddata, out double maxvalue)
{
XmlDocument doc = new XmlDocument();
DataSet TeeDataSet = new DataSet();
DateTime dt = DateTime.Today;
Int32 maxVal = 0;
try
{
doc.LoadXml(strTrenddata);
maxvalue = 0;
DataTable TeeDataTable = new DataTable("DataTable1");
DataColumn xval = new DataColumn("DateTime", typeof(DateTime));
DataColumn yval = new DataColumn("SystemName", typeof(double));
TeeDataTable.Columns.Add(xval);
TeeDataTable.Columns.Add(yval);
TagName = TagName.Split('/')[0];
XmlDocument pardoc = new XmlDocument();
foreach (XmlNode xnList in doc.SelectNodes("/*[local-name()='TrendData']/*[local-name()='TrendDataSet']"))
{
foreach (XmlNode xnList1 in xnList.ChildNodes)
{
string str = xnList1.Name;
XmlNode parentnode = xnList1.ParentNode;
pardoc.LoadXml(parentnode.OuterXml);
if (str == TagName)
{
//add
DataRow newRow = TeeDataTable.NewRow();
newRow[xval] = pardoc.SelectSingleNode("/*[local-name()='TrendDataSet']/*[local-name()='TimeStamp']").InnerText;
newRow[yval] = xnList1.InnerText;
TeeDataTable.Rows.Add(newRow);
}
}
}
TeeDataSet.Tables.Add(TeeDataTable);
var maxVal1 = TeeDataTable.AsEnumerable()
.Max(r => r.Field<double>("SystemName"));
maxVal = Convert.ToInt32(maxVal1);
}
catch (Exception ex)
{
}
maxvalue = maxVal;
return TeeDataSet;
}
protected void WebChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
PlaceAxes(0, 0, 0, 0, 0);
//set x position for new label
int x = tChart1.Chart.Axes.Bottom.CalcPosValue(tChart1.Chart.Axes.Bottom.Minimum);
AxisLabels tmpLabels = new AxisLabels(tChart1.Chart.Axes.Bottom);
FieldInfo privateField = tmpLabels.GetType().GetField("position", BindingFlags.NonPublic | BindingFlags.Instance);
int y = (int)privateField.GetValue(tChart1.Chart.Axes.Bottom.Labels);
string label = tChart1.Chart.Axes.Bottom.Minimum.ToString("#");
//output text
//g.TextOut(x - ((int)Math.Round(g.TextWidth(label) / 2)), y, label);
// It print to number. I need it to shift the start date??
}
private void PlaceAxes(int nSeries, int NextXLeft, int NextXRight, int MargLeft, int MargRight)
{
const int extraPos = 12;
const int extraMargin = 50;
Steema.TeeChart.Chart ch1 = tChart1.Chart;
//Variable
int MaxLabelsWidth;
int lenghtTicks;
int extraSpaceBetweenTitleAndLabels;
foreach (Steema.TeeChart.Styles.Line s in ch1.Series)
{
if (s.CustomVertAxis != null)
{
MaxLabelsWidth = s.CustomVertAxis.MaxLabelsWidth();
lenghtTicks = s.CustomVertAxis.Ticks.Length;
extraSpaceBetweenTitleAndLabels = (s.CustomVertAxis.Title.Width);//- 2016.Axes.Custom[nSeries].MaxLabelsWidth());
if (s.CustomVertAxis.Title.Visible)
{
s.CustomVertAxis.RelativePosition = NextXLeft;
NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraSpaceBetweenTitleAndLabels + extraPos);
MargLeft = MargLeft + extraMargin;
}
else
{
s.CustomVertAxis.RelativePosition = NextXLeft;
if (ch1.Series.Count == 3)
NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraPos);
else
NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraPos + 25);
MargLeft = MargLeft + extraMargin;
}
}
ch1.Panel.MarginLeft = MargLeft;
}
}
and I obtain the following chart:
- export635990998091376500.png (15.38 KiB) Viewed 19450 times
Again, I'm afraid cannot see any attempt to implement the coding technique I mentioned in my last message to you. Could you please clarify whether you simply want me to implement this code for you?
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Mon May 23, 2016 5:16 am
by 15676891
Hi Christopher,
Not sure which code you are referring. However, I had attached code with the below method implemented. I assume this is what you also suggested to fix this issue in other post.
private void WebChart1_BeforeDrawAxes(object sender, Graphics3D g)
Attached again the file with the code recommended.
Appreciate quick help. Thanks.
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Mon May 23, 2016 1:54 pm
by Christopher
Hello Priyanka,
I think I've got a couple of solutions for you. Firstly the zero that does not appear on the custom axis - this is due to the custom valueformat, which should be changed to this:
Code: Select all
WebChart1.Chart[0].CustomVertAxis.Labels.ValueFormat = "####0;{####0};
and the singular label on the bottom axis was because, for your data, the increment was set too high:
Code: Select all
double inc = 1.0 / 480.0; //five minutes
I hope that helps.
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Wed May 25, 2016 1:00 pm
by 15676891
Hi Christopher,
Thanks. It solved both issues
Need your inputs on removing the border (bottom line) marked in attached screenshot (Trend_chart1). We need the border to just chart area as attached in screenshot (Trend_chart2)
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Wed May 25, 2016 3:21 pm
by Christopher
Priyanka wrote:
Thanks. It solved both issues
You're welcome, I'm very glad to hear it!
Priyanka wrote:
Need your inputs on removing the border (bottom line) marked in attached screenshot (Trend_chart1). We need the border to just chart area as attached in screenshot (Trend_chart2)
You can try:
Code: Select all
WebChart1.Chart.Panel.Bevel.Inner = BevelStyles.None;
WebChart1.Chart.Panel.Bevel.Outer = BevelStyles.None;
Re: Bottom and Custom Vertical Axis Label Start Position
Posted: Thu May 26, 2016 9:10 am
by 15676891
Hi Christopher,
I tried it but no luck.