You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调整AG Grid搭配AdapTable时Format Column的Gradient渐变顺序

这个需求完全可以实现。

你当前负数区间表现不符合预期的原因是AdapTable的渐变列默认规则是同个CellRange内数值越接近Max值,填充色的饱和度越高:你配置的负数区间Max为0,所以越接近0的负数红色越深,刚好和需求相反。

只需要给负数对应的CellRange配置项新增一个Reverse: true属性即可,该属性会翻转当前区间的颜色深度计算逻辑,改成数值越接近Min值(也就是你的-100)颜色越深。

修改后的完整配置如下:

FormatColumn: {
  FormatColumns: [
      {
        Scope: { ColumnIds: ['current_value']},
        ColumnStyle: {
          GradientStyle: {
            CellRanges: [
              {Min: -100, Max: 0, Color: 'Red', Reverse: true},
              {Min: 0, Max: 100, Color: 'Green'}
            ],
          },
        },
        DisplayFormat: { Formatter: 'NumberFormatter', Options: { Parentheses: true}},
        CellAlignment: 'Center',
      },
    ],
  },

修改后正数区间保持原有逻辑:数值越大绿色越深;负数区间会变为数值越小红色越深,完全匹配你的使用需求。

内容的提问来源于stack exchange,提问作者Simone

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.08 00:42:04