Page 1 of 1

Grid Spacing problem

Posted: Thu Feb 23, 2017 7:19 am
by 16078574
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 7589 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 7588 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 7588 times

Re: Grid Spacing problem

Posted: Fri Feb 24, 2017 11:49 am
by Christopher
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 7574 times
do you obtain the same at your end?

Re: Grid Spacing problem

Posted: Tue Feb 28, 2017 5:01 am
by 16078574
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 7572 times

And this is what I got
002.PNG
Figure 2
002.PNG (40.87 KiB) Viewed 7574 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?

Re: Grid Spacing problem

Posted: Tue Feb 28, 2017 10:10 am
by Christopher
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.