Skip to content

[Bug] wrong label of xAxis in histogram #4338

@xile611

Description

@xile611

Version

2.0.10

Link to Minimal Reproduction

no

Steps to Reproduce

const spec = {
    "type": "histogram",
    "xField": "__BinStart__",
    "x2Field": "__BinEnd__",
    "yField": "__MeaValue__",
    "padding": 0,
    "region": [
        {
            "clip": true
        }
    ],
    "legends": {
        "type": "discrete",
        "visible": false,
        "maxCol": 1,
        "maxRow": 1,
        "autoPage": true,
        "orient": "right",
        "position": "start",
        "item": {
            "focus": true,
            "maxWidth": "30%",
            "focusIconStyle": {
                "size": 14,
                "fill": "#606773",
                "fontWeight": 400
            },
            "shape": {
                "space": 6,
                "state": {
                    "unSelected": {
                        "opacity": 0.2,
                        "fillOpacity": 1
                    }
                }
            },
            "label": {
                "style": {
                    "fontSize": 12,
                    "fill": "#606773",
                    "fontWeight": 400
                },
                "state": {
                    "unSelected": {
                        "fill": "#606773",
                        "fillOpacity": 0.8
                    }
                }
            },
            "background": {
                "state": {
                    "selectedHover": {
                        "fill": "#606773",
                        "fillOpacity": 0.05
                    },
                    "unSelectedHover": {
                        "fill": null
                    }
                }
            }
        },
        "pager": {
            "textStyle": {
                "fill": "#606773"
            },
            "handler": {
                "style": {
                    "fill": "#89909D"
                },
                "state": {
                    "disable": {
                        "fill": "#F1F2F5"
                    }
                }
            }
        },
        "padding": 0
    },
    "barGap": 2,
    "animation": true,
    "color": {
        "type": "ordinal",
        "domain": [],
        "range": [
            "#8D72F6",
            "#5766EC",
            "#66A3FE",
            "#51D5E6",
            "#4EC0B3",
            "#F9DF90",
            "#F9AD71",
            "#ED8888",
            "#E9A0C3",
            "#D77DD3"
        ]
    },
    "background": "transparent",
    "data": {
        "id": "histogram",
        "values": [
            {
                "__BinStart__": 1,
                "__BinEnd__": 2,
                "__BinCount__": 3,
                "__BinPercentage__": 0.3333333333333333,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 3,
                "v": 3
            },
            {
                "__BinStart__": 2,
                "__BinEnd__": 3,
                "__BinCount__": 1,
                "__BinPercentage__": 0.1111111111111111,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 1,
                "v": 1
            },
            {
                "__BinStart__": 3,
                "__BinEnd__": 4,
                "__BinCount__": 0,
                "__BinPercentage__": 0,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 0,
                "v": 0
            },
            {
                "__BinStart__": 4,
                "__BinEnd__": 5,
                "__BinCount__": 0,
                "__BinPercentage__": 0,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 0,
                "v": 0
            },
            {
                "__BinStart__": 5,
                "__BinEnd__": 6,
                "__BinCount__": 1,
                "__BinPercentage__": 0.1111111111111111,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 1,
                "v": 1
            },
            {
                "__BinStart__": 6,
                "__BinEnd__": 7,
                "__BinCount__": 0,
                "__BinPercentage__": 0,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 0,
                "v": 0
            },
            {
                "__BinStart__": 7,
                "__BinEnd__": 8,
                "__BinCount__": 1,
                "__BinPercentage__": 0.1111111111111111,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 1,
                "v": 1
            },
            {
                "__BinStart__": 8,
                "__BinEnd__": 9,
                "__BinCount__": 1,
                "__BinPercentage__": 0.1111111111111111,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 1,
                "v": 1
            },
            {
                "__BinStart__": 9,
                "__BinEnd__": 10,
                "__BinCount__": 1,
                "__BinPercentage__": 0.1111111111111111,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 1,
                "v": 1
            },
            {
                "__BinStart__": 10,
                "__BinEnd__": 11,
                "__BinCount__": 1,
                "__BinPercentage__": 0.1111111111111111,
                "__MeaId__": "v",
                "__MeaName__": "v",
                "__MeaValue__": 1,
                "v": 1
            }
        ],
        "fields": {}
    },
    "large": false,
    "largeThreshold": null,
    "progressiveStep": 400,
    "progressiveThreshold": null,
    "axes": [
        {
            "min": 1,
            "max": 11,
            "visible": true,
            "type": "linear",
            "base": 10,
            "orient": "bottom",
            "nice": true,
            "zero": true,
            "inverse": false,
            "label": {
                "space": 8,
                "visible": true,
                "style": {
                    "fill": "#8F959E",
                    "angle": 0,
                    "fontSize": 12,
                    "fontWeight": 400
                }
            },
            "title": {
                "visible": false,
                "text": "",
                "style": {
                    "fill": "#606773",
                    "fontSize": 12,
                    "fontWeight": 400
                }
            },
            "tick": {
                "visible": false,
                "tickSize": 4,
                "inside": false,
                "style": {
                    "stroke": "#E3E5EB"
                }
            },
            "grid": {
                "visible": true,
                "style": {
                    "lineWidth": 0.5,
                    "stroke": "#E3E5EB",
                    "lineDash": [
                        4,
                        2
                    ]
                }
            },
            "domainLine": {
                "visible": false,
                "style": {
                    "lineWidth": 1,
                    "stroke": "#E3E5EB"
                }
            },
            "innerOffset": {
                "right": 12
            }
        },
        {
            "visible": true,
            "type": "linear",
            "base": 10,
            "orient": "left",
            "nice": true,
            "zero": true,
            "inverse": false,
            "label": {
                "space": 8,
                "visible": true,
                "style": {
                    "fill": "#8F959E",
                    "angle": 0,
                    "fontSize": 12,
                    "fontWeight": 400
                }
            },
            "title": {
                "visible": false,
                "text": "",
                "style": {
                    "fill": "#606773",
                    "fontSize": 12,
                    "fontWeight": 400
                }
            },
            "tick": {
                "visible": false,
                "tickSize": 4,
                "inside": false,
                "style": {
                    "stroke": "#E3E5EB"
                }
            },
            "grid": {
                "visible": true,
                "style": {
                    "lineWidth": 0.5,
                    "stroke": "#E3E5EB",
                    "lineDash": [
                        4,
                        2
                    ]
                }
            },
            "domainLine": {
                "visible": false,
                "style": {
                    "lineWidth": 1,
                    "stroke": "#E3E5EB"
                }
            },
            "innerOffset": {
                "top": 12
            }
        }
    ],
    "label": {
        "visible": true,
        "style": {
            "stroke": "#fff"
        },
        "smartInvert": false,
        "overlap": {
            "hideOnHit": true,
            "clampForce": true
        }
    },
    "tooltip": {
        "style": {
            "panel": {
                "padding": 9,
                "border": {
                    "radius": 12,
                    "width": 1,
                    "color": "#e3e5e8"
                },
                "backgroundColor": "#fff"
            },
            "keyLabel": {
                "lineHeight": 12,
                "fontSize": 12,
                "fontColor": "#606773"
            },
            "valueLabel": {
                "lineHeight": 12,
                "fontSize": 12,
                "fontColor": "#21252c",
                "fontWeight": "medium"
            },
            "titleLabel": {
                "fontSize": 12,
                "lineHeight": 12,
                "fontColor": "#21252c",
                "fontWeight": "bold"
            }
        },
        "visible": true,
        "mark": {
            "title": {
                "visible": false
            },
            "content": [
                [
                    {
                        "visible": true,
                        "hasShape": true,
                        "shapeType": "rectRound"
                    }
                ]
            ]
        },
        "dimension": {
            "title": {
                "visible": false
            },
            "content": [
                [
                    {
                        "visible": true,
                        "hasShape": true,
                        "shapeType": "rectRound"
                    }
                ]
            ]
        }
    },
    "crosshair": {
        "xField": {
            "visible": true,
            "line": {
                "type": "rect",
                "style": {
                    "lineWidth": 0,
                    "opacity": 0.26,
                    "fill": "#D9DDE4"
                }
            },
            "label": {
                "visible": true,
                "labelBackground": {
                    "visible": true,
                    "style": {
                        "fill": "#364159"
                    }
                },
                "style": {
                    "fill": "#ffffff"
                }
            }
        }
    },
    "bar": {
        "style": {
            "visible": true,
            "fillOpacity": 1,
            "lineWidth": 1
        },
        "state": {
            "hover": {
                "fillOpacity": 0.6
            }
        }
    }
};

const vchart = new VChart(spec, { dom: CONTAINER_ID });
vchart.renderSync();

// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;

Current Behavior

Image

Expected Behavior

出现了大于数据源中的数据

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions