Grid Spacing problem

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
sharewealth
Newbie
Newbie
Posts: 2
Joined: Tue Jun 28, 2016 12:00 am

Grid Spacing problem

Post by sharewealth » Thu Feb 23, 2017 7:19 am

Hi,

We are trying to upgrade our very old teechart to the latest and were having some problem. One problem I'm having difficulty is setting the spacing of the vertical grid lines. Our current version doesnt have themes, now with the new version we are using TeeCharts theme.


Figure 1: Using the TeeChart theme gives me this screen. A uneven spacing of vertical grid lines. Note that I had to set the ChartAxis.Grid.DrawEvery = 1; in ThemeProperties.ChangeAxis(Axis ChartAxis) for bottom axis because for some reason it is set to 2 and what it does is skip 1 line which is not what we want.
001.png
Figure 1
001.png (66.06 KiB) Viewed 7363 times

Figure 2: It seems that commenting this code ThemeProperties.Instance.AxisLabelsFontSize = 8; from TeeChartThemes.SetDefaultValues() fixes the problem but the spacing is too wide compared to what we currently have.
002.png
Figure 2
002.png (61.22 KiB) Viewed 7362 times
What I need is to
1: Make date font smaller
2: Make the spacing between each v line and date tighter so I can show more dates


Figure 3: Is what our current app looks like with the old version of TeeChart.
original.PNG
Figure 3
original.PNG (167.98 KiB) Viewed 7362 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Grid Spacing problem

Post by Christopher » Fri Feb 24, 2017 11:49 am

Hello,
sharewealth wrote: What I need is to
1: Make date font smaller
2: Make the spacing between each v line and date tighter so I can show more dates
the following code, using the latest publicly available version of TeeChart.dll:

Code: Select all

  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
      CreateChart();
      InitializeChart();
    }

    TChart tChart1;

    private void CreateChart()
    {
      tChart1 = new TChart();
      tChart1.Dock = DockStyle.Fill;
      splitContainer1.Panel2.Controls.Add(tChart1);
    }

    private void InitializeChart()
    {
      Candle series = new Candle(tChart1.Chart);

      tChart1.Legend.Visible = false;
      series.FillSampleValues(100);
      series.UpCloseColor = Color.Green;
      series.Style = CandleStyles.CandleBar;

      tChart1.Axes.Bottom.Grid.Visible = true;
      tChart1.Axes.Bottom.Labels.Font.Size = 3;

      tChart1.Header.Text = Utils.Version;
    }

    private void button1_Click(object sender, EventArgs e)
    {
      tChart1.Export.Image.PNG.Save(@"D:\FTP\" + "TChart" + DateTime.UtcNow.Ticks.ToString() + ".png");
    }
  }
gives me the following:
TChart636235335920558233.png
TChart636235335920558233.png (28.66 KiB) Viewed 7348 times
do you obtain the same at your end?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

sharewealth
Newbie
Newbie
Posts: 2
Joined: Tue Jun 28, 2016 12:00 am

Re: Grid Spacing problem

Post by sharewealth » Tue Feb 28, 2017 5:01 am

After a digging through the code, I noticed that there is a logic that skips a line when the label is too wide which I think is there to avoid overlapping dates. I found it in Axes.AxisLabelsSeries(Rectangle rect)
where tmpDraw will be false if it thinks the date will overlap. I fixed this to always true and I got the result that I needed except that its a bit cramped..

This is the code where I force tmpDraw = true
001.PNG
Figure 1
001.PNG (46.26 KiB) Viewed 7346 times

And this is what I got
002.PNG
Figure 2
002.PNG (40.87 KiB) Viewed 7348 times
Next question is, how to I set the width of the grid to make it a few pixels wider so the date text wont be too close to each other?

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Grid Spacing problem

Post by Christopher » Tue Feb 28, 2017 10:10 am

sharewealth wrote: Next question is, how to I set the width of the grid to make it a few pixels wider so the date text wont be too close to each other?
It would be useful, if only to ascertain we are both running a binary which gives us the same result, if you could run the following code and post a screencap of the result you obtain:

Code: Select all

      public partial class Form1 : Form
      {
        public Form1()
        {
          InitializeComponent();
          CreateChart();
          InitializeChart();
        }

        TChart tChart1;

        private void CreateChart()
        {
          tChart1 = new TChart();
          tChart1.Dock = DockStyle.Fill;
          splitContainer1.Panel2.Controls.Add(tChart1);
        }

        private void InitializeChart()
        {
          Candle series = new Candle(tChart1.Chart);

          tChart1.Legend.Visible = false;
          series.FillSampleValues(100);
          series.UpCloseColor = Color.Green;
          series.Style = CandleStyles.CandleBar;

          tChart1.Axes.Bottom.Grid.Visible = true;
          tChart1.Axes.Bottom.Labels.Font.Size = 3;

          tChart1.Header.Text = Utils.Version;
        }

        private void button1_Click(object sender, EventArgs e)
        {
          tChart1.Export.Image.PNG.Save(@"D:\FTP\" + "TChart" + DateTime.UtcNow.Ticks.ToString() + ".png");
        }
      }
If this code works for you as it works here, I believe it should be somewhat easier for me to help you resolve your issue.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply