te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - TypeError: Cannot read properties of undefined (reading 'toString') (apex-charts) - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TypeError: Cannot read properties of undefined (reading 'toString') (apex-charts) - Stack Overflow

programmeradmin4浏览0评论

I was working on a personal project, and I was thinking of using apexcharts, but this error shown in the image started to appear, it disappears if I set the width and height properties in the Chart ponent, it also disappears if I put the site in production, but at the moment I'm working on the responsiveness of the layout

export function Chart() {
    const Chart = dynamic(() => import("react-apexcharts"), { ssr: false });
    const options: ApexOptions = {
        chart: {
            id: "chart",
            background: "#030a4d8d",
            fontFamily: "Roboto",
            width: "auto",
            height: "auto",
            redrawOnWindowResize: true,
            selection: {
                enabled: false,
            },
            toolbar: {
                show: false,
            },
        },
        dataLabels: {
            background: {
                borderRadius: 10,
            },
            style: {
                colors: ["#142085"],
            },
        },
        colors: ["#7e838c", "#474d59", "#363b47"],
        grid: {
            show: false,
        },
        legend: {
            fontFamily: "Roboto",
        },
        noData: {
            text: "Nenhum dado encontrado",
            style: {
                fontFamily: "Roboto",
            },
        },
        xaxis: {
            categories: ["Sistemas", "Comandos", "Servidores"],
            labels: {
                style: {
                    colors: "#f5f7fa",
                    fontFamily: "Roboto",
                },
            },
        },
        yaxis: {
            show: false,
        },
        series: [
            {
                data: [100, 200, 300],
            },
        ],
        tooltip: {
            enabled: false,
        },
    };

    return (
        <div className="chart-container">
            <Chart
                options={options}
                series={options.series}
                type="bar"
                width={300}
                height={150}
            />
        </div>
    );
}

I've already tried to define the width in the ponent and style it over it in the css, but the ponent's styling prevails, I'm a beginner in the area of ​​frameworks, and I can't even read English, I just hope that this error disappears without me having to define the width and height properties in the chart ponent

I was working on a personal project, and I was thinking of using apexcharts, but this error shown in the image started to appear, it disappears if I set the width and height properties in the Chart ponent, it also disappears if I put the site in production, but at the moment I'm working on the responsiveness of the layout

export function Chart() {
    const Chart = dynamic(() => import("react-apexcharts"), { ssr: false });
    const options: ApexOptions = {
        chart: {
            id: "chart",
            background: "#030a4d8d",
            fontFamily: "Roboto",
            width: "auto",
            height: "auto",
            redrawOnWindowResize: true,
            selection: {
                enabled: false,
            },
            toolbar: {
                show: false,
            },
        },
        dataLabels: {
            background: {
                borderRadius: 10,
            },
            style: {
                colors: ["#142085"],
            },
        },
        colors: ["#7e838c", "#474d59", "#363b47"],
        grid: {
            show: false,
        },
        legend: {
            fontFamily: "Roboto",
        },
        noData: {
            text: "Nenhum dado encontrado",
            style: {
                fontFamily: "Roboto",
            },
        },
        xaxis: {
            categories: ["Sistemas", "Comandos", "Servidores"],
            labels: {
                style: {
                    colors: "#f5f7fa",
                    fontFamily: "Roboto",
                },
            },
        },
        yaxis: {
            show: false,
        },
        series: [
            {
                data: [100, 200, 300],
            },
        ],
        tooltip: {
            enabled: false,
        },
    };

    return (
        <div className="chart-container">
            <Chart
                options={options}
                series={options.series}
                type="bar"
                width={300}
                height={150}
            />
        </div>
    );
}

I've already tried to define the width in the ponent and style it over it in the css, but the ponent's styling prevails, I'm a beginner in the area of ​​frameworks, and I can't even read English, I just hope that this error disappears without me having to define the width and height properties in the chart ponent

Share Improve this question edited Jan 13, 2023 at 8:13 vimuth 5,63248 gold badges91 silver badges124 bronze badges asked Jan 13, 2023 at 1:29 Uilian ComimUilian Comim 431 silver badge3 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 14

give width like this in your chart ponent.

        <Chart
            options={options}
            series={options.series}
            type="bar"
            width={"100%"}
            height={150}
        />
    

Try to dynamically import your whole ponent, not only the apex-chart library.

I mean, go down in the tree:

Root|
    |
    |Page.js| <- use next/dynamic here to import "Component.js"
            |
            |Component.js| <- instead of use next/dynamic here.
                         |
                         |apex-chart ponent
import dynamic from 'next/dynamic';
import { Props } from 'react-apexcharts';
const ReactApexChart = dynamic(() => import("react-apexcharts"), { ssr: false })

const state: Props = {

    series: [{
        name: "Desktops",
        data: [10, 41, 35, 51, 49, 62, 69]
    }],
    options: {
        chart: {
            height: 350,

            type: 'line',
            zoom: {
                enabled: false
            }
        },
        dataLabels: {
            enabled: false
        },
        stroke: {
            curve: 'straight'
        },

        grid: {
            row: {
                colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
                opacity: 0.5
            },
        },
        xaxis: {
            categories: ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat',],
        }
    },


};
export function DashboardChartComponent() {
    return <ReactApexChart options={state.options} series={state.series} type="line" width={"100%"} height={350} />

}

Specifying both height and width at the same time worked for me.

 <ApexChart
    options={chartOptions}
    series={seriesData}
    type="bar"
    height={150}
    width={"100%"}
/>
发布评论

评论列表(0)

  1. 暂无评论