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

Message ListMessage List     Post MessagePost Message

  Radial gradient color in a pointer
Posted by Fabiano on Jun-29-2011 02:45
Hi folks,

is there a way to put a radial gradient color in gauge/meter pointer? I've tried the same way I did with linear gradient, but, it doesn't work, only the pointer's border shows up.

  Re: Radial gradient color in a pointer
Posted by Peter Kwan on Jun-30-2011 01:15
Hi Fabiano,

Yes. You can just use the radialGradientColor as usual. For example, in the "Round Meter" sample code, you can change the addPointer line to (in VB/VBScript/VBA):

Call m.addPointer(value, m.radialGradientColor(100, 100, 85, 85, &Hff0000, &H0000ff))

If you think it is not working, would you mind to inform me of your charting code?

Regards
Peter Kwan

  Re: Radial gradient color in a pointer
Posted by Fabiano on Jun-30-2011 20:45
Hi Peter,

thank you for your answer.

In fact the gradient color works indeed, my problem was the parameters for the method "radialGradientColor".
In order to make it works, I found out a error that I think is a bug. Try run the following code:
----
#include "chartdir.h"

int main(int argc, char *argv[])
{
    LinearMeter *m = new LinearMeter(450, 275, Chart::silverColor(), 0, -2);
    m->setMeter(15, 25, 420, 200, Chart::Top);
    m->setScale(0, 100, 10);

MeterPointer *pPointer;
const double value = 50.0; /*30.0*/
    pPointer = m->addPointer(value, m->radialGradientColor(2, 63, 1, 38, 0xff0000, 0x0000ff));
pPointer->setShape(Chart::DiamondPointer, Chart::NoValue, 5);

    m->makeChart("meter.png");

    //free up resources
    delete m;
    return 0;
}
----

You'll see that it throw out a exception 0x05, but if you change the value from 50 to 30, it'll run perfectly. I used the ChartDirector 4.1, I don't try it on 5.0 version.

Regards
Fabiano Barbosa.

  Re: Radial gradient color in a pointer
Posted by Peter Kwan on Jul-01-2011 01:26
Hi Fabiano,

Thanks for reporting this problem to us. I have tried your code using ChartDirector Ver 4.1, and had reproduced your problem. I have also tried using ChartDirector Ver 5, and the problem did not occur.

There is a bug in radialGradientColor if the radius is 1 pixel or less. For your case, your radialGradientColor is an ellipse of radius 1 pixel x 38 pixel, so it triggers the error. To work around the problem, please do not use radius of 1 pixel or less. (If you are using a radius of 1 x 38 pixel, the radialGradientColor is not really a suitable choice. You may consider to use a linearGradientColor instead.)

Hope this can help.

Regards
Peter Kwan

  Re: Radial gradient color in a pointer
Posted by Fabiano on Jul-01-2011 21:22
It did help a lot, thank you. I have another issue, but I'm going to open another tread.