【问题标题】:amcharts 4 category X axis labels not aligned with graphed dataamcharts 4 类别 X 轴标签未与图形数据对齐
【发布时间】:2020-11-24 16:39:16
【问题描述】:

在类别 X 轴上使用旋转标签。 (实图使用长名称,但结果相同。) A:轴标签和它们的数据点的对齐很好,没有标签旋转。 B:旋转时标签未对齐。 A 和 B 图形编码之间的唯一区别是在 xAxes 渲染器中添加了"labels":{"rotation":90}。 如何固定对齐?

var chart =am4core.createFromConfig({
  "colors":         { "list": ["#DB3", "#000", "#888"] },
  "data":           [$data],
  "legend":         {   "markers":{"width":20, "height":10},
                        "position":"top",
                        "useDefaultMarker":true
    },
  "series": [
        {   "dataFields":       { "categoryX":"X", "valueY":"Y1" },
            "name":             "[font-size:16px;font-weight:600;]{$n1}[/]",
            "strokeWidth":      2,
            "type":             "LineSeries"
      },
        {   "dataFields":       { "categoryX":"X", "valueY":"Y2" },
            "name":             "[font-size:16px;font-weight:600;]{$n2}[/]",
            "strokeWidth":      2,
            "type":             "LineSeries"
      },
        {   "dataFields":       { "categoryX":"X", "valueY":"Y3" },
            "name":             "[font-size:16px;font-weight:600;]others[/]",
            "strokeWidth":      2,
            "type":             "LineSeries"
      }
    ],
    "xAxes": [
        {   "dataFields":       {   "category": "X" },
            "renderer":         {   "minGridDistance":11, "labels":{"rotation":90}},
            "type":                 "CategoryAxis"
        }
    ],
    "yAxes": [
        {   "renderer":         {"minGridDistance":15},
            "title":                {"text": "[font-size:16px;font-weight:600;]Values[/]"},
            "type":                 "ValueAxis"
    }]
}, "line", am4charts.XYChart);

【问题讨论】:

    标签: amcharts axis-labels


    【解决方案1】:

    标签渲染器需要 "verticalCenter":"middle" 旋转。 我不知道我尝试了多少其他东西!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-19
      • 2014-03-09
      • 1970-01-01
      • 2019-07-12
      • 1970-01-01
      相关资源
      最近更新 更多