0

SVG in Internet Explorer

asked 2010-09-15 04:51:32 +0800

SparkySpider gravatar image SparkySpider
444 1 3

Hi there,

Ok, we got the generating SVG down (http://www.zkoss.org/forum/listComment/13667). Now the question is how to get it to work in Internet Exolorer.

The object tag works well in Firefox, Opera, Safari and Chrome (tested myself). This is the code:

<window id="winLandingDashboard" apply="com.gpsbadger.schools.admin.LandingDashboardPanel">
<html>
<![CDATA[
<object data="chart.svg" width="640" height="480" type="image/svg+xml"/>
]]>
</html>
</window>

I wanted to use the SVGWeb JavaScript library, but it needs to be the script item in the page (not going to happen in an AJAX framework). Adobe doesn't support their SVG plugin anymore. Has anyone got some code that they can paste here that works?

Thanks,

Mark

delete flag offensive retag edit

8 Replies

Sort by ยป oldest newest

answered 2010-09-19 10:14:02 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi Mark
You have to install a plugin
http://www.planetsvg.com/content/svg-solutions-internet-explorer

link publish delete flag offensive edit

answered 2010-09-22 05:00:01 +0800

SparkySpider gravatar image SparkySpider
444 1 3

Yeah, unfortunately I can't fine one that works reliably. I think I'm going to package Batik to do my SVG for me. Any idea how to manipulate the data attribute of the Object tag in Java / ZUL. I see there is no support for <object/> in org.zkoss.zul

link publish delete flag offensive edit

answered 2010-09-22 20:02:28 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

another simple way is use iframe tag

<iframe src="rect.svg" width="300px" height="100px"/>

link publish delete flag offensive edit

answered 2010-09-25 05:00:07 +0800

SparkySpider gravatar image SparkySpider
444 1 3

Ok, good idea. Used an IFrame for now. I would like to know how to do it for future reference though, please. That is, access an attribute of an XHTML element:

Change the data attribute of the object tag from Java

<window id="winLandingDashboard" apply="com.gpsbadger.schools.admin.LandingDashboardPanel">
  <html>
    <![CDATA[
      <object data="chart.svg" width="640" height="480" type="image/svg+xml"/>
    ]]>
  </html>
</window>

link publish delete flag offensive edit

answered 2010-09-26 21:45:17 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

updated 2010-09-26 21:49:15 +0800

I have create a sample

<window>
	<button label="add svg" >
		<attribute name="onClick"><![CDATA[
			Map args = new HashMap();
			args.put("data", "circle.svg");
			Executions.createComponents("page1.zul", div ,args);
		]]></attribute>
	</button>
	<div id="div"/>
</window>

page1.zul

<html>
	<![CDATA[ 
		<object data="${arg.data}" width="640" height="480" type="image/svg+xml"/> 
	]]>
</html>

or just use zk iframe

<window>
	<button label="add svg" >
		<attribute name="onClick"><![CDATA[
			div.appendChild(new Iframe("circle.svg"));
		]]></attribute>
	</button>
	<div id="div"/>
</window>

link publish delete flag offensive edit

answered 2010-09-29 05:13:12 +0800

SparkySpider gravatar image SparkySpider
444 1 3

updated 2010-09-29 05:16:08 +0800

Hey Jimmy,

Any idea how to send a SVG onclick event back to ZK?

	<z:zk z:forEach="${chart.barxValues}">
		<z:zk z:onClick="alert('hello')">
			<text x="${each.middle}" y="${chart.chartBottom + 20}" text-anchor="middle" fill="black" stroke="none" stroke-width="0" font-size="10" font-family="Helvetica, Arial, Verdana">${edoList[forEachStatus.index].fullname}</text>
			<z:zk z:forEach="${edoList[forEachStatus.index].activityList}">
				<rect x="${forEachStatus.previous.each.left}" y="${area[forEachStatus.previous.index][forEachStatus.index].y}" width="${forEachStatus.previous.each.width}" height="${area[forEachStatus.previous.index][forEachStatus.index].height}" fill="${area[forEachStatus.previous.index][forEachStatus.index].colour}" stroke="none" style="opacity:${area[forEachStatus.previous.index][forEachStatus.index].backgroundOpacity};cursor:pointer;"/>
				<text x="${forEachStatus.previous.each.middle}" y="${area[forEachStatus.previous.index][forEachStatus.index].y + 11}" text-anchor="middle" fill="black" stroke="none" stroke-width="0" font-size="10" font-family="Helvetica, Arial, Verdana" style="opacity:${area[forEachStatus.previous.index][forEachStatus.index].textOpacity}">${area[forEachStatus.previous.index][forEachStatus.index].activity.name}</text>
			</z:zk>
		</z:zk>
	</z:zk>

Using <z:zk z:onClick="alert('hello')"> doesn't seem to work. I can't find a SVG tag that is both common to HTML and SVG that I can use as a wrapper. Plain SVG onClick works, but then I lose ZK and am using straight JavaScript.

Help appreciated...

link publish delete flag offensive edit

answered 2010-09-29 05:54:55 +0800

SparkySpider gravatar image SparkySpider
444 1 3

updated 2010-09-29 06:02:50 +0800

I tried your example to set the attribute of the object tag:

I have this in the zul:

		<window id="winVisual" xmlns:xhtml="http://www.w3.org/1999/xhtml">
			<xhtml:object id="objVisual" data="${winLandingDashboard$visualUrl}" width="1020" height="600" type="image/svg+xml"/>
		</window>

And this in my Java:

	public String getVisualUrl() {
		return currentSvgUrl;
	}

	public void update() {

		Executions.createComponents("LandingDashboardPanel.zul", winLandingDashboard.getFellow("winVisual"), null);

	}

But I'm getting:

org.zkoss.zk.ui.UiException: Replicated UUID is not allowed for class org.zkoss.zhtml.Object: objVisual

Can I not use some kind of an annotated data bind - or even easier, just create my own custom tag for Object, solving the problem?

link publish delete flag offensive edit

answered 2010-10-03 20:10:33 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

You can try canvas4z
http://docs.zkoss.org/wiki/How_To_Use_Canvas4Z
We not suggest use SVG
maybe You can try to use canvas4z to instead it

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-09-15 04:51:32 +0800

Seen: 886 times

Last updated: Oct 03 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More