Page 1 of 1

Console Application

Posted: Thu Jul 14, 2011 7:53 am
by 8123522
Is it possible to create a graph as an image file in a console application?

Re: Console Application

Posted: Thu Jul 14, 2011 2:32 pm
by 10050769
Hello MikeTheLad,

Yes is possible. You only have added TeeChart.dll and System.Windows.Forms references and then you can do something as next:

Code: Select all

 
   class Program
    {
        static void Main(string[] args)
        {
            Steema.TeeChart.TChart tChart1 = new Steema.TeeChart.TChart();
            Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line.FillSampleValues();
            tChart1.Export.Image.JPEG.Save(@"C:\tmp\ConsoleImage.jpg");
        }
    }
Please, can you confirm us if previous code works as you expected?

I hope will helps.

Thanks,

Re: Console Application

Posted: Thu Jul 14, 2011 3:31 pm
by 8123522
I get the error below

Error 1 The type 'System.Windows.Forms.Control' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

I can't add System.Windows.Forms as not on my list

Re: Console Application

Posted: Thu Jul 14, 2011 4:06 pm
by 10050769
Hello MikeTheLad,

Please follow next steps:

1.- Click with right button on folder of references
2.- Select Add Reference
3.- Select Tab .Net
4.- Find System.Windows.Froms in the list and add it in the project and run it.

Please can you confirm us if using previous steps you can find the reference?

I hope will helps.

Thanks,

Re: Console Application

Posted: Thu Jul 14, 2011 4:23 pm
by 8123522
Thanks, I was trying the COM reference, produce a sample graph file now. So I assume now I have all the functions off all graphs available.

Re: Console Application

Posted: Thu Jul 14, 2011 4:29 pm
by 8123522
How would I go about specifying the size of the graph?

Re: Console Application

Posted: Fri Jul 15, 2011 7:45 am
by narcis
Hi MikeTheLad,

You can either set the chart control dimensions:

Code: Select all

      tChart1.Width = 800;
      tChart1.Height = 600;
Or set the exported image dimensions:

Code: Select all

      tChart1.Export.Image.JPEG.Width = 800;
      tChart1.Export.Image.JPEG.Height = 600;
      tChart1.Export.Image.JPEG.Save(@"C:\tmp\ConsoleImage.jpg");

Re: Console Application

Posted: Fri Jul 15, 2011 8:03 am
by 8123522
Have sorted the sizing

Re: Console Application

Posted: Mon Sep 26, 2011 10:40 am
by 8123522
This is all working fine in Visual 2010, I am now trying in a Visual 2008 application to do the same, on the line


Steema.TeeChart.TChart tChart1 = new Steema.TeeChart.TChart();


This is falling over with "Object reference not set to an instance of an object.", all the dll are in place and registered as per the 2010 app

Re: Console Application

Posted: Mon Sep 26, 2011 10:56 am
by narcis
Hi MikeTheLad,

This error message indicates that your application doesn't have the design-time license properly compiled into it as I explained here.

Re: Console Application

Posted: Mon Sep 26, 2011 11:03 am
by 8123522
I did see this thread before and belive this is the problem however this is for V2, we have V1

Re: Console Application

Posted: Mon Sep 26, 2011 11:04 am
by 8123522
Also, this solution does have a website and the graph works fine in this

Re: Console Application

Posted: Mon Sep 26, 2011 1:28 pm
by narcis
Hi MikeTheLad,
I did see this thread before and belive this is the problem however this is for V2, we have V1
I think this also applies to later v1 releases.
Also, this solution does have a website and the graph works fine in this
The web application could be set up correctly but not the console application. Could you please check it has licenses.licx compiled as an embedded resource?

If problems persist please attach a simple example project we can run "as-is" to reproduce the problem here.

Thanks in advance.

Re: Console Application

Posted: Mon Sep 26, 2011 1:58 pm
by 8123522
That was it, I added that file to the project and can now create graphs, however I only getting one bar per series, code is:-

Steema.TeeChart.TChart tChart1 = new Steema.TeeChart.TChart();
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar2 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
tChart1.Legend.Visible = true;
tChart1.Header.Text = "";
tChart1.Chart.Panel.Color = System.Drawing.Color.White;
tChart1.Chart.Panel.Visible = false;
tChart1.Chart.Walls.Visible = false;
tChart1.Chart.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None;
tChart1.Chart.Panel.Bevel.Inner = Steema.TeeChart.Drawing.BevelStyles.None;
tChart1.Aspect.View3D = false;
tChart1.Axes.Bottom.Automatic = false;

tChart1.Axes.Bottom.Title.Visible = true;
tChart1.Axes.Bottom.Title.Text = "Age";
tChart1.Axes.Left.Title.Visible = true;
tChart1.Axes.Left.Title.Text = "Frequency";



bar1.Add(300, "Jan");
bar1.Add(325, "Feb");
bar1.Add(287, "Mar");
bar1.Title = "Product10";

bar2.Add(175, "Jan");
bar2.Add(223, "Feb");
bar2.Add(241, "Mar");
bar2.Title = "Product12";

Re: Console Application

Posted: Mon Sep 26, 2011 2:49 pm
by narcis
Hi MikeTheLad,

That's because you set bottom axis to be manual. You can either remove this line:

Code: Select all

      tChart1.Axes.Bottom.Automatic = false;
Or set its min. and max. values manually like this:

Code: Select all

      tChart1.Axes.Bottom.SetMinMax(0, 2);