From: Tiago Melo Date: Tue, 6 Mar 2018 18:53:14 +0000 (+0000) Subject: mgr/dashboard_v2: improve tooltip of cephfsChart X-Git-Tag: v13.1.0~580^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7c1f7d37026d0bfdf4f29d948bc39e595d32c40c;p=ceph.git mgr/dashboard_v2: improve tooltip of cephfsChart Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.scss b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.scss index 23aaa3547655..62a023b9aaf4 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.scss +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.scss @@ -1,6 +1,6 @@ +@import '../../../../styles/chart-tooltip.scss'; + .chart-container { - position: relative; - margin: auto; height: 500px; width: 100%; } diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts index fb4a394a77d4..cca1ae2feb92 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts @@ -1,6 +1,9 @@ -import { Component, Input, OnChanges, OnInit } from '@angular/core'; +import { Component, ElementRef, Input, OnChanges, OnInit, ViewChild } from '@angular/core'; import * as _ from 'lodash'; +import * as moment from 'moment'; + +import { ChartTooltip } from '../../../shared/models/chart-tooltip'; @Component({ selector: 'cd-cephfs-chart', @@ -8,6 +11,9 @@ import * as _ from 'lodash'; styleUrls: ['./cephfs-chart.component.scss'] }) export class CephfsChartComponent implements OnChanges, OnInit { + @ViewChild('chartCanvas') chartCanvas: ElementRef; + @ViewChild('chartTooltip') chartTooltip: ElementRef; + @Input() mdsCounter: any; lhsCounter = 'mds.inodes'; @@ -22,6 +28,27 @@ export class CephfsChartComponent implements OnChanges, OnInit { return; } + const getTitle = title => { + return moment(title).format('LTS'); + }; + + const getStyleTop = tooltip => { + return tooltip.caretY - tooltip.height - 15 + 'px'; + }; + + const getStyleLeft = tooltip => { + return tooltip.caretX + 'px'; + }; + + const chartTooltip = new ChartTooltip( + this.chartCanvas, + this.chartTooltip, + getStyleLeft, + getStyleTop + ); + chartTooltip.getTitle = getTitle; + chartTooltip.checkOffset = true; + const lhsData = this.convert_timeseries(this.mdsCounter[this.lhsCounter]); const rhsData = this.delta_timeseries(this.mdsCounter[this.rhsCounter]); @@ -72,6 +99,15 @@ export class CephfsChartComponent implements OnChanges, OnInit { min: 0 } ] + }, + tooltips: { + enabled: false, + mode: 'index', + intersect: false, + position: 'nearest', + custom: tooltip => { + chartTooltip.customTooltips(tooltip); + } } }, chartType: 'line'