I have an SVG figure that represents a name card for a person:
<svg
viewBox="0 0 300 100"
style="border: 1px solid black;"
>
<g>
<text x="5" y="25">Name</text>
<text x="120" y="25">Joe Smith</text>
</g>
<g>
<text x="5" y="55">Age</text>
<text x="120" y="55">55</text>
</g>
<g>
<text x="5" y="85">Occupation</text>
<text x="120" y="85">Astronaut</text>
</g>
</svg>
VoiceOver reads it like this:
Name, group
Name
End of, name, group
Joe Smith, group
Joe Smith
End of, Joe Smith, group
Age, group
Age
End of, Age, group
55, group
55
End of, 55, group
Occupation, group
Occupation
End of, Occupation, group
Astronaut, group
Astronaut
End of, Astronaut, group
It's very, very verbose. How do I modify this code to make VoiceOver read it like this?
Name
Joe Smith
Age
55
Occupation
Astronaut
I'm looking for a solution using SVG / ARIA. I know I can implement this using HTML and achieve better results in VoiceOver, but this is just a dummy example to illustrate the problem.
You can safely remove the <g> elements as they serve no real purpose for display (they are used for layering in an editor and as a possible point to apply transforms, styling etc.)
After doing that the element will read correctly.
I recommend using SVG OMG to optimise your SVGs, especially if they are large and complex graphics. You may still need to remove some <g> tags, you can safely do this just using a replace function on <g> and </g> (the hacky way!) or better yet use an XML reader / writer and do it properly!
Related
I'm trying to understand what the first and last number value in points attribute represent, but MDN doesn't seem to explain this, it actually says there needs to be two numbers, however I keep seeing this first and last pattern. I keep noticing that there are pairs of numbers, the values that represent the x and y axis of the point, however their is just a single number that isn't a pair at the beginning and end?
<svg height="210" width="500">
<polygon points="100,10 40,198 190,78 10,78 160,198">//what does first and last number mean?
<style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;" />
</svg>
You are misinterpreting the numbers and their separators.
In a points value like the following:
100,10 40,198 190,78 10,78 160,198
The X and Y coordinates are separated by a comma, and the pairs are separated by a space (but using a comma is also allowed here).
So there are five X,Y coordinate pairs: (100,10) (40,198) (190,78) (10,78) and (160,198)
I have a web page I have designed with a specific color scheme, and I want to have 4 specific colors from that scheme to be the only hues present in my images. Essentially, I want to collapse four ranges of hues to four discrete hues. Within one hue I want to maintain the existing tints/brightness variation.
I would like to perform this shift using CSS filters.
I believe I would use feColorMatrix or feComponenentTransfer, however I cannot find an example that shows how to do this kind of shift with 4 or more colors (I only see examples of shifting rgb to either 2 colors, or shifting individually red, green, and blue, so that you go from a certain three color structure to a different three color distribution).
I would like to shift the images so that they only contains these 4 hues:
rgb(82, 79, 161)
rgb(0, 173, 220)
rgb(242,235,22)
rgb(183, 36, 103)
To clarify, this is a visual representation about I would like to see things shift:
You can use this example image:
Here's some basic code/snippet to get you started:
.four_colors {
/*insert filter here */
}
<img class ="four_colors" src="http://i.stack.imgur.com/FGKUX.png">
If you can help, I'd appreciate it greatly!
This is not possible. The SVG Filter primitives that underly CSS Filters do not have HSL-aware primitives (although they should IMHO). Even the hue-rotate filter is a (bad) RGB approximation.
It is not possible to take hue ranges and posterize them. It IS possible to take RGB or brightness ranges and posterize them, so if you want to restate your question in that way, there are solutions. If you really want hue manipulation, you'll have to write that from scratch in Canvas.
By way of inspiration, here is an example of selective color selection using RGB in a filter:
http://codepen.io/mullany/pen/ApInK
<filter id="redselect" color-interpolation-filters="linearRGB">
<feColorMatrix in="SourceGraphic" result="BigRed"type="matrix" values="0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
3.8 -4 -4 0 -0.5" >
</feColorMatrix>
<feColorMatrix type="saturate" values="0" in="SourceGraphic" result="GreySource"/>
<feComposite operator="in" in="SourceGraphic" in2="BigRed" result="RedOriginal"/>
<feComposite operator="atop" in="RedOriginal" in2="GreySource" result="final"/>
</filter>
When describing paths in SVG, online examples often separate values with commas, while others don't.
The paths tutorial from the Mozilla Developer Network SVG Tutorial uses both notations to describe arcs:
A 30 50 0 0 1 162.55 162.45
and
A 45 45, 0, 0, 0, 125 125
Elsewhere, I have also seen:
A30,50 0 0,1 100,100
When and where do SVG path descriptions need commas?
Commas are mostly optional and whitespace is also mostly optional. You need one or the other in some cases to say when something ends and the next thing begins i.e. so that 1,1 or 1 1 is not parsed as 11.
You can put a single comma between any two numbers so A, 30 50 0 0 1 162.55 162.45 is invalid as is A 30,, 50 0 0 1 162.55 162.45
The W3C SVG Recommendation states that:
Superfluous white space and separators such as commas can be eliminated (e.g., "M 100 100 L 200 200" contains unnecessary spaces and could be expressed more compactly as "M100 100L200 200").
I want to create something like the below using pure SVG but without using a D3 chord or similar functionality.
I am able to create a polygon using bezier curves in SVG using standard path elements. But don't know how to fill that polygon with custom color. How to define the boundary of this polygon and set the fill property?
Any thoughts where grouping can help?
If you want to fill the region, you should use only one path element. You can chain the bezier curves together so that one starts where the last one ended. Then, add Z to the end of the path data to close the path.
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="300">
<path d="M480 150 C 300 200, 200 150, 20 200 C 15 150, 15 150, 20 100 C 200 100, 300 150, 480 150 Z" stroke="black" fill="red"></path>
</svg>
If you know where all of your end points and control points should go, it's no more difficult than making separate paths.
Here's a FIDDLE if you want to play around with the path data and see how the chaining works.
I am getting an extra empty row between data when I am importing it from the database and formatting the report in Excel sheet.
EDIT (clarification from a comment): The output in Excel shows an extra blank row between records and and extra blank column between fields.
Add net.sf.jasperreports.export.xls.remove.empty.space.between.columns and net.sf.jasperreports.export.xls.remove.empty.space.between.rows properties to report template.
net.sf.jasperreports.export.xls.remove.empty.space.between.columns - Specifies whether the empty spacer columns should be removed or not.
net.sf.jasperreports.export.xls.remove.empty.space.between.rows - Specifies whether the empty spacer rows should be removed or not.
The sample:
<jasperReport ...>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="net.sf.jasperreports.export.xls.remove.empty.space.between.columns" value="true"/>
<property name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows" value="true"/>
The information about configuration properties is here.
You can set isRemoveLineWhenBlank and isBlankWhenNull for textField element for hiding blank row.
The sample how to remove the whole line if the current textField is empty:
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true"/>
<textElement/>
<textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
</textField>
Another assumption is to change the height of all textField (or/and staticText) elements in the Band.
In case this design:
you will have a space between any two rows.
In case this design (textField height is equal to the Band's height):
the each line will be exactly under the other.
Every thing that Alex K states in his Dec 2 '11 answer is correct. But a few other settings may be helpful. These settings help when the text of the report stretches the detail band.
On every field in the detail band set:
positionType="Float"
stretchType="RelativeToTallestObject"
Example:
<detail>
<band height="20" splitType="Prevent">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" mode="Transparent" x="372" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{your column name}]]></textFieldExpression>
</textField>
This will force the all fields to be one height. The float setting tells the field to minimize the distance between the previous and next row. The RelativeToTallestObject setting tells all fields in the band to be the same height as the tallest field. These two settings help eliminate 'empty space' which shows up as unwanted cells in Excel.