I created a project with a storyBoard and when designing I used the 'view as iPhone11 PRO'. Now when I run the simulator on iPhone 11 MAX I get a hugh white bar on the right side. Ofcouse because the MAX has a bigger screen. Now I tried to set constraints, I tried a lot of different options by using tutorials etc (really a lot). But I just can't seem to get it working on my project.
The problem at the moment, I set all UIImage height and width and added missing constraints by using 'add missing constrains'. The only thing is, it doesn't do anything. I just expected that all images would be a little bit bigger so I'm having the same layout as on the 11 PRO.
ON THE LEFT THE iPHONE 11 PRO - ON THE RIGHT THE iPHONE 11 MAX
So, I guess the constraints are good but my images don't get bigger when running on a 11 MAX. What would be the best practise for this? (All my images are #x1 #x2 #x1)
"This is day 5 I'm trying..." - you should have spent those 5 days reading the docs and working through tutorials on auto-layout. As you have quickly found out, there is much more to it than positioning elements on a single sized screen and expecting it to look the same everywhere.
You are thinking that you need to make the "tiles" bigger for the larger screen, but what happens when a user runs your app on a smaller screen?
If you haven't learned about UIStackView yet, this may be hard to follow, but it is probably the way you want to go.
The "top" level of your layout has two equal-height sections. So...
We start with a Vertical stack view with Distribution: Fill Equally.
the top half has two equal width sections, so we embed a Horizontal stack view, also with *Fill Equally
the right-half of that section has another two equal-height elements, so we embed a Vertical stack view, also with *Fill Equally
the bottom half has two two equal-height elements, so we embed a Vertical stack view, *Fill Equally
the bottom half of that section has two equal width sections, so we embed a Horizontal stack view, *Fill Equally
All stack views have Spacing: 8
Now, to get it to fit on various screen sizes - while keeping the aspect ratios - we'll look at the overall size: Width is 360, and Height is 728 (we need to count the 8-pt spacing). So...
We'll give the outer-most stack view an Aspect Ratio of 360:728
We want to keep everything centered, so give the stack view CenterX and CenterY constraints.
An iPhone 11 Pro has a width of 375-pts, so to get your exact dimensions we need Leading and Trailing constraints (always to the safe-area) of 7.5
The Aspect Ratio constraint will handle the Height
We'll need to make a couple adjustments, and add a few more constraints, to handle other screen sizes...
That layout will "size up" to fit an 11 and an 11 Pro Max fine. However, on an iPhone 8 or 7 or SE, it will be too tall to fit the screen. To handle that, we can...
change the Leading and Trailing constraints to >= 7.5 (allowing the stack view to leave a little more space on the sides)
add Leading and Trailing constraints of Equal to Zero with Priority: 750 (Default High). That tells auto-layout to try to pull the sides to the edges
add Top and Bottom constraints of >= 0 to prevent it from extending above/below the screen
add Top and Bottom constraints of Equal to Zero with Priority: 750 (Default High). That tells auto-layout to try to pull the top and bottom to the edges
Here's how it looks in Storyboard:
Note that the image views have NO Constraints, and all stack views are set to Distribution: Fill Equally with Spacing: 8
Here's how that looks on various devices (very big image - click to see detail):
Because we cannot draw on "partial pixels" and some devices have 2 pixels-per-point and other devices have 3 pixels-per-point (we don't need to worry about #1x screens anymore) the actual sizes will not be exact - but they'll be close enough that you'd have to magnify and compare to see the differences.
Here is the source to a Storyboard with that layout so you can inspect it:
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="bdh-XY-7ei">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Schurk Images View Controller-->
<scene sceneID="Zle-Gp-apY">
<objects>
<viewController id="bdh-XY-7ei" customClass="SchurkImagesViewController" customModule="DelMe" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Dyb-Gm-pEf">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="Tyg-ff-xjO">
<rect key="frame" x="7.6666666666666572" y="47" width="360" height="728"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="JqK-ZW-H50">
<rect key="frame" x="0.0" y="0.0" width="360" height="360"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="AtH-1N-5xc">
<rect key="frame" x="0.0" y="0.0" width="176" height="360"/>
<color key="backgroundColor" red="0.55634254220000001" green="0.97934550050000002" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="qMO-ld-jJw">
<rect key="frame" x="184" y="0.0" width="176" height="360"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Yhc-Ph-1ck">
<rect key="frame" x="0.0" y="0.0" width="176" height="176"/>
<color key="backgroundColor" red="0.55634254220000001" green="0.97934550050000002" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="nhS-Od-9jO">
<rect key="frame" x="0.0" y="184" width="176" height="176"/>
<color key="backgroundColor" red="0.55634254220000001" green="0.97934550050000002" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
</subviews>
</stackView>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="WrS-eH-b3H">
<rect key="frame" x="0.0" y="368" width="360" height="360"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="won-nT-d54">
<rect key="frame" x="0.0" y="0.0" width="360" height="176"/>
<color key="backgroundColor" red="0.55634254220000001" green="0.97934550050000002" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="iS7-mQ-dnf">
<rect key="frame" x="0.0" y="184" width="360" height="176"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="xcJ-dz-KeY">
<rect key="frame" x="0.0" y="0.0" width="176" height="176"/>
<color key="backgroundColor" red="0.55634254220000001" green="0.97934550050000002" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0FQ-rZ-x81">
<rect key="frame" x="184" y="0.0" width="176" height="176"/>
<color key="backgroundColor" red="0.55634254220000001" green="0.97934550050000002" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
</subviews>
</stackView>
</subviews>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="width" secondItem="Tyg-ff-xjO" secondAttribute="height" multiplier="360:728" id="SdN-id-c4g"/>
</constraints>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="Q0H-gV-XLg"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="Tyg-ff-xjO" firstAttribute="top" secondItem="Q0H-gV-XLg" secondAttribute="top" priority="750" id="2Ih-jC-mAG"/>
<constraint firstItem="Tyg-ff-xjO" firstAttribute="centerY" secondItem="Q0H-gV-XLg" secondAttribute="centerY" id="EnC-xv-6e3"/>
<constraint firstItem="Tyg-ff-xjO" firstAttribute="top" relation="greaterThanOrEqual" secondItem="Q0H-gV-XLg" secondAttribute="top" id="KBQ-9p-3NJ"/>
<constraint firstItem="Q0H-gV-XLg" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Tyg-ff-xjO" secondAttribute="trailing" constant="7.5" id="KP5-ws-DRX"/>
<constraint firstItem="Tyg-ff-xjO" firstAttribute="leading" secondItem="Q0H-gV-XLg" secondAttribute="leading" priority="750" id="LSW-Dg-4V8"/>
<constraint firstItem="Q0H-gV-XLg" firstAttribute="bottom" secondItem="Tyg-ff-xjO" secondAttribute="bottom" priority="750" id="N6T-iS-PU1"/>
<constraint firstItem="Q0H-gV-XLg" firstAttribute="trailing" secondItem="Tyg-ff-xjO" secondAttribute="trailing" priority="750" id="V1E-M5-o7w"/>
<constraint firstItem="Q0H-gV-XLg" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="Tyg-ff-xjO" secondAttribute="bottom" id="gVs-hN-gNr"/>
<constraint firstItem="Tyg-ff-xjO" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Q0H-gV-XLg" secondAttribute="leading" constant="7.5" id="gih-7i-tg8"/>
<constraint firstItem="Tyg-ff-xjO" firstAttribute="centerX" secondItem="Q0H-gV-XLg" secondAttribute="centerX" id="knQ-zw-EAq"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ddD-Pk-Baz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-407" y="1534"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Each UIImage will not change size dynamically with different screen sizes because you set width and height constraints to constants.
I'd suggest removing the constraints on each UIImage and instead add them to a UIStackView. Add constraints to pin the edges of the UIStackView to the view's safeAreaLayoutGuide. The UIStackView will handle resizing your UIImage's based on it's alignment and distribution properties.
Documentation on UIStackView: https://developer.apple.com/documentation/uikit/uistackview
Related
I am trying to retrieve the string "This is my string" that belongs to text id="short_name
I have tried:
$SVGTemplate = Get-Content "C:\temp\sample.svg
$SVGTemplate = [XML]$SVGTemplate
$SVGTemplateShortName = Select-Xml -Xml $SVGTemplate -XPath '/s:svg/s:g/s:g[#id="short_name"]/s:text/text()' -Namespace #{s = "http://www.w3.org/2000/svg"}
$SVGTemplateShortName.node.value
But it returns an empty value. This used to work before and recently broke because I had to redesign the svg graphic.
I have tried to correct the XPath many times and it keeps returning an empty value. What could I be doing wrong?
Below is my xml file.
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 26.5.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
<style type="text/css">
.st0{fill:#E30613;}
.st1{fill:#FFFFFF;}
.st2{fill:#009FE3;}
.st3{fill:none;}
.st4{font-family:'MyriadPro-Regular';}
.st5{font-size:88px;}
.st6{fill:#008D36;}
</style>
<g id="background">
<rect id="stroke" class="st0" width="500" height="500"/>
<rect id="Fill" x="12" y="12" class="st1" width="476" height="476"/>
</g>
<g id="short">
<rect id="short_fill" x="12" y="400" class="st2" width="476" height="100"/>
<rect y="412" class="st3" width="500" height="88"/>
<text id="short_name" transform="matrix(1 0 0 1 87.7305 474.4795)" class="st1 st4 st5">This is my string</text>
</g>
<g id="hud">
<rect id="left" x="12" y="12" class="st6" width="92" height="76"/>
<rect id="right" x="396" y="12" width="92" height="76"/>
</g>
<g id="graphic">
<g id="Card_Symbl">
<g id="Layer_10">
<polygon class="st0" points="309.9,387.1 396.3,124.5 303.1,105.8 96.5,251.1 "/>
</g>
</g>
</g>
</svg>
If you want to locate an element by its full path, an easier way is to use PowerShell's member access:
$SVGTemplate.svg.g.text | Where-Object id -eq 'short_name' | ForEach-Object '#text'
... or more succinct, using intrinsic .Where method:
$SVGTemplate.svg.g.text.Where{ $_.id -eq 'short_name'}.'#text'
XPath does have an advantage if you want to locate an element regardless of how deep it is nested (relative path, introduced by double slash):
$SVGTemplate |
Select-Xml -XPath '//s:text[#id="short_name"]' -Namespace #{s = "http://www.w3.org/2000/svg"} |
ForEach-Object { $_.Node.'#text' }
Of course it also works using the absolute path (introduced using single slash), but is much more lengthy than its member access counterpart:
$SVGTemplate |
Select-Xml -XPath '/s:svg/s:g/s:text[#id="short_name"]' -Namespace #{s = "http://www.w3.org/2000/svg"} |
ForEach-Object { $_.Node.'#text' }
The original XPath expects a <g> tag with an id attribute and a value of "short_name"... however the XML does not contain such a path. Was it supposed to read `/s:text[#id="short_name"]?
Other than that, yes anyone can use PS´s "human-friendly" access methods... though there is a bit of an inherent danger there when there is no schema attached to the XML or when trying to access optional nodes that might or might not be there for a given path.
PS works with lists. XML paths break when using $xmlDoc.tagA.tagB.tagC notation; assuming this is not $null and is a list longer than exactly one (1) node then we have no way of telling where in the XML and under possibly what conditions we got those nodes from.
... When in doubt: don't.
I want to insert a new column in my report to graphically display a "needle" displaying the position in a range of 0% - 100% like so:
I am looking for ideas please!
My idea
Use graphic (rainbow 0%-100% in every detail column).
Use a pixel offset (somehow??) where I simply place an overly large "|" type. So if 0%-100% are 200px that would mean that to display the needle at 50% I would offset the type 100px!
The easiest / most straightforward option I have found and implemented:
<image scaleImage="RetainShape" onErrorType="Blank">
<reportElement x="575" y="1" width="100" height="13" uuid="7cf54aff-65ac-40e5-8dc9-7f95d6f34d49"/>
<imageExpression>
<![CDATA[net.sf.jasperreports.renderers.BatikRenderer.getInstanceFromText("
<svg id=\"Layer_1\" data-name=\"Layer 1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"100\" height=\"13\" viewBox=\"0 0 100 13\">
<defs>
<linearGradient id=\"linear-gradient\" x1=\"-176.88\" y1=\"316.13\" x2=\"-150.45\" y2=\"316.13\" gradientTransform=\"matrix(3.78, 0, 0, -3.78, 689.01, 1202.56)\" gradientUnits=\"userSpaceOnUse\">
<stop offset=\"0\" stop-color=\"green\"/>
<stop offset=\"1\" stop-color=\"green\" stop-opacity=\"0\"/>
</linearGradient>
</defs>
<path d=\"M0,1.26H100v10.4H0Z\" style=\"fill: url(#linear-gradient)\"/>
<path d=\"M" + !!! OFFSET CALCULATION !!! + ",0V13\" style=\"fill: none;stroke: #000\"/>
</svg>
")]]></imageExpression>
</image>
Result:
I can't get these sliders to line up, Im not sure why.
here's my storyboard ...that trailing constraint is clearly being ignored. What am I doing wrong?
edit: for matt:
I deleted all constraints
and control-dragged two of them, which should have been sufficient: the trailing: 14 and the center Y (now on superview, the rhs being label was in error). there is no "remove at runtime" on any drawn constraints.
the flags are visible but there's no indication of what they mean (the size inspector unhelpfully says only "has ambiguous constraint").
edit #2
Based on input here and in swift discord, Here's an example of the view with changes applied:
and here is the relevant xml of that storyboard:
<tableViewCell clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" restorationIdentifier="RootAppCell" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="RootAppCell" id="PDl-Cx-SrR" customClass="RootAppCell" customModule="Assignment_5">
<rect key="frame" x="0.0" y="28" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="PDl-Cx-SrR" id="EHS-uv-XgI" customClass="RootAppCell" customModule="Assignment_5">
<rect key="frame" x="0.0" y="0.0" width="343" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uDJ-B5-x3A">
<rect key="frame" x="277" y="6" width="51" height="31"/>
</switch>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="App Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fWL-xO-z8g">
<rect key="frame" x="18" y="11" width="81" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="fWL-xO-z8g" firstAttribute="centerY" secondItem="EHS-uv-XgI" secondAttribute="centerY" id="G84-Ys-Q8G"/>
<constraint firstItem="fWL-xO-z8g" firstAttribute="leading" secondItem="EHS-uv-XgI" secondAttribute="leadingMargin" constant="3" id="JrD-j0-SxV"/>
<constraint firstItem="uDJ-B5-x3A" firstAttribute="centerY" secondItem="EHS-uv-XgI" secondAttribute="centerY" id="Q5Q-sy-Qh7"/>
<constraint firstAttribute="trailingMargin" secondItem="uDJ-B5-x3A" secondAttribute="trailing" constant="2" id="bMt-16-diy"/>
<constraint firstItem="uDJ-B5-x3A" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="fWL-xO-z8g" secondAttribute="trailing" id="he7-G6-aBc"/>
</constraints>
</tableViewCellContentView>
If you are unclear on which constraints that are conflicting, take a look at the console output when you load the screen, you should be able to see something that looks similar to this
(
"<NSLayoutConstraint:0x6199cd0 UIButton:0x7fbbf90.width == 0 (active)>",
"<NSLayoutConstraint:0x6998ec0 H:|-(15)-[UILabel:0x6ce60] (active, names: '|':UIButton:0x7fbbf90 )>",
"<NSLayoutConstraint:0x6199000 H:[UILabel:0x6ce60]-(15)-| (active, names: '|':UIButton:0x7fbbf90 )>"
)
And to help even further, you can use this web page to paste that section and it will at least tell you which constraints that are conflicting in your code..
https://www.wtfautolayout.com/
Table view cells can be tricky since they will get additional constraints based on for instance what you have set as row height of the cell etc.
Hope this helps the debugging
This is what I tried, and worked well for me:
Add Constraints:
Leading of the UILabel from superView is 15.
Center Y of UILabel is equal to superView's center Y.
Bottom of UIView (divider view) from superView is 0
Trailing of UIView (divider view) from superView is 0
Leading of UIView (divider view) from superView is 0
Horizontal space between UILabel and UISwitch is 5.
Center Y of UISwitch is equal to superView's center Y.
Trailing of the UISwitch from the superview is 10.
One more extra constraint needed for UIView (divider view) that is Height of the view is 1.
Here is the output:
Hope this will help you!!
I have created lables dynamically in my storyboard.
now i want to name those lables.
i am having no idea what should i do.
this is my code:
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Data Updated on July 7, 2012" textAlignment="right" lineBreakMode="tailTruncation" minimumFontSize="10" id="ovU-eL-SMN">
<rect key="frame" x="313" y="961" width="444" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.047058823530000002" green="0.0" blue="0.35294117650000001" alpha="1" colorSpace="calibratedRGB"/>
<color key="highlightedColor" cocoaTouchSystemColor="darkTextColor"/>
</label>
here, i am using html code in storyboard.i am fetching value from database and put those values as lable text.I just have to name it and the value has to be passed in appdelegate
this is the mainstoryboard file
You can set tag property of each label like 10 , 11 , 12 as many you have label.
Then
for(int i=10 ;i<last_label_Tag;i++)
{
UILabel *lbl=(UILabel*)[self.view viewWithTag:i];
lbl.text=#"Define text for the labels"// or you can use separate Labels without loop.
}
Good morning! I'm having a problem with Jaspersoft iReport 4.5.0, and I was hoping for some help. Basically, when I display an xy line chart, it's attempting to add a label on the x-axis for each data point. I have almost 200 data points, so this ends up looking like just a solid line, even if I tweak the rotation of the tick labels or whatever.
I'm aware that the general response to this question is to use a timeseries chart instead. This would ordinarily work, but in my instance I am using a multi-axis chart where the opposite axis is a bar chart. Since a bar chart has no timeseries variety, iReport will not allow me to mix a bar chart with a timeseries chart, forcing me to use the xy line chart.
Is there any way I can have my cake and eat it, too? Some way I can filter out some of the labels? Or perhaps limit the number of labels that can be displayed, spread out over the x-axis? I have yet to see a definitive answer anywhere on the internet!
Thanks in advance!
- Ian
EDIT: Here is the jrxml for one of the multi-axis charts I'd like to modify:
<multiAxisChart>
<chart evaluationTime="Report" hyperlinkType="LocalAnchor">
<reportElement x="42" y="441" width="440" height="292"/>
<chartTitle position="Top">
<titleExpression><![CDATA["CICS Elapsed"]]></titleExpression>
</chartTitle>
<chartSubtitle/>
<chartLegend/>
<anchorNameExpression><![CDATA["CICS Elapsed Small"]]></anchorNameExpression>
<hyperlinkAnchorExpression><![CDATA["CICS Elapsed Big"]]></hyperlinkAnchorExpression>
<hyperlinkTooltipExpression><![CDATA["Click to Enlarge"]]></hyperlinkTooltipExpression>
</chart>
<multiAxisPlot>
<plot/>
<axis position="leftOrTop">
<lineChart>
<chart>
<reportElement x="0" y="0" width="0" height="0" backcolor="#FFFFFF"/>
<chartTitle position="Top" color="#000000">
<titleExpression><![CDATA["CICS Elapsed"]]></titleExpression>
</chartTitle>
<chartSubtitle color="#000000"/>
<chartLegend textColor="#000000" backgroundColor="#FFFFFF"/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="wmprod_cics"/>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["Cpu Time"]]></seriesExpression>
<categoryExpression><![CDATA[$F{TIMESTAMP}]]></categoryExpression>
<valueExpression><![CDATA[$F{ELAPSTIME}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot isShowShapes="false">
<plot/>
<categoryAxisLabelExpression><![CDATA["Date/Time"]]></categoryAxisLabelExpression>
<valueAxisLabelExpression><![CDATA["Avg Elapsed Time (ms)"]]></valueAxisLabelExpression>
</linePlot>
</lineChart>
</axis>
<axis position="rightOrBottom">
<barChart>
<chart>
<reportElement x="0" y="0" width="0" height="0" backcolor="#FFFFFF"/>
<chartTitle position="Top" color="#000000">
<titleExpression><![CDATA["CICS Elapsed"]]></titleExpression>
</chartTitle>
<chartSubtitle color="#000000"/>
<chartLegend textColor="#000000" backgroundColor="#FFFFFF"/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="wmprod_cics"/>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["Volume (transactions)"]]></seriesExpression>
<categoryExpression><![CDATA[$F{TIMESTAMP}]]></categoryExpression>
<valueExpression><![CDATA[$F{TRANSCOMPL}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot/>
<itemLabel/>
<valueAxisLabelExpression><![CDATA["Volume (transactions)"]]></valueAxisLabelExpression>
</barPlot>
</barChart>
</axis>
</multiAxisPlot>
</multiAxisChart>
I had the same problem. I think the answer is this:
<chart>
<reportElement x="0" y="0" width="802" height="215">
<property name="net.sf.jasperreports.chart.domain.axis.tick.interval" value="1"/>
</reportElement>
Set the tick interval as appropriate. Note: My chart was a scatter chart. Untested with line chart.