VisActor / VChart

VChart, more than just a cross-platform charting library, but also an expressive data storyteller.
https://www.visactor.io/vchart
MIT License
950 stars 66 forks source link

[FAQ] 如何让X轴时间打横平展开 #2984

Open Brant-lzh opened 3 months ago

Brant-lzh commented 3 months ago

设置小的bandSize发现展不开 image 设置大的bandSize发现数据展示不全 image

请问应该如何设置呢? 调整X轴时间间隔(打横展示),并且展示全

xile611 commented 2 months ago

@Brant-lzh 给一下完整的配置吧 看起来是设置了自定旋转,autoRotate 如果不想自动旋转,可以关闭这个属性

Brant-lzh commented 2 months ago
{
  "type": "line",
  "data": [
    {
      "id": "line",
      "values": [
        {
          "name": "solo-center-5f4f648f96-l4462",
          "time": "14:20",
          "value": "0.114"
        },
        {
          "name": "solo-center-5f4f648f96-l4462",
          "time": "14:21",
          "value": "0.116"
        },
        {
          "name": "solo-center-5f4f648f96-l4462",
          "time": "14:22",
          "value": "0.114"
        },
        //.......
        {
          "name": "solo-center-5f4f648f96-wf5ln",
          "time": "16:50",
          "value": "0.076"
        }
      ]
    }
  ],
  "xField": "time",
  "yField": "value",
  "seriesField": "name",
  "invalidType": "break",
  "point": {
    "visible": false
  },
  "axes": [
    {
      "orient": "left",
      "label": {
        "formatter": "{label}m"
      }
    },
    {
      "orient": "bottom",
      "nice": true,
      "trimPadding": true
    }
  ],
  "label": {
    "visible": false
  },
  "legends": {
    "orient": "bottom",
    "selectMode": "multiple",
    "title": {
      "visible": true,
      "text": "可多选",
      "align": "center",
      "textStyle": {
        "fontSize": 10,
        "fontWeight": "bolder"
      }
    },
    "defaultSelected": [
      "solo-center-5f4f648f96-l4462"
    ]
  }
}

@xile611 感谢回答!

以上是我的配置,但是我是在飞书搭建卡片工具里配置的,出现这个问题,但到VisActor官网渲染没这个问题,请是飞书卡片渲染有问题?

image

xile611 commented 2 months ago
{
  "type": "line",
  "data": [
    {
      "id": "line",
      "values": [
        {
          "name": "solo-center-5f4f648f96-l4462",
          "time": "14:20",
          "value": "0.114"
        },
        {
          "name": "solo-center-5f4f648f96-l4462",
          "time": "14:21",
          "value": "0.116"
        },
        {
          "name": "solo-center-5f4f648f96-l4462",
          "time": "14:22",
          "value": "0.114"
        },
        //.......
        {
          "name": "solo-center-5f4f648f96-wf5ln",
          "time": "16:50",
          "value": "0.076"
        }
      ]
    }
  ],
  "xField": "time",
  "yField": "value",
  "seriesField": "name",
  "invalidType": "break",
  "point": {
    "visible": false
  },
  "axes": [
    {
      "orient": "left",
      "label": {
        "formatter": "{label}m"
      }
    },
    {
      "orient": "bottom",
      "nice": true,
      "trimPadding": true
    }
  ],
  "label": {
    "visible": false
  },
  "legends": {
    "orient": "bottom",
    "selectMode": "multiple",
    "title": {
      "visible": true,
      "text": "可多选",
      "align": "center",
      "textStyle": {
        "fontSize": 10,
        "fontWeight": "bolder"
      }
    },
    "defaultSelected": [
      "solo-center-5f4f648f96-l4462"
    ]
  }
}

@xile611 感谢回答!

以上是我的配置,但是我是在飞书搭建卡片工具里配置的,出现这个问题,但到VisActor官网渲染没这个问题,请是飞书卡片渲染有问题?

image

@skie1997 跟踪一下这个问题

skie1997 commented 2 months ago

@Brant-lzh

{
  "type": "line",
  "data": [
    {
      "id": "line",
      "values": [
        {
          "name": "solo-center-5f4f648f96-l4462",
          "time": "14:20",
          "value": "0.114"
        },
        {
          "name": "solo-center-5f4f648f96-l4462",
          "time": "14:21",
          "value": "0.116"
        },
        {
          "name": "solo-center-5f4f648f96-l4462",
          "time": "14:22",
          "value": "0.114"
        },
        //.......
        {
          "name": "solo-center-5f4f648f96-wf5ln",
          "time": "16:50",
          "value": "0.076"
        }
      ]
    }
  ],
  "xField": "time",
  "yField": "value",
  "seriesField": "name",
  "invalidType": "break",
  "point": {
    "visible": false
  },
  "axes": [
    {
      "orient": "left",
      "label": {
        "formatter": "{label}m"
      }
    },
    {
      "orient": "bottom",
      "nice": true,
      "trimPadding": true
    }
  ],
  "label": {
    "visible": false
  },
  "legends": {
    "orient": "bottom",
    "selectMode": "multiple",
    "title": {
      "visible": true,
      "text": "可多选",
      "align": "center",
      "textStyle": {
        "fontSize": 10,
        "fontWeight": "bolder"
      }
    },
    "defaultSelected": [
      "solo-center-5f4f648f96-l4462"
    ]
  }
}

@xile611 感谢回答!

以上是我的配置,但是我是在飞书搭建卡片工具里配置的,出现这个问题,但到VisActor官网渲染没这个问题,请是飞书卡片渲染有问题?

image

@Brant-lzh 看之前的截图应该是搭建工具中轴的label格式化没有生效,导致展示不下。搭建工具中的label spec也设置了label format么? image

Brant-lzh commented 1 month ago

@skie1997 完整的配置都在上面了! 你所说的搭建工具中的label spec也设置了label format么,是指搭建工具在其他方面填写的内容?