Console Application

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
MikeTheLad
Newbie
Newbie
Posts: 65
Joined: Mon Jan 19, 2004 5:00 am

Console Application

Post by MikeTheLad » Thu Jul 14, 2011 7:53 am

Is it possible to create a graph as an image file in a console application?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Console Application

Post by Sandra » Thu Jul 14, 2011 2:32 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 65
Joined: Mon Jan 19, 2004 5:00 am

Re: Console Application

Post by MikeTheLad » Thu Jul 14, 2011 3:31 pm

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

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Console Application

Post by Sandra » Thu Jul 14, 2011 4:06 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 65
Joined: Mon Jan 19, 2004 5:00 am

Re: Console Application

Post by MikeTheLad » Thu Jul 14, 2011 4:23 pm

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.

MikeTheLad
Newbie
Newbie
Posts: 65
Joined: Mon Jan 19, 2004 5:00 am

Re: Console Application

Post by MikeTheLad » Thu Jul 14, 2011 4:29 pm

How would I go about specifying the size of the graph?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Console Application

Post by Narcís » Fri Jul 15, 2011 7:45 am

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");
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 65
Joined: Mon Jan 19, 2004 5:00 am

Re: Console Application

Post by MikeTheLad » Fri Jul 15, 2011 8:03 am

Have sorted the sizing

MikeTheLad
Newbie
Newbie
Posts: 65
Joined: Mon Jan 19, 2004 5:00 am

Re: Console Application

Post by MikeTheLad » Mon Sep 26, 2011 10:40 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Console Application

Post by Narcís » Mon Sep 26, 2011 10:56 am

Hi MikeTheLad,

This error message indicates that your application doesn't have the design-time license properly compiled into it as I explained here.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 65
Joined: Mon Jan 19, 2004 5:00 am

Re: Console Application

Post by MikeTheLad » Mon Sep 26, 2011 11:03 am

I did see this thread before and belive this is the problem however this is for V2, we have V1

MikeTheLad
Newbie
Newbie
Posts: 65
Joined: Mon Jan 19, 2004 5:00 am

Re: Console Application

Post by MikeTheLad » Mon Sep 26, 2011 11:04 am

Also, this solution does have a website and the graph works fine in this

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Console Application

Post by Narcís » Mon Sep 26, 2011 1:28 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 65
Joined: Mon Jan 19, 2004 5:00 am

Re: Console Application

Post by MikeTheLad » Mon Sep 26, 2011 1:58 pm

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";
Attachments
RAL_488_AgeGraph.jpg
RAL_488_AgeGraph.jpg (84.04 KiB) Viewed 17365 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Console Application

Post by Narcís » Mon Sep 26, 2011 2:49 pm

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);
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply