Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to change a background image in a chart dynamically?

My customer wants to have a water print of his own choice to be displayed in a chart. Therefore I´m looking for a dynamic solution in order to modify the background image of a chart (not a text object).

Any idea??

Thanks in advance!

3 Replies
Not applicable
Author

First, you want to set up the chart background using Dynamic Image. You then want to set that Dynamic Image to a variable value. For example:

=$(vImage)

I found you must have the equals sign for it to work.

Then for your variable value, you enter the path. I needed single quotes around the path.

Now, the hard part is letting the user pick the image. I've used Excel automation to give the user a file select box in a macro. For a macro, you could use something like:

Set oXL=CreateObject("Excel.Application")

f_name=oXL.GetOpenFilename("All Files (*.*),*.*",,"Select file",False)

If f_name="False" then
'user cancelled out of dialog box
Set oXL=nothing
Exit sub
End If

ActiveDocument.Variables("vImage").SetContent "'" & f_name & "'", true

Set oXL=nothing


You may have to tweak it a bit, but that should work for you.

Not applicable
Author

as far as i know there is no API method to programmatically set the background image of a sheet object (background image are not just referenced by their path in the document, they are fully embedded in it), you must use the sheet object properties dialog box to set it manually

anyway, i'm interested in a workaround if someone has one

Not applicable
Author

Thanks for the replies. When using V9.0 a solution for a dynamic background could look like this. The user has an excel table where he can insert the file names of the bitmaps to be displayed as background image.

BackgroundImage:

DIRECTORY Images;

LOAD Report, Bitmap

FROM

[Images.xls]

(biff, embedded labels, table is Tabelle1$);

LET LocReport = 35;

FOR i = 1 TO LocReport

LET LocImage = 'LocImage' & num(i,'00');

LET LocBitmap = lookup('Bitmap','Report',num(i,'00'), 'BackgroundImage');

IF LocBitmap <> NULL THEN

LET $(LocImage) = '.\Images\' & LocBitmap;

ELSE

SET $(LocImage) = '';

ENDIF

NEXT

DIRECTORY;

and e.g. =$('LocImage35')

as dynamic picture in the chart properties.

Regards

Christian