小编Wil*_*son的帖子

无法为 apexcharts 获取正确格式化的数据

我从 API 接收这样的数据

{
    "Bob Knight": 30774.72000002,
    "Samuel Herman": 10310.61000004,
    "Lucie Perry": 26308.41,
    "Andreas Smith": 8960.189999999999,
    "Frederic Smith": 2029.5000000599998,
}
Run Code Online (Sandbox Code Playgroud)

我试图在我的 React 应用程序中使用顶点图表在条形图中显示它,但是我似乎无法以正确的方式格式化数据以使顶点显示任何内容。我试过在 javascript 中这样格式化:

{
    {x: "Bob Knight", y:"30774.720002"},
    ...
}
Run Code Online (Sandbox Code Playgroud)

这似乎是文档建议的内容,但它没有呈现任何内容。以下是我的组件的有用部分

constructor(props) {
        super(props);
        this.state = {
            options: {
                chart: {
                    id: "basic-bar"
                },
                xaxis: {
                    type: 'category'
                }
            },
            values: []
        }
    }

    componentDidUpdate(prevProps) {
        if (!equal(this.props.selectedDate, prevProps.selectedDate))
        {
            var m = moment(this.props.selectedDate).format("M");
            var y = moment(this.props.selectedDate).format("YYYY");
            axios.get('http://localhost:8080/opportunity/owner/' + y + '/' + m)
                .then(res => { …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs apexcharts

5
推荐指数
1
解决办法
504
查看次数

如何设置 ApexCharts 中 x 轴标签的格式

我有一个返回数据的 API,如下所示:

[
    {
        "attributes": {
            "type": "AggregateResult"
        },
        "expr0": 25937961.52,
        "expr1": 1,
        "expr2": 2020
    },
    {
        "attributes": {
            "type": "AggregateResult"
        },
        "expr0": 4092447.85,
        "expr1": 3,
        "expr2": 2020
    },
    {
        "attributes": {
            "type": "AggregateResult"
        },
        "expr0": 18509414.84,
        "expr1": 6,
        "expr2": 2019
    },
    {
        "attributes": {
            "type": "AggregateResult"
        },
        "expr0": 13572118.12,
        "expr1": 10,
        "expr2": 2019
    },
...
Run Code Online (Sandbox Code Playgroud)

其中expr0是货币值,expr1是月份,expr2是年份。我在 React 中使用 ApexCharts 在我的网站上显示结果,但是我似乎无法正确格式化数据。我的组件如下所示,但它目前仅显示一个点。我不确定数据点是否需要显示 x/y 键,或者日期是否需要位于选项的 x 轴中。

class SFAllTimeQuoteValue extends Component {
    constructor(props) {
        super(props);
        this.state …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs apexcharts

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

apexcharts ×2

javascript ×2

reactjs ×2