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

Message ListMessage List     Post MessagePost Message

  wallpaper auto streching
Posted by Hee Du on Sep-13-2017 10:14
Hi.

I am using wallpaper as a fixed size image.
When the running chart size is changed I also want to adjust the size of the wallpaper together.
I would like to know if there is an option to adjust the size of the image you inserted using chart.setBgImage (image) according to the chart area.

Thanks,

Hee Du

  Re: wallpaper auto streching
Posted by Peter Kwan on Sep-14-2017 00:11
Hi Hee,

Yes, you can add a text box to the background (using BaseChart.addText), where the text is "<*img=/path/to/image/png,width=600,height=400*>" (assume 600 x 400 is the size of your chart). In C#, it is like:

c.addText(0, 0, "<*img=/path/to/img.png,width=" + c.getWidth() + ",height=" + c.getHeight() + "*>").setZOrder(Chart.ChartBackZ);

Hope this can help.

Regards
Peter Kwan

  Re: wallpaper auto streching
Posted by Hee Du on Sep-14-2017 16:10
Attachments:
Dear Peter

Thanks for the reply

Thanks to that, the previous problem has been solved completely.

However, there are new problems related to SVG convertion.

If you save as SVG after using wallpaper currently using "AngularMeter chart" it will be stored as shown below.

I would like to know if I can draw a chart on the background image.

Thanks
Heedu
cap1.PNG

  Re: wallpaper auto streching
Posted by Peter Kwan on Sep-14-2017 23:27
Attachments:
Hi Hee,

I have just tried myself and it works normally in my case. I have attached the background image I am using, and the result PNG and SVG for your reference. (You can view the SVG by dragging the downloaded aaa.svg file onto the browser window.) The SVG shows the same image as the PNG, but is scalable.

The code I used is (in C#):

double value = 72.55;
AngularMeter m = new AngularMeter(300, 180, Chart.Transparent);
m.setMeter(150, 150, 128, -90, 90);
m.setScale(0, 100, 20, 10, 5);
m.addPointer2(value, 0xff0000);

m.addText(0, 0, "<*img=c:\win10.png,width=" + m.getWidth() + ",height=" + m.getHeight() + "*>").setZOrder(Chart.ChartBackZ);

m.makeChart("c:\temp\aaa.svg");
m.makeChart("c:\temp\semicirclemeter.png");

I tried using ChartDirector version 6. If you are using an older version of ChartDirector, please try to use ChartDirector version 6 to see if it works normally.

If the above still does not solve the problem, is it possible to provide me with a code example (may be by modifying the code above), and also provide the resulting SVG and the background image file you use.

Regards
Peter Kwan
aaa.svg
aaa.svg

6.36 Kb
    
semicirclemeter.png
win10.png

  Re: wallpaper auto streching
Posted by Hee Du on Sep-15-2017 19:40
Daer Peter

I have found an accurate reproduction step of this problem.

Now, I am using "enableVectorOutput" to create SVG.

Using wallpaper for png has no problem, However, when jpg is used, the image is distorted.
A sample executable code can be found below.

double value = 72.55;

AngularMeter m = new AngularMeter(300, 180, Chart.Transparent);

m.enableVectorOutput();
m.setMeter(150, 150, 128, -90, 90);
m.setScale(0, 100, 20, 10, 5);
m.addPointer(value, 0xff00000);

m.addText(0, 0, "<*img=d:/anyImage.jpg,width=" + m.getWidth() + ",height=" + m.getHeight() + "*>").setZOrder(Chart.ChartBackZ);

m.makeChart();

m.getDrawArea().outSVG("d:/svgTest2.svg");

All jpg images seem to be distorted.

I would like to know if there is a problem with storing SVG.

thanks,
HeeDu

  Re: wallpaper auto streching
Posted by Peter Kwan on Sep-15-2017 21:26
Attachments:
Hi Hee,

"enableVectorOutput" is not necessary in ChartDirector version 6. In fact, "enableVectorOutput" has not effect at all in ChartDirector version 6. It is only for compatibility with older versions of ChartDirector.

The vector graphics in ChartDirector version 6 improves a lot. All graphics are internally vectorized, so there is no need to use "enableVectorOutput", and in additional to SVG, ChartDirector version 6 can also output PDF vector graphics.

If you need to use "enableVectorOutput", is it possible you are using ChartDirector version 5? I have just tried using JPG as the background image with ChartDirector version 6, and it works normally.

I have attached the SVG produced using your code, and the JPG that I used as the background image for your reference.

Regards
Peter Kwan
svgTest2.svg
svgTest2.svg

8.78 Kb
    
win10.jpg

  Re: wallpaper auto streching
Posted by Peter Kwan on Sep-15-2017 21:29
Hi Hee,

I forgot to mention that I am using ChartDirector for .NET. Are you using .NET/C# or Java? (The syntax of your code can be C# or Java.)

Regards
Peter Kwan