ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Compass
Posted by Boboss on Oct-22-2010 15:32
Hello
I'm french. Sorry for my English.

I want to build a compass in VBS.
I want to write North, South,...

Thanks for  your help

Boboss

  Re: Compass
Posted by Peter Kwan on Oct-23-2010 01:29
Attachments:
Hi Boboss,

You may consider to use a circular meter to draw a compass. I have attached an ASP/VBScript example for your reference.

Hope this can help.

Regards
Peter Kwan
compass.png
compass.asp
<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")

' The value to display on the meter
value = 45.17

' Create an AugularMeter object of size 200 x 200 pixels
Set m = cd.AngularMeter(200, 200)

' Set the meter center at (100, 100), with radius 85 pixels
Call m.setMeter(100, 100, 85, 0, 360)

' Meter scale is 0 - 360
Call m.setScale2(0, 360, Array("N", "-", "-", "-", "E", "-", "-", "-", "W", "-", "-", "-", "S", "-", "-", "-"))

' Disable default angular arc by setting its width to 0. Set 2 pixels line width for
' major tick, and 1 pixel line width for minor ticks.
Call m.setLineWidth(0, 2, 1)

' Set the circular meter surface as metallic blue (9999DD)
Call m.addRing(0, 90, cd.metalColor(&H9999dd))

' Add a semi-transparent blue (40333399) pointer at the specified value
Call m.addPointer(value, &H40333399).setShape(cd.DiamondPointer, 0.85)
Call m.addPointer(value + 180, &H40993333).setShape(cd.DiamondPointer, 0.85)

' Output the chart
Response.ContentType = "image/png"
Response.BinaryWrite m.makeChart2(cd.PNG)
Response.End
%>

  Re: Compass
Posted by Boboss on Oct-24-2010 06:45
Attachments:
Thank you for your compass

I write a script to make a compass in VB.

I try your model. It's OK too.

Thank you for your help

If you want the script, you can ask.

Boboss
multiameter.png

  Re: Compass
Posted by Neil on May-06-2017 02:31
Hi Peter,
  Any chance in getting this for Visual C++ V6? And perhaps with the degrees values on the outer side?

Many Thanks
Neil

  Re: Compass
Posted by Peter Kwan on May-06-2017 19:28
Hi Neil,

Below is the same code in C++, modified with the labels on the outside (using BaseMeter.setLabelPos).


// The value to display on the meter
double value = 45.17;

// Create an AugularMeter object of size 200 x 200 pixels
AngularMeter *m = new AngularMeter(200, 200);

// Set the meter center at (100, 100), with radius 70 pixels
m->setMeter(100, 100, 70, 0, 360);

// Meter scale is 0 - 360
const char *labels[] = { "N", "-", "-", "-", " E", "-", "-", "-", "S", "-", "-", "-", "W", "-", "-", "-" };
m->setScale(0, 360, StringArray(labels, (int)(sizeof(labels)/sizeof(*labels))));

// Disable default angular arc by setting its width to 0. Set 2 pixels line width for
// major tick, and 1 pixel line width for minor ticks.
m->setLineWidth(0, 2, 1);

// Set the circular meter surface as metallic blue (9999DD)
m->addRing(0, 90, Chart::metalColor(0x9999dd));

// Add a semi-transparent blue (40333399) pointer at the specified value
m->addPointer(value, 0x40333399)->setShape(Chart::DiamondPointer, 0.85);
m->addPointer(value + 180, 0x40993333)->setShape(Chart::DiamondPointer, 0.85);

// Labels outside
m->setLabelPos(false, 3);

// Output the chart
m_ChartViewer.setChart(m);

delete m;

Hope this can help.

Regards
Peter Kwan