Browse Source

feat(ui): Change Alert chart from Line Chart to Area Chart [WIP] (#31546)

* feat(ui): Change Alert chart from Line Chart to Area Chart [WIP]

Change the Alert Chart on the Alert Details page from a Line Chart to an Area Chart. Also move the marklines to the top layer.

FIXES WOR-1560

* add disabling for area chart emphasis

* remove emphasis since alreay in LineSeries
Kelly Carino 3 years ago
parent
commit
b52daf0258
1 changed files with 13 additions and 10 deletions
  1. 13 10
      static/app/views/alerts/rules/details/metricChart.tsx

+ 13 - 10
static/app/views/alerts/rules/details/metricChart.tsx

@@ -10,11 +10,11 @@ import momentTimezone from 'moment-timezone';
 import {Client} from 'sentry/api';
 import {Client} from 'sentry/api';
 import Feature from 'sentry/components/acl/feature';
 import Feature from 'sentry/components/acl/feature';
 import Button from 'sentry/components/button';
 import Button from 'sentry/components/button';
+import AreaChart, {AreaChartSeries} from 'sentry/components/charts/areaChart';
 import ChartZoom from 'sentry/components/charts/chartZoom';
 import ChartZoom from 'sentry/components/charts/chartZoom';
 import MarkArea from 'sentry/components/charts/components/markArea';
 import MarkArea from 'sentry/components/charts/components/markArea';
 import MarkLine from 'sentry/components/charts/components/markLine';
 import MarkLine from 'sentry/components/charts/components/markLine';
 import EventsRequest from 'sentry/components/charts/eventsRequest';
 import EventsRequest from 'sentry/components/charts/eventsRequest';
-import LineChart, {LineChartSeries} from 'sentry/components/charts/lineChart';
 import LineSeries from 'sentry/components/charts/series/lineSeries';
 import LineSeries from 'sentry/components/charts/series/lineSeries';
 import SessionsRequest from 'sentry/components/charts/sessionsRequest';
 import SessionsRequest from 'sentry/components/charts/sessionsRequest';
 import {HeaderTitleLegend, SectionHeading} from 'sentry/components/charts/styles';
 import {HeaderTitleLegend, SectionHeading} from 'sentry/components/charts/styles';
@@ -26,6 +26,7 @@ import {
 import {Panel, PanelBody, PanelFooter} from 'sentry/components/panels';
 import {Panel, PanelBody, PanelFooter} from 'sentry/components/panels';
 import Placeholder from 'sentry/components/placeholder';
 import Placeholder from 'sentry/components/placeholder';
 import Truncate from 'sentry/components/truncate';
 import Truncate from 'sentry/components/truncate';
+import CHART_PALETTE from 'sentry/constants/chartPalette';
 import {IconCheckmark, IconFire, IconWarning} from 'sentry/icons';
 import {IconCheckmark, IconFire, IconWarning} from 'sentry/icons';
 import {t} from 'sentry/locale';
 import {t} from 'sentry/locale';
 import ConfigStore from 'sentry/stores/configStore';
 import ConfigStore from 'sentry/stores/configStore';
@@ -86,7 +87,7 @@ function formatTooltipDate(date: moment.MomentInput, format: string): string {
   return momentTimezone.tz(date, timezone).format(format);
   return momentTimezone.tz(date, timezone).format(format);
 }
 }
 
 
-function createThresholdSeries(lineColor: string, threshold: number): LineChartSeries {
+function createThresholdSeries(lineColor: string, threshold: number): AreaChartSeries {
   return {
   return {
     seriesName: 'Threshold Line',
     seriesName: 'Threshold Line',
     type: 'line',
     type: 'line',
@@ -107,7 +108,7 @@ function createStatusAreaSeries(
   startTime: number,
   startTime: number,
   endTime: number,
   endTime: number,
   yPosition: number
   yPosition: number
-): LineChartSeries {
+): AreaChartSeries {
   return {
   return {
     seriesName: '',
     seriesName: '',
     type: 'line',
     type: 'line',
@@ -126,10 +127,10 @@ function createIncidentSeries(
   lineColor: string,
   lineColor: string,
   incidentTimestamp: number,
   incidentTimestamp: number,
   incident: Incident,
   incident: Incident,
-  dataPoint?: LineChartSeries['data'][0],
+  dataPoint?: AreaChartSeries['data'][0],
   seriesName?: string,
   seriesName?: string,
   aggregate?: string
   aggregate?: string
-): LineChartSeries {
+): AreaChartSeries {
   const formatter = ({value, marker}: any) => {
   const formatter = ({value, marker}: any) => {
     const time = formatTooltipDate(moment(value), 'MMM D, YYYY LT');
     const time = formatTooltipDate(moment(value), 'MMM D, YYYY LT');
     return [
     return [
@@ -231,7 +232,7 @@ class MetricChart extends React.PureComponent<Props, State> {
     }
     }
   };
   };
 
 
-  getRuleChangeSeries = (data: LineChartSeries[]): LineSeriesOption[] => {
+  getRuleChangeSeries = (data: AreaChartSeries[]): LineSeriesOption[] => {
     const {dateModified} = this.props.rule || {};
     const {dateModified} = this.props.rule || {};
 
 
     if (!data.length || !data[0].data.length || !dateModified) {
     if (!data.length || !data[0].data.length || !dateModified) {
@@ -349,10 +350,12 @@ class MetricChart extends React.PureComponent<Props, State> {
     const criticalTrigger = rule.triggers.find(({label}) => label === 'critical');
     const criticalTrigger = rule.triggers.find(({label}) => label === 'critical');
     const warningTrigger = rule.triggers.find(({label}) => label === 'warning');
     const warningTrigger = rule.triggers.find(({label}) => label === 'warning');
 
 
-    const series: LineChartSeries[] = [...timeseriesData];
+    const series: AreaChartSeries[] = [...timeseriesData];
     const areaSeries: any[] = [];
     const areaSeries: any[] = [];
-    // Ensure series data appears above incident lines
-    series[0].z = 100;
+    // Ensure series data appears below incident/mark lines
+    series[0].z = 1;
+    series[0].color = CHART_PALETTE[0][0];
+
     const dataArr = timeseriesData[0].data;
     const dataArr = timeseriesData[0].data;
     const maxSeriesValue = dataArr.reduce(
     const maxSeriesValue = dataArr.reduce(
       (currMax, coord) => Math.max(currMax, coord.value),
       (currMax, coord) => Math.max(currMax, coord.value),
@@ -559,7 +562,7 @@ class MetricChart extends React.PureComponent<Props, State> {
                 onZoom={zoomArgs => handleZoom(zoomArgs.start, zoomArgs.end)}
                 onZoom={zoomArgs => handleZoom(zoomArgs.start, zoomArgs.end)}
               >
               >
                 {zoomRenderProps => (
                 {zoomRenderProps => (
-                  <LineChart
+                  <AreaChart
                     {...zoomRenderProps}
                     {...zoomRenderProps}
                     isGroupedByDate
                     isGroupedByDate
                     showTimeInTooltip
                     showTimeInTooltip