【问题标题】:How to change the label color of Y-Axis on click in angular Gantt chart High Chart如何在角度甘特图高图表中单击时更改 Y 轴的标签颜色
【发布时间】:2021-11-24 10:08:12
【问题描述】:

如何在单击标签时更改 Y 轴的背景颜色。它适用于 javascript,但不适用于 angular。

chart.yAxis[0].labelGroup.element.childNodes.forEach(function (label) {
  label.onclick = function () {
    alert(label.style);
    label.style.fill = "teal";
    let data = chart.series[0].data,
      visibleRows = 0,
      chartHeight;
    data.forEach((el) => {
      if (el.visible) {
        visibleRows++;
      }
    });
    if (visibleRows > 3) {
      alert("if");
      chartHeight = 40 * visibleRows;
    } else {
      alert("else");
      chartHeight = 40 * visibleRows + 110;
    }
    chart.update({
      chart: {
        height: chartHeight
      }
    });
  };
});

https://codepen.io/mehrotrarohit07/pen/PoKxvQp?editors=1010

【问题讨论】:

  • 您能分享一下您在 Angular 中实现此自定义代码的尝试吗?

标签: angular highcharts gantt-chart highcharts-gantt


【解决方案1】:

经过长时间的研究,找到了解决方案。

this.chart.yAxis[0].labelGroup.element.childNodes.forEach(function (label) {
      label.onclick = function () {
        alert(label.style)
        label.style.fill = "teal";
      };
    });
  }

Stackblitz 网址 https://stackblitz.com/edit/highcharts-angular-gantt-un3avk?file=src%2Fapp%2Fapp.component.ts

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-06
    • 2021-03-12
    • 2021-02-15
    • 1970-01-01
    相关资源
    最近更新 更多