java - Android MPAndroidChart xasis 值显示大于 1
问题描述
我正在使用 android java MPAndroidChart 库。从照片中可以看出,x 轴的值显示不止一个。我只想在星期二显示一次。我该怎么做 图表的图像
解决方案
您可以强制设置标签计数。这将导致仅在您的轴上生成一个标签。例如:
xAxis.setLabelCount(1, true)
从文档中:
/**
* sets the number of label entries for the y-axis max = 25, min = 2, default: 6, be aware
* that this number is not
* fixed (if force == false) and can only be approximated.
*
* @param count the number of y-axis labels that should be displayed
* @param force if enabled, the set label count will be forced, meaning that the exact
* specified count of labels will
* be drawn and evenly distributed alongside the axis - this might cause labels
* to have uneven values
*/
public void setLabelCount(int count, boolean force) {
setLabelCount(count);
mForceLabels = force;
}
您可以尝试的另一件事是更多地使用粒度。像这样:
axisLeft.granularity = 3F
从文档:
/**
* Set a minimum interval for the axis when zooming in. The axis is not allowed to go below
* that limit. This can be used to avoid label duplicating when zooming in.
*
* @param granularity
*/
public void setGranularity(float granularity) {
mGranularity = granularity;
// set this to true if it was disabled, as it makes no sense to call this method with granularity disabled
mGranularityEnabled = true;
}
推荐阅读
- kubernetes - Minikube 入口没有响应
- javascript - 将几个变量传递给函数 Jquery
- c++ - 使用带有结构不完整类型错误的模板
- c# - 何时使用全局变量(减少全局变量 vs DRY)
- python - python剥离文本和名称定义
- kubernetes - etcd 可以检测问题并为其他集群选举领导者吗?
- java - org.json.simple.JSONArray 不能转换为 org.json.simple.JSONObject 类
- sql - SQL Server 重复项 - 删除值
- javascript - 如何在运行另一个函数之前等待 fetch 完成
- php - 是否可以强制 PHP 代码继续运行,如果上传的文件超过此值时超过了诸如 upload_max_filesize 之类的 php.ini 指令?