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

Message ListMessage List     Post MessagePost Message

  How can I resize my background picture?(C++ MFC)
Posted by Tony on Feb-25-2015 17:46
Hi,

I want to use a background for my XYChart as below:
plotarea->setBackground("picture.png",1);

But the XYChart and picture.png need to be resized by OnSize() function.
How can I resize picture.png?



If it doesn't work.
I will use CDC class to resize picture.png and put in the same location with  my XYChart.

But It has flicker because XYChart is not transparent.
Any ideas to solve it?

thanks for help.

  Re: How can I resize my background picture?(C++ MFC)
Posted by Peter Kwan on Feb-26-2015 00:30
Hi Tony,

May be you can try to put a "CDML" image at the back of the plot area, like:

char myImage[1024];
sprintf(myImage, "<*img=picture.png,width=%d,height=%d*>", plotarea->getWidth(),
plotarea->getHeight());

c->addText(plotarea->getLeftX(), plotarea->getTopY(), myImage)
  ->setZOrder(Chart::PlotAreaZ);

Hope this can help.

Regards
Peter Kwan

  Re: How can I resize my background picture?(C++ MFC)
Posted by Tony on Feb-26-2015 17:44
it's OK
Thank you very much.

  Re: How can I resize my background picture?(C++ MFC)
Posted by Tony on Mar-03-2015 17:27
Attachments:
Sorry, I have some questions.


I want to design a chart similar attachment.
But the color pattern need to be resized by OnSize() function too.
How can I resize color pattern in the area?



If it doesn't work.
Maybe It can be designed by Area Charts.
But How can I use the pattern to fill up the outside area in an area chart?
I intend to use white color for outside area.


thanks for help.
spectrum.jpg

  Re: How can I resize my background picture?(C++ MFC)
Posted by Peter Kwan on Mar-04-2015 01:40
Hi Tony,

I think you can just directly create the gradient and use it as the area color. There is no
need to use any external image as the pattern.


// I measured the colors using Photoshop and use it to create the gradient
int gradient[] = {
  0 , 0x2A193C, 13, 0x4C0593, 26, 0x4C05E9, 39, 0x0000FA, 52, 0x0076FF,
  64, 0x0DCDFF, 77, 0x00FF97, 90, 0x32FB00, 103, 0x7CFF00, 116, 0xC3FF00,
  128, 0xFFFF00, 141, 0xFEC400, 154, 0xFF7800, 167, 0xFC2A09, 180, 0xF70302,
  192, 0xf70900, 205, 0xF70400, 218, 0xD90000, 231, 0xB00000, 244, 0x6F0000,
  256, 0x570000};

// Gradient is from the left side to the right side of the plot area
int myColor = c->linearGradientColor(c->getPlotArea()->getLeftX(), 0,
  c->getPlotArea()->getRightX(), 0,
  IntArray(gradient, (int)(sizeof(gradient) / sizeof(*gradient))));

// Use the gradient to fill the area
c->addAreaLayer(myData, myColor, "My Area");


Hope this can help.

Regards
Peter Kwan

  Re: How can I resize my background picture?(C++ MFC)
Posted by Tony on Mar-05-2021 19:36
Hi,

How can I create the same chart by C# (winform)?

  Re: How can I resize my background picture?(C++ MFC)
Posted by Peter Kwan on Mar-06-2021 16:17
Hi Tony,

You can simply change the code to C# syntax

// I measured the colors using Photoshop and use it to create the gradient
int[] gradient = {
  0 , 0x2A193C, 13, 0x4C0593, 26, 0x4C05E9, 39, 0x0000FA, 52, 0x0076FF,
  64, 0x0DCDFF, 77, 0x00FF97, 90, 0x32FB00, 103, 0x7CFF00, 116, 0xC3FF00,
  128, 0xFFFF00, 141, 0xFEC400, 154, 0xFF7800, 167, 0xFC2A09, 180, 0xF70302,
  192, 0xf70900, 205, 0xF70400, 218, 0xD90000, 231, 0xB00000, 244, 0x6F0000,
  256, 0x570000};

// Gradient is from the left side to the right side of the plot area
int myColor = c.linearGradientColor(c.getPlotArea().getLeftX(), 0,
  c.getPlotArea().getRightX(), 0, gradient);

// Use the gradient to fill the area
c.addAreaLayer(myData, myColor, "My Area");

Regards
Peter Kwan