热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

iOS图表-设置最小的y轴范围。-iOSCharts-setminimumyaxisrange

ImusingthefabulousiOSChartslibrary(https:github.comdanielgindiios-charts)andImhaving

I'm using the fabulous iOS Charts library (https://github.com/danielgindi/ios-charts) and I'm having a hard time finding anything to support this behavior in the documentation. I'd like to force the y-axis to always display a range from 0-35. Currently, if I only have one data entry in at say (0, 9) the y-axis will display its range as 0-9. However when I add another entry at (1, 32) suddenly I can see the top of the graph at 35.

我正在使用令人难以置信的iOS Charts库(https://github.com/danielgindi/ios-charts),我在文档中很难找到支持这种行为的任何东西。我想强迫y轴总是显示0-35的范围。目前,如果我只有一个数据输入(0,9),y轴将显示其范围为0-9。然而,当我在(1,32)中添加另一个条目时,我突然可以看到图的顶部是35。

There are three methods that look promising (because they're related) but they aren't quite providing the type of behavior that I'm looking for.

有三种方法看起来很有前途(因为它们是相关的),但是它们并不能提供我所要寻找的行为类型。

1: Chart.setVisibleYRangeMaximum (if only it were Minimum...)

1:图表。setVisibleYRangeMaximum(如果它是最小的…)

2: Chart.setVisibleXRangeMaximum (useless again...)

2:图表。setVisibleXRangeMaximum(无用的了…)

3: Chart.setVisibleXRangeMinimum (now where's your YRange cousin?!)

3:图表。setvisiblexrangimum(现在你的YRange表兄弟在哪里?!)

So anyways, that's where I'm at. I've read documentation but to no avail. Help me SO?

无论如何,这就是我现在的处境。我读过文档,但都没用。帮我吗?

3 个解决方案

#1


9  

customAxisMin is Deprecated in latest Charts.

在最新的图表中,customAxisMin被弃用。

Use property axisMinValue instead!

使用属性axisMinValue相反!

#2


8  

Take a look at below properties. Should be able to solve your problem.

看看下面的属性。应该能够解决你的问题。

/// A custom minimum value for this axis. 
/// If set, this value will not be calculated automatically depending on the provided data. 
/// Use resetCustomAxisMin() to undo this. 
/// Do not forget to set startAtZeroEnabled = false if you use this method.
/// Otherwise, the axis-minimum value will still be forced to 0.
public var customAxisMin = Double.NaN

/// Set a custom maximum value for this axis. 
/// If set, this value will not be calculated automatically depending on the provided data. 
/// Use resetCustomAxisMax() to undo this.
public var customAxisMax = Double.NaN

/// if true, the y-label entries will always start at zero
public var startAtZeroEnabled = true

For example:

例如:

_chartView.leftAxis.customAxisMax = 35;
_chartView.leftAxis.customAxisMin = 0;

or _chartView.leftAxis.startAtZeroEnabled = YES;

或_chartView.leftAxis。startAtZeroEnabled =是的;

#3


2  

For Charts 3 (tried on Charts 3.0.2), this works:

对于图表3(在图表3.0.2中进行了尝试),这是可行的:

chartView.leftAxis.axisMinimum = 0

By default there is a rightAxis as well (at least for bar charts) and the grid won't be aligned if you don't also set:

默认情况下,也有一个右对齐(至少对于条形图),如果你不设置,网格就不会对齐:

chartView.rightAxis.axisMinimum = 0

Note: I wrote this as a comment initially but I think it should be an answer to be easier to find for people who end up here from Google.

注意:我最初是作为评论写的,但我认为这应该是一个更容易找到的答案,因为人们从谷歌结束。


推荐阅读
  • 在寻找轻量级Ruby Web框架的过程中,您可能会遇到Sinatra和Ramaze。两者都以简洁、轻便著称,但它们之间存在一些关键区别。本文将探讨这些差异,并提供详细的分析,帮助您做出最佳选择。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 本文详细介绍了Java中org.eclipse.ui.forms.widgets.ExpandableComposite类的addExpansionListener()方法,并提供了多个实际代码示例,帮助开发者更好地理解和使用该方法。这些示例来源于多个知名开源项目,具有很高的参考价值。 ... [详细]
  • 本章将深入探讨移动 UI 设计的核心原则,帮助开发者构建简洁、高效且用户友好的界面。通过学习设计规则和用户体验优化技巧,您将能够创建出既美观又实用的移动应用。 ... [详细]
  • Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 本文基于刘洪波老师的《英文词根词缀精讲》,深入探讨了多个重要词根词缀的起源及其相关词汇,帮助读者更好地理解和记忆英语单词。 ... [详细]
  • 1.如何在运行状态查看源代码?查看函数的源代码,我们通常会使用IDE来完成。比如在PyCharm中,你可以Ctrl+鼠标点击进入函数的源代码。那如果没有IDE呢?当我们想使用一个函 ... [详细]
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 使用 Azure Service Principal 和 Microsoft Graph API 获取 AAD 用户列表
    本文介绍了一段通用代码示例,该代码不仅能够操作 Azure Active Directory (AAD),还可以通过 Azure Service Principal 的授权访问和管理 Azure 订阅资源。Azure 的架构可以分为两个层级:AAD 和 Subscription。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • Android 渐变圆环加载控件实现
    本文介绍了如何在 Android 中创建一个自定义的渐变圆环加载控件,该控件已在多个知名应用中使用。我们将详细探讨其工作原理和实现方法。 ... [详细]
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • 题目Link题目学习link1题目学习link2题目学习link3%%%受益匪浅!-----&# ... [详细]
author-avatar
司文龙2502933797
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有