vue.js - 如何使用 D3 和 Vue 本地化和格式化刻度
问题描述
我vue-i18n
用来格式化日期,如下所示:
const setDateTimeFormats = {
short: {
year: 'numeric',
month: 'long',
day: 'numeric',
},
};
export const dateTimeFormats = {
en: setDateTimeFormats,
ja: setDateTimeFormats,
};
然后像这样调用它:
checkedOn() {
return this.$d(moment(checkedOn), 'short');
},
但我不知道如何在同一个项目中使用 D3 本地化和格式化刻度。
这是与蜱有关的一点(仅显示从Jan
现在到现在 的月份Jan Feb Mar Apr May Jun Jul Aug Sep
:)
const x = scaleTime()
.domain([moment('2020-01-01').toDate(), moment().toDate()])
.range([0, width]);
svg.append('g')
.attr('class', 'xaxis')
.attr('transform', `translate(0, ${height})`)
.call(axisBottom(x).tickFormat(timeFormat('%b')));
解决方案
推荐阅读
- c# - 为什么当我尝试在 RecData() 方法中接收数据时,我的 udp 客户端没有抛出异常?
- docker - Docker 运行:无效的参考格式
- python - 读取文本文件并将其解析到结构 json 文件中 - 在 json 文件中返回不需要的键和 null/dict
- r - 在绘制“tmap”库期间在“R”中将标签放置在绘图区域之外(部分)
- powershell - 加载表格后,检查列表中的项目并倒计时
- infopath - 如何在 InfoPath 日期字段中限制日期值以允许从今天起 45 天的范围?
- java - 如何从java中的方法重定向到jsp?
- google-cloud-platform - 在 Google Cloud Platform Console 上启用 Google Ads API 的问题
- c# - 寻求诊断 SQL IndexOutOfRangeException 和 SQLException 的帮助
- php - 正确注释类方法返回值