【问题标题】:How to disable tool-tip in ng-apexchart如何在 ng-apexchart 中禁用工具提示
【发布时间】:2020-09-11 07:00:36
【问题描述】:

我在我的角度应用程序中集成顶点图表,实现顶点折线图。我想隐藏启用选项的工具提示:false。但不工作。甚至无法将自定义工具提示设置为折线图。 当悬停在系列上时,它会显示一些垂直虚线,我需要隐藏工具提示或隐藏垂直虚线并创建自定义工具提示。

任何建议都会很有帮助。 谢谢。

import { Component, ViewChild, OnInit } from '@angular/core';

import {
  ChartComponent,
  ApexAxisChartSeries,
  ApexChart,
  ApexXAxis,
  ApexDataLabels,
  ApexTitleSubtitle,
  ApexStroke,
  ApexGrid,
  ApexLegend,
  ApexTooltip,
  ApexYAxis,
} from 'ng-apexcharts';

export interface ChartOptions {
  series: ApexAxisChartSeries;
  chart: ApexChart;
  xaxis: ApexXAxis;
  yaxis: ApexYAxis;
  dataLabels: ApexDataLabels;
  grid: ApexGrid;
  stroke: ApexStroke;
  title: ApexTitleSubtitle;
  legend: ApexLegend;
  tooltip: ApexTooltip;
}
@Component({
  selector: 'app-line-chart',
  templateUrl: './line-chart.component.html',
  styleUrls: ['./line-chart.component.css'],
})
export class LineChartComponent implements OnInit {
  @ViewChild('lineChart') lineChart: ChartComponent;
  public chartOptions: Partial<ChartOptions>;

  constructor() {}

  ngOnInit(): void {
    this.chartOptions = {
      series: [
        {
          name: 'Desktops',
          data: [10, 41, 35, 51, 49, 62, 69, 91, 148],
        },
        {
          name: 'Laptops',
          data: [22, 55, 66, 77, 88, 99, 90, 110, 170],
        },
      ],
      chart: {
        height: 350,
        type: 'line',
        zoom: {
          enabled: false,
        },
        toolbar: {
          tools: {
            download: false,
          },
        },
      },
      dataLabels: {
        enabled: false,
      },
      stroke: {
        curve: 'straight',
      },
      grid: {
        row: {
          colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
          opacity: 0.5,
        },
      },
      yaxis: {
        tooltip: {
          enabled: false,
        },
      },
      xaxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep'],
        tooltip: {
          enabled: false,
        },
      },
      legend: {
        show: false,
        onItemClick: {
          toggleDataSeries: false,
        },
        onItemHover: {
          highlightDataSeries: false,
        },
      },
      tooltip: {
        enabled: false,
        enabledOnSeries: undefined,
        marker: {
          show: false,
        }
      }
    };
  }
}
<apx-chart
      [series]="chartOptions.series"
      [chart]="chartOptions.chart"
      [xaxis]="chartOptions.xaxis"
      [dataLabels]="chartOptions.dataLabels"
      [grid]="chartOptions.grid"
      [stroke]="chartOptions.stroke"
      [title]="chartOptions.title"
      #lineChart
    ></apx-chart>

【问题讨论】:

    标签: javascript css angular apexcharts


    【解决方案1】:

    您的组件中缺少 tooltip 属性

    <apx-chart
      ...
      [tooltip]="chartOptions.tooltip"
      #lineChart
    ></apx-chart>
    

    【讨论】:

    • 谢谢你,拯救了我的一天。 @junedchhipa 你能告诉我如何使用 apexchart 实现树形图。
    • 抱歉,ApexCharts 中尚不提供树状图。
    • 我已经更新了问题中的图像,它在列悬停时显示了一些显示,是否有任何选项可以隐藏那个蓝色阴影?
    猜你喜欢
    • 2019-02-16
    • 2019-01-11
    • 2015-05-23
    • 2017-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多