带有Appsmith和自定义粉状图表的时轴格式
我使用自定义融合图表(散点图),并且已经加载了我想要显示的数据。我坚持使用我的数据所需的 x, y 格式。我现在想沿时间轴 (x) 分散数据。数据的导入工作起来就像一个魅力,但轴看起来只是将 x 值用作字符串/整数。有谁知道如何正确地将 x 轴或数据格式化为时间轴?
我还发现,通过使用常规图表,它看起来更好一些,但时间戳在 x 轴上无法正确缩放(可以在第二张图片中看到)。
自定义图表的 json:
{
"type": "scatter",
"dataSource": {
"chart": {
"caption": "Axes",
"subCaption": "Aggregated History",
"baseFont": "Helvetica Neue,Arial",
"xAxisName": "Date",
"yAxisName": "Price",
"theme": "fusion"
},
"categories": [],
"dataset": [
{
"seriesname": "Offer",
"showregressionline": "0",
"data": [
{
"x": "2022-01-20T13:50:00Z",
"y": 105.316
},
{
"x": "2022-02-01T11:16:00Z",
"y": 104.64
},
{
"x": "2022-02-01T11:16:00Z",
"y": 104.64
},
{
"x": "2022-02-01T12:18:00Z",
"y": 104.599
},
{
"x": "2022-02-01T12:18:00Z",
"y": 104.599
},
{
"x": "2022-02-01T12:19:00Z",
"y": 104.564
},
{
"x": "2022-02-01T12:49:00Z",
"y": 104.608
},
{
"x": "2022-02-01T12:49:00Z",
"y": 104.572
},
{
"x": "2022-02-01T13:03:00Z",
"y": 104.56
},
{
"x": "2022-02-01T13:19:00Z",
"y": 104.593
}
]
},
{
"seriesname": "Bid",
"showregressionline": "0",
"data": [
{
"x": "2022-02-14T13:47:00Z",
"y": 102.415
},
{
"x": "2022-02-14T13:47:00Z",
"y": 102.415
},
{
"x": "2022-02-14T13:47:00Z",
"y": 102.415
},
{
"x": "2022-02-14T14:17:00Z",
"y": 102.421
},
{
"x": "2022-02-14T14:17:00Z",
"y": 102.421
},
{
"x": "2022-02-14T14:17:00Z",
"y": 102.421
},
{
"x": "2022-02-14T14:47:00Z",
"y": 102.373
},
{
"x": "2022-02-14T14:47:00Z",
"y": 102.373
},
{
"x": "2022-02-14T14:47:00Z",
"y": 102.373
},
{
"x": "2022-02-14T15:17:00Z",
"y": 102.443
}
]
}
],
"vtrendlines": []
}
}
I use a Custom Fusion Chart (Scatter) and I have loaded the data I want to display. I stick to the required x, y format with my data. I would now like to scatter the data along a time axis (x). The import of the data works like a charm, but the axis looks like it just uses the x value as String/Integer. Does anyone have an idea how to properly format the x-axis or the data to be a time axis?
What I also found out that by using regular charts it looks a bit better but the time-stamps do not scale properly across the x-axis (can be seen in the 2nd image).
The json for the custom chart:
{
"type": "scatter",
"dataSource": {
"chart": {
"caption": "Axes",
"subCaption": "Aggregated History",
"baseFont": "Helvetica Neue,Arial",
"xAxisName": "Date",
"yAxisName": "Price",
"theme": "fusion"
},
"categories": [],
"dataset": [
{
"seriesname": "Offer",
"showregressionline": "0",
"data": [
{
"x": "2022-01-20T13:50:00Z",
"y": 105.316
},
{
"x": "2022-02-01T11:16:00Z",
"y": 104.64
},
{
"x": "2022-02-01T11:16:00Z",
"y": 104.64
},
{
"x": "2022-02-01T12:18:00Z",
"y": 104.599
},
{
"x": "2022-02-01T12:18:00Z",
"y": 104.599
},
{
"x": "2022-02-01T12:19:00Z",
"y": 104.564
},
{
"x": "2022-02-01T12:49:00Z",
"y": 104.608
},
{
"x": "2022-02-01T12:49:00Z",
"y": 104.572
},
{
"x": "2022-02-01T13:03:00Z",
"y": 104.56
},
{
"x": "2022-02-01T13:19:00Z",
"y": 104.593
}
]
},
{
"seriesname": "Bid",
"showregressionline": "0",
"data": [
{
"x": "2022-02-14T13:47:00Z",
"y": 102.415
},
{
"x": "2022-02-14T13:47:00Z",
"y": 102.415
},
{
"x": "2022-02-14T13:47:00Z",
"y": 102.415
},
{
"x": "2022-02-14T14:17:00Z",
"y": 102.421
},
{
"x": "2022-02-14T14:17:00Z",
"y": 102.421
},
{
"x": "2022-02-14T14:17:00Z",
"y": 102.421
},
{
"x": "2022-02-14T14:47:00Z",
"y": 102.373
},
{
"x": "2022-02-14T14:47:00Z",
"y": 102.373
},
{
"x": "2022-02-14T14:47:00Z",
"y": 102.373
},
{
"x": "2022-02-14T15:17:00Z",
"y": 102.443
}
]
}
],
"vtrendlines": []
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我有用,基本上,散点图很难直接理解日期对象。为了解决我们将需要使用Fusion图表中的某些配置,以及lib时刻以获取正确的值
,从
category
对象添加在`类别对象中。请注意,
x
键值将与数据集中的值相对应。现在,我们也为数据集做同样的事情。
结果是:

This worked for me, Basically the scatter chart is having a hard time understanding the date objects directly. To resolve that we will need to use some configs from the fusion chart and also the moment lib to get the right value
Start with adding the
category
object in the `categories object.notice that the
x
key value will correspond to the value in your dataset.Now we do the same for the dataset as well.
the result of this is:
