How can we make the echarts responsive - echarts

Charts responsive - When we take a view of chart in higher resolution screens, it will change the width responsively according to viewport width.

Resize chart on menu width change and window resize
var myChart = echarts.init(document.getElementById('ChartDivID'));
$(window).on('resize', resize);
// Resize function
function resize() {
setTimeout(function () {
// Resize chart
myChart.resize();
}, 200);
}

Related

How to Set UIImageView in circle Swift 5

This code is only working with fix height and width. How can Round UIImageView when we use multiplier?
Here, is the code that Circle my ImageView. Width and Height is 300.
class MusicViewController: UIViewController {
#IBOutlet weak var imgAlbum: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
imgAlbum.layer.borderWidth = 1
imgAlbum.layer.masksToBounds = false
imgAlbum.layer.borderColor = UIColor.black.cgColor
imgAlbum.layer.cornerRadius = imgAlbum.frame.height/2
imgAlbum.clipsToBounds = true
}
}
If I change my height and width to multiplier like. Now, the multiplier of Height 0.5 and width 0.8.
(Proportional height and width to SuperView)
As #RajaKishan and #aiwiguna both said that you can't get a square image with both proportional height and width constraint together because then you can not get a round circle with different height and width.
You can set width or height proportional to superview and set the aspect ratio to 1:1 then you can change the multiplier and get the circle properly. You can check to attached image for constraints
then set cornerRadius in viewDidLayoutSubviews(), not in viewDidLoad(). (viewDidLoad() is called before the layout constraints change the view height, and only once. viewDidLayoutSubviews() is called any time your view's geometry changes, so you should invoke any layout logic there.
override func viewDidLayoutSubviews() {
self.yourImageView.layer.cornerRadius = self.yourImageView.bounds.height/2
self.yourImageView.clipsToBounds = true
}
you will not get a square by using proportional width and proportional height constraint together like that, in different device it will have different height and width
my suggestion is to use only one proportional width or proportional height (which one you want) and use aspect ratio constraint 1:1 on the view

The content of UILabel is being truncated after rotation in Swift 4

I am using AutoLayout. I have a view with %10 width and 200 fixed height. I placed a UILabel into that view with 0 margins. Then I am rotating the UILabel, changing the content and calling sizeToFit() function. At the load of the controller the rotation works but the content is being truncated. After I did a button click on the controller, the UILabel is being enlarged and content is being fit.
What should I do to avoid this problem?
Note: I checked the width and height of the label's frame with debugging. After sizeToFit() the width and height of the frame changes as expected. However, the UI is not refreshing. I also tried label.setNeedsLayout() and label.layoutIfNeeded() but nothing changed.
For rotation I am using below extension:
extension UILabel {
#IBInspectable
var rotation: Int {
get {
return 0
} set {
let radians = CGFloat(CGFloat(Double.pi) * CGFloat(newValue) / CGFloat(180.0))
self.transform = CGAffineTransform(rotationAngle: radians)
}
}
}
You can try view.layoutIfNeeded() instead of label.layoutIfNeeded()

How to Make NSVisualEffectView That Only Appears When Content is Beneath It

I am working on a macOS application that makes use of NSVisualEffectView to achieve transparency. I want to achieve an effect similar to that of iOS' Cover Sheet widget view. Notice how when you scroll up, content a blur appears around the search bar. I want do this in a macOS app so that when content in a table view is scrolled beneath a certain point an NSVisualEffectView blurs it. How would I do this? Thanks in advance.
Create a instance of Visual Effect View as following and set on window:
func setVisualEffectToWindow(window: NSWindow) {
// create the visual effect view
var blurryView = NSVisualEffectView(frame: NSRect(x: 0, y: 0, width: 800, height: 600)) //Create with size you want or you can use window content bound here
// this is default value but is here for clarity
blurryView.blendingMode = NSVisualEffectBlendingMode.BehindWindow
// set the background to always be the dark blur
blurryView.material = NSVisualEffectMaterial.Dark
// set it to always be blurry regardless of window state
blurryView.state = NSVisualEffectState.Active
window.contentView.addSubview(blurryView)
}

Image doesn't load inside a frame

I have an app where I load an Image inside a Frame on a ViewCell. On Windows Phone 8.1 the image doesn't show the first time the page is shown, but if I navigate to another page and then return, it loads. Android and iOS work fine.
The problem is the Frame, because if I set the Image as the ViewCell's Content, it loads normally.
View = new Frame {
Content = new Image {
Source = "img.png"
}
};
Debugging I found out that both the Width and Height of the Image are -1. MinimiumWidthRequest and MinimumHeightRequest have no effect. I also tried using the FFImageLoading library, to no avail.
I use the frame so I can put a black border on it using a custom renderer.
Any help would be much appreciated.
You can use StackLayout instead of Frame:
View = new StackLayout {
Children = new Image {
Source = "img.png"
}};

How do I set the bar width static in a horizontal bar chart in ios-charts?

How can you set the bar width on a horizontal bar chart in the ios-charts library? It seems that the width is based off the size of the frame drawn for the chart. Therefore it spaces each bar to a size that almost fills the container. Is there any way to override this?
Yes I remember it will calculate the bar width to fit for the screen.
There are two properties:
barSpace
groupSpace
These two defines the bar width and the space for grouped bars. It is a little obscured to understand by its name, so you need to read the code.
There is also a barSpace property inside the barDataSet you could use to custimze:
/// space indicator between the bars in percentage of the whole width of one value (0.15 == 15% of bar width)
public var barSpace: CGFloat = 0.15
The groupSpace can be customized in barChartData:
private var _groupSpace = CGFloat(0.8)
/// The spacing is relative to a full bar width
public var groupSpace: CGFloat
{
get
{
return _groupSpace
}
set
{
_groupSpace = newValue
}
}
Overriding them requires you have a better understanding, especially you want to override the renderer.