如何在图表JS中阻止轴标签被切断?

时间:2017-10-02 16:52:19

标签: javascript chart.js

如何阻止图表切断轴标签字?这个问题类似:" How do I prevent the scale labels from being cut off in chartjs?"但只能解决刻度线上的标签。

轴标签应该说"心理健康连续体"。但是public static func transferImage(toAlbum albumName:String, withID imageID:String, onSuccess success:@escaping(String)->Void, onFailure failure:@escaping(Error?)->Void){ guard let album = self.getAlbum(withName: albumName) else{ ... failure here, albumNotFoundError return; } if(self.hasImageInAlbum(withIdentifier: imageID, fromAlbum: albunName)){ ... failure here, image already exists in the album, do not make another return; } let theAsset = self.getExistingAsset(withLocalIdentifier: imageID); if(theAsset == nil){ ... failure, no asset for asset id return; } PHPhotoLibrary.shared().performChanges({ let albumChangeRequest = PHAssetCollectionChangeRequest(for: album); let changeRequest = PHAssetChangeRequest.init(for: theAsset!); let enumeration:NSArray = [theAsset!]; let cnt = album.estimatedAssetCount; if(cnt == 0){ albumChangeRequest?.addAssets(enumeration); }else{ albumChangeRequest?.inserAssets(enumeration, at: [0]); } }){didSucceed, error) in OperationQueue.main.addOperation({ didSucceed ? success(imageID) : failure(error); }) } } 被切断了。

Chart cut off

1 个答案:

答案 0 :(得分:1)

您可以通过在图表上设置布局填充来解决此问题。

options: {
  layout: {
    padding: {
      top: 20
    }
  }
}

这是参考 http://www.chartjs.org/docs/latest/configuration/layout.html