How to embed legend in jfreechart categoryplot? - embed

I want to embed legend into categoryplot.
There is a example that is implemented with XYplot
(Embed the legend into the plot area of JFreeChart)
But, XYTitleAnnotation can be use only for XYplot.
How can I do it?

A CategoryPlot doesn't have the notion of XY coordinates, but a CategoryTextAnnotation can be positioned as outlined here.

Related

Angled div effect?

I was browsing though websites to get some inspiration and I came across this one: http://sozodesign.co.uk/
I was wondering how they got the angled div effect? Does anyone know of a tutorial/documentation they can forward to me?
Thanks,
Callum
Translate and Skew are the two transformation methods which are used in that website to get the desired effect.
The translate3d() function is used to translate the element by a vector
[tx, ty, tz], where tx is the translation along the x-axis, ty is the
translation along the y-axis, and tz is the translation along the
z-axis. The values tx, ty, and tz are provided either as a or
as a percentage.
The skew() method is used to skew an element along the X and Y-axis by
the given angles.
You can have a clear view on these and other transformation techniques at codrops

Add Html Text to Html5 Canvas

I got from a different Application a html formatted Text from user input.
(With font b br ul and so on, different fonts and colors in one fragment )
I would like to write this on a canvas.
like context.write("<b>Hello</b> World <font...>more text </font>");
how can i do this?
First, you'll have to make available to the canvas all the fonts you are using #font-face if needed.
Then you'll have to describe all the operations needed to draw the text, remember canvas is just a drawing surface. You'll have to iterate over these steps:
Specify the font to be used: (same syntax as the CSS font property)
context.font = "12px Arial bold"
Measure the string that will be drawn to know where to place the next one:
context.measureText(txt).width
Draw your text (fill or stroke):
context.fillText(txt, x, y)
This should help
https://developer.mozilla.org/en/Drawing_text_using_a_canvas
Though you would need to read the formats from the html and re-apply using this method.

Strange difference between HTML and SVG span rendering in Safari

This question is a little specific and I am hoping someone here can shed some light on a potential solution for me.
All of the following points are important:
I am writing some HTML pages that are going to be read on a third party hand-held device.
In order to fit the requirements of this device each word must be in a separate span, this is for an upcoming feature of the device that I am not allowed to go into, but it has to be formatted like this.
This HTML is being converted from SVG, the SVG is created from Adobe Illustrator documents.
The only place I have any control of the creation of the HTML is in the conversion from SVG to HTML.
My problem is this, in SVG text is broken down into "text" nodes and tspan nodes. Look at this simple SVG, note how I am changing the Y coord on the first tspan.
<text><tspan y="50">Hello</tspan><tspan> World</tspan></text>
When this renders in a webkit based browser, like safari, the sentence "Hello World" is displayed with the word "World" right next to the word "Hello".
In my converted HTML example:
<div><span style="position:absolute;top:50px;">Hello</span><span> World</span></div>
"Hello" is displayed with a y offset of 50, however "World" is displayed in the top left corner origin of the page.
This is frustrating as I do not have the coords of where the "World" span should be placed in the SVG (as Illustrator does not need this coord to render it correctly). Also, there may be one or more tspans in the SVG with altered positions which will prevent me from applying the style to the div.
In short, does anyone know if there is an attribute I can set to place the second span directly after the first?
Thanks
You could style the div instead of the span
<div style="position:absolute;top=50px;"><span>Hello</span><span> World</span></div>
That would keep text-chunks together and positioned relative to each other, but you could still have a span for every single word
Have figured this out after trying a bunch of different things.
It is actually very straightforward, however I didn't realise spans could be nested so I am going to let myself off.
<div><span style="position:absolute;top:50px;"><span>Hello</span><span> World</span></span></div>
The trick is to wrap all the words that need to be grouped together in a span. Hopefully this helps anyone who is stuck on a similar issue.

Creating a canvas on top of an SVG (or other image)

The reason for asking this question is because I want to be able to draw an arrow between two svg images. I want to use canvas to create the arrows, so firstly I generate the svgs then place a canvas on top of them to be able to draw the arrows.
I've tried using style=... but haven't had any luck as everytime I add the canvas element it just pushes my svg images to another pl
If there's no easy way to do this I'll just create arrows using SVG, I figured it would be more efficient to use canvas if I had to do lots of arrows in a short amount of time.
You need position:absolute on the CSS for the canvas to take it out of the flow, and then you can layer it as you like using z-index.
However, I instead suggest that you can use one or two tiny canvases to create the arrowheads and use toDataURL() on them to create a url you can use for <image> tags in the SVG. This way all your graphics are in SVG but you can use the canvas for complex raster effects if you need to.
have you tried z-index? it's a useful css trick
#svgcontent
{
z-index:1
}
#html5content
{
z-index:3
}
EDIT: accidentally screwed the #s up. 'scuse me.

Making the shadow from a ScatterViewItem a different shape

I am developing a program for Surface using Expression Blend and Visual Studio.
I have a custom user control with an ellipse and a label in a grid.
This will need to be placed in a scatterViewItem.
My problem is that the scatterviewitem will cast a rectangle shaped shadow under the ellipse shaped content. I can disable the shadow completely, but is there any way to make the shadow inherit the shape from its parent? Or can i set the shape of the scatterviewItem itself in any way?
Sorry but shaping the shadow directly is not possible... You have to create your own ChromeShadow. Take a look at the "ScatterPuzzle" Example from the Surface SDK.