Hi,
if I want to display (and print) an x-y-chart with for example a circle represented as x=r.cos(angle) and y= r.sin(angle) but without a distortion
so that the user sees a 'real' circle, how can I do that?
Best regards and thanks for any help.
Tobias
True scale
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Tobias,
To get a real circle you could use something as shown in the All Features\Welcome !\Axes\Isometric axes example at the features demo available at TeeChart's program group.
For the series what would you like to use, points, a line, ...?
To get a real circle you could use something as shown in the All Features\Welcome !\Axes\Isometric axes example at the features demo available at TeeChart's program group.
For the series what would you like to use, points, a line, ...?
Best Regards,
Narcís Calvet / 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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Tobias,
Ok, you can use something like this:
Ok, you can use something like this:
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart;
using System.Runtime.InteropServices;
namespace CircledShape
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private static short HORZSIZE = 4; // Horizontal size in millimeters
private static short VERTSIZE = 6; // Vertical size in millimeters
[DllImport("gdi32.dll")]
private static extern Int32 GetDeviceCaps(IntPtr hdc, Int32 capindex);
private void Form1_Load(object sender, EventArgs e)
{
fastLine1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.None;
fastLine1.YValues.Order = Steema.TeeChart.Styles.ValueListOrder.None;
for (double angle = 0; angle < 2*Math.PI; angle=angle+0.001)
{
fastLine1.Add(Math.Cos(angle), Math.Sin(angle));
}
tChart1.Axes.Left.SetMinMax(-1.25, 1.25);
tChart1.Axes.Bottom.SetMinMax(-1.25, 1.25);
//Trick to force the chart being drawn so that isometric axes can be calculated
Bitmap bmp = tChart1.Bitmap;
MakeIsometric(fastLine1);
}
private void MakeIsometric(Axis vertical, Axis horizontal)
{
if ((vertical.Chart.Width > 0) && (vertical.Chart.Height > 0))
{
// setup values
double xrange = horizontal.Maximum - horizontal.Minimum;
double yrange = vertical.Maximum - vertical.Minimum;
double tmpx = xrange / (double)vertical.Chart.Width;
double tmpy = yrange / (double)vertical.Chart.Height;
Screen screen = Screen.FromControl(this);
Graphics g = Graphics.FromHwnd(this.Handle);
IntPtr hptr = g.GetHdc();
double xyscreen = GetDeviceCaps(hptr, HORZSIZE) * screen.Bounds.Height;
xyscreen /= (double)GetDeviceCaps(hptr, VERTSIZE) * screen.Bounds.Width;
g.ReleaseHdc(hptr);
g.Dispose();
tmpy *= xyscreen;
double offset = 0.0;
if (tmpx > tmpy)
{
if (tmpy != 0.0)
{
offset = 0.5 * (yrange * tmpx / tmpy - yrange);
vertical.SetMinMax(vertical.Minimum - offset, vertical.Maximum + offset);
}
}
else if (tmpx < tmpy)
{
if (tmpx != 0.0)
{
offset = 0.5 * (xrange * tmpy / tmpx - xrange);
horizontal.SetMinMax(horizontal.Minimum - offset, horizontal.Maximum + offset);
}
}
}
}
private void MakeIsometric(Steema.TeeChart.Styles.Series series)
{
MakeIsometric(series.GetVertAxis, series.GetHorizAxis);
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
MakeIsometric(fastLine1);
}
private void tChart1_UndoneZoom(object sender, EventArgs e)
{
MakeIsometric(fastLine1);
}
private void tChart1_Scroll(object sender, EventArgs e)
{
MakeIsometric(fastLine1);
}
}
}
Best Regards,
Narcís Calvet / 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 |