小编Gol*_*ter的帖子

Plotly: How to remove white space after saving an image?

I have a question about saving plotly table as an image. I wrote the following code:

import plotly.graph_objects as go

layout = go.Layout(autosize=True, margin={'l': 0, 'r': 0, 't': 0, 'b': 0})

fig = go.Figure(data=[go.Table(header=dict(values=['A Scores', 'B Scores']),
                           cells=dict(values=[[100, 90, 80, 90], [95, 85, 75, 95]]))
                  ], layout=layout)

fig.write_image("fig1.png", scale=5)
Run Code Online (Sandbox Code Playgroud)

But unfortunately, there is a big white space at the bottom of the table.

大空白

Can I cut it from the image? The height setting doesn't fit because the table may have …

python plotly

6
推荐指数
1
解决办法
676
查看次数

如何以antd的形式输出自己的错误?

我使用 React 和 Antd 进行注册。当后端发送错误“用户已注册”时,点击“注册”后需要将其显示在表单中。

像这里或其他东西,但我输入用户名和两个密码:

在此输入图像描述

来自服务器的响应,但我可以采用不同的方式:

{
    "errorCode": "1",
    "errorMessage": "user already registered"
}
Run Code Online (Sandbox Code Playgroud)

代码:

    class RegisterPage extends React.Component {

    // Method in which I send the request
    signUp(values) {
        fetch("http://localhost:8080/sign-up", {
            method: "POST",
            body: JSON.stringify({"username": values.username, "password": values.password})
        }).then(response => response.json())
            .then(response => {console.log(response)
            })
    }

    render() {
        return (
            <>
                <Header/>
                <div className="container">
                </div>
                <Row type="flex" justify="center" align="middle" style={{minHeight: '80vh'}}>
                    <Form

                        name="normal_login"
                        className="login-form"
                        initialValues={{
                            remember: true,
                        }}
                        onFinish={this.signUp}
                    >
                        <Form.Item className="username-input"
                                   name="username"
                                   rules={[
                                       {
                                           required: true,
                                           message: …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs antd

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

标签 统计

antd ×1

javascript ×1

plotly ×1

python ×1

reactjs ×1