X axis label can't be shown
Posted: Sun Feb 19, 2023 7:48 am
Dear Suppoter,
I am in the process of upgrade Teechart from 4.1.2015 to 4.2002 version. But I got a problem to show the labels of x-axis for bar chart. I am using AxisLabelStyle.PointValue for axis label. It only shows one label on the x axis. All other labels are missing, it used to work fine on the old version of TeeChart. I paste my code as below. Please let me know how to solve it. Thank you.
public partial class Form1 : Form
{
private Steema.TeeChart.TChart chart;
public Form1()
{
InitializeComponent();
chart = new Steema.TeeChart.TChart();
chart.Aspect.View3D = false;
chart.BackColor = System.Drawing.Color.White;
chart.Legend.Brush.Gradient.StartColor = System.Drawing.SystemColors.Control;
chart.Location = new System.Drawing.Point(0, 0);
chart.AutoRepaint = false;
chart.Panel.Color = SystemColors.Window;
chart.Panel.Brush.Color = System.Drawing.Color.White;
chart.Panel.Brush.ForegroundColor = System.Drawing.Color.White;
chart.Panel.Brush.Gradient.EndColor = System.Drawing.Color.Empty;
chart.Panel.Brush.Gradient.MiddleColor = System.Drawing.Color.Empty;
chart.Panel.Brush.Gradient.StartColor = System.Drawing.Color.Empty;
chart.Panel.Brush.Gradient.UseMiddle = false;
chart.Panel.Brush.Gradient.Visible = false;
chart.Size = new System.Drawing.Size(568, 421);
chart.Walls.Back.Brush.Color = System.Drawing.Color.White;
chart.Walls.Back.Brush.Gradient.StartColor = System.Drawing.Color.White;
chart.Walls.View3D = false;
chart.Zoom.History = false;
chart.Zoom.Animated = false;
chart.Aspect.View3D = false;
chart.Aspect.Width3D = 0;
chart.Aspect.Height3D = 0;
chart.Legend.LegendStyle = LegendStyles.Series;
chart.Legend.Shadow.Visible = false;
chart.Legend.Inverted = true;
chart.Legend.ClipText = false;
chart.Legend.Pen.Color = Color.Transparent;
chart.Legend.Symbol.Width = 20;
chart.Legend.Symbol.WidthUnits = LegendSymbolSize.Pixels;
chart.Legend.Font.Size = 8;
chart.Axes.Bottom.FixedLabelSize = false;
chart.Axes.Left.FixedLabelSize = false;
chart.Axes.Right.FixedLabelSize = false;
chart.Axes.Bottom.Title.Visible = false;
chart.Axes.Left.Title.Visible = false;
chart.Axes.Right.Title.Visible = false;
chart.Axes.Bottom.Minimum = double.MinValue;
chart.Axes.Bottom.Maximum = double.MaxValue;
chart.Axes.Left.Minimum = double.MinValue;
chart.Axes.Left.Maximum = double.MaxValue;
chart.Axes.Right.Minimum = double.MinValue;
chart.Axes.Right.Maximum = double.MaxValue;
// default value DashCap.Flat results "invisible" lines of any dotted styles (DashStyle.Dot, DashStyle.DashDot), case of Direct2D
// SmoothingMode.HighSpeed of Direct2D doesn't show dots of line of 1pt
chart.Axes.Bottom.Grid.DashCap = DashCap.Round;
chart.Axes.Bottom.Grid.DrawEvery = 1;
chart.Axes.Left.Grid.DashCap = DashCap.Round;
chart.Axes.Left.Grid.DrawEvery = 1;
chart.Axes.Right.Grid.DashCap = DashCap.Round;
//-----------------------------------------------------
chart.Axes.Left.AxisPen.Visible = true;
chart.Axes.Left.Ticks.Visible = true;
chart.Axes.Left.MinorTicks.Visible = true;
chart.Axes.Bottom.AxisPen.Visible = true;
chart.Axes.Bottom.Ticks.Visible = true;
chart.Axes.Bottom.MinorTicks.Visible = true;
chart.Axes.Top.Automatic = true;
chart.Axes.Top.Visible = true;
chart.Axes.Top.AxisPen.Visible = true;
chart.Axes.Top.Labels.Visible = false;
chart.Axes.Right.AxisPen.Visible = true;
chart.Axes.Right.Ticks.Visible = true;
chart.Axes.Right.MinorTicks.Visible = true;
//-----------------------------------------------------
chart.Panel.Bevel.Width = 0;
chart.Panel.Bevel.Outer = BevelStyles.None;
chart.Panel.Bevel.Inner = BevelStyles.None;
chart.Panel.MarginUnits = PanelMarginUnits.Pixels;
chart.Panel.Bevel.Inner = BevelStyles.None;
chart.Panel.Bevel.Outer = BevelStyles.None;
chart.AutoRepaint = true;
chart.Dock = System.Windows.Forms.DockStyle.Fill;
chart.Axes.Bottom.Labels.Style = AxisLabelStyle.PointValue;
this.Controls.Add(chart);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var xValues = new DateTime[4];
for (int i = 0; i < 4; i++)
{
var dt = DateTime.Now.AddMonths(i);
// var dt = DateTime.Now.AddDays(i); Add days works well
xValues = dt;
}
var yValues = new double[4] { 50, 100, 200, 241 };
plotSeries(xValues, yValues);
}
private void plotSeries(DateTime[] xValues, double[] yValues)
{
var bar = new Bar();
chart.Series.Add(bar);
bar.Add(xValues, yValues);
bar.Brush.Visible = true;
bar.BarStyle = BarStyles.Rectangle;bar.Pen.Width = 0;
bar.Pen.Color = Color.Transparent;
bar.XValues.DateTime = true;
}
}
I am in the process of upgrade Teechart from 4.1.2015 to 4.2002 version. But I got a problem to show the labels of x-axis for bar chart. I am using AxisLabelStyle.PointValue for axis label. It only shows one label on the x axis. All other labels are missing, it used to work fine on the old version of TeeChart. I paste my code as below. Please let me know how to solve it. Thank you.
public partial class Form1 : Form
{
private Steema.TeeChart.TChart chart;
public Form1()
{
InitializeComponent();
chart = new Steema.TeeChart.TChart();
chart.Aspect.View3D = false;
chart.BackColor = System.Drawing.Color.White;
chart.Legend.Brush.Gradient.StartColor = System.Drawing.SystemColors.Control;
chart.Location = new System.Drawing.Point(0, 0);
chart.AutoRepaint = false;
chart.Panel.Color = SystemColors.Window;
chart.Panel.Brush.Color = System.Drawing.Color.White;
chart.Panel.Brush.ForegroundColor = System.Drawing.Color.White;
chart.Panel.Brush.Gradient.EndColor = System.Drawing.Color.Empty;
chart.Panel.Brush.Gradient.MiddleColor = System.Drawing.Color.Empty;
chart.Panel.Brush.Gradient.StartColor = System.Drawing.Color.Empty;
chart.Panel.Brush.Gradient.UseMiddle = false;
chart.Panel.Brush.Gradient.Visible = false;
chart.Size = new System.Drawing.Size(568, 421);
chart.Walls.Back.Brush.Color = System.Drawing.Color.White;
chart.Walls.Back.Brush.Gradient.StartColor = System.Drawing.Color.White;
chart.Walls.View3D = false;
chart.Zoom.History = false;
chart.Zoom.Animated = false;
chart.Aspect.View3D = false;
chart.Aspect.Width3D = 0;
chart.Aspect.Height3D = 0;
chart.Legend.LegendStyle = LegendStyles.Series;
chart.Legend.Shadow.Visible = false;
chart.Legend.Inverted = true;
chart.Legend.ClipText = false;
chart.Legend.Pen.Color = Color.Transparent;
chart.Legend.Symbol.Width = 20;
chart.Legend.Symbol.WidthUnits = LegendSymbolSize.Pixels;
chart.Legend.Font.Size = 8;
chart.Axes.Bottom.FixedLabelSize = false;
chart.Axes.Left.FixedLabelSize = false;
chart.Axes.Right.FixedLabelSize = false;
chart.Axes.Bottom.Title.Visible = false;
chart.Axes.Left.Title.Visible = false;
chart.Axes.Right.Title.Visible = false;
chart.Axes.Bottom.Minimum = double.MinValue;
chart.Axes.Bottom.Maximum = double.MaxValue;
chart.Axes.Left.Minimum = double.MinValue;
chart.Axes.Left.Maximum = double.MaxValue;
chart.Axes.Right.Minimum = double.MinValue;
chart.Axes.Right.Maximum = double.MaxValue;
// default value DashCap.Flat results "invisible" lines of any dotted styles (DashStyle.Dot, DashStyle.DashDot), case of Direct2D
// SmoothingMode.HighSpeed of Direct2D doesn't show dots of line of 1pt
chart.Axes.Bottom.Grid.DashCap = DashCap.Round;
chart.Axes.Bottom.Grid.DrawEvery = 1;
chart.Axes.Left.Grid.DashCap = DashCap.Round;
chart.Axes.Left.Grid.DrawEvery = 1;
chart.Axes.Right.Grid.DashCap = DashCap.Round;
//-----------------------------------------------------
chart.Axes.Left.AxisPen.Visible = true;
chart.Axes.Left.Ticks.Visible = true;
chart.Axes.Left.MinorTicks.Visible = true;
chart.Axes.Bottom.AxisPen.Visible = true;
chart.Axes.Bottom.Ticks.Visible = true;
chart.Axes.Bottom.MinorTicks.Visible = true;
chart.Axes.Top.Automatic = true;
chart.Axes.Top.Visible = true;
chart.Axes.Top.AxisPen.Visible = true;
chart.Axes.Top.Labels.Visible = false;
chart.Axes.Right.AxisPen.Visible = true;
chart.Axes.Right.Ticks.Visible = true;
chart.Axes.Right.MinorTicks.Visible = true;
//-----------------------------------------------------
chart.Panel.Bevel.Width = 0;
chart.Panel.Bevel.Outer = BevelStyles.None;
chart.Panel.Bevel.Inner = BevelStyles.None;
chart.Panel.MarginUnits = PanelMarginUnits.Pixels;
chart.Panel.Bevel.Inner = BevelStyles.None;
chart.Panel.Bevel.Outer = BevelStyles.None;
chart.AutoRepaint = true;
chart.Dock = System.Windows.Forms.DockStyle.Fill;
chart.Axes.Bottom.Labels.Style = AxisLabelStyle.PointValue;
this.Controls.Add(chart);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var xValues = new DateTime[4];
for (int i = 0; i < 4; i++)
{
var dt = DateTime.Now.AddMonths(i);
// var dt = DateTime.Now.AddDays(i); Add days works well
xValues = dt;
}
var yValues = new double[4] { 50, 100, 200, 241 };
plotSeries(xValues, yValues);
}
private void plotSeries(DateTime[] xValues, double[] yValues)
{
var bar = new Bar();
chart.Series.Add(bar);
bar.Add(xValues, yValues);
bar.Brush.Visible = true;
bar.BarStyle = BarStyles.Rectangle;bar.Pen.Width = 0;
bar.Pen.Color = Color.Transparent;
bar.XValues.DateTime = true;
}
}