From 82f7c539cbcaab82eaaab312699567847458493b Mon Sep 17 00:00:00 2001 From: Marshall Peterson Date: Mon, 14 Oct 2024 15:37:00 -0600 Subject: [PATCH] feat: add sentiment icons --- src/specBuilder/specUtils.ts | 11 ++++++++++- src/svgPaths.ts | 9 +++++++++ src/types/Chart.ts | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/specBuilder/specUtils.ts b/src/specBuilder/specUtils.ts index 7b0a5b15c..0075e3a71 100644 --- a/src/specBuilder/specUtils.ts +++ b/src/specBuilder/specUtils.ts @@ -9,7 +9,13 @@ * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -import { DATE_PATH, ROUNDED_SQUARE_PATH } from '@svgPaths'; +import { + DATE_PATH, + ROUNDED_SQUARE_PATH, + SENTIMENT_NEGATIVE_PATH, + SENTIMENT_NEUTRAL_PATH, + SENTIMENT_POSITIVE_PATH, +} from '@svgPaths'; import { spectrumColors } from '@themes'; import { Data, Scale, ScaleType, Spec, ValuesData } from 'vega'; @@ -178,6 +184,9 @@ export const getPathFromSymbolShape = (symbolShape: ChartSymbolShape): string => export const getPathFromIcon = (icon: Icon | string): string => { const supportedIcons: { [key in Icon]: string } = { date: DATE_PATH, + sentimentNegative: SENTIMENT_NEGATIVE_PATH, + sentimentNeutral: SENTIMENT_NEUTRAL_PATH, + sentimentPositive: SENTIMENT_POSITIVE_PATH, }; return supportedIcons[icon] || icon; }; diff --git a/src/svgPaths.ts b/src/svgPaths.ts index a32609399..10b72e89e 100644 --- a/src/svgPaths.ts +++ b/src/svgPaths.ts @@ -21,3 +21,12 @@ export const ANNOTATION_SINGLE_ICON_SVG = export const ANNOTATION_RANGED_ICON_SVG = 'M 3.8 7.6 V 4.3 A 0.5 0.5 90 0 1 4.3 3.8 h 3.3 a 0.6 0.6 90 0 1 -0.1 0.4 L 4.2 7.5 a 0.6 0.6 90 0 1 -0.4 0.1 Z m 3.7 -15.1 a 0.5 0.5 90 0 0 -0.4 -0.2 H -7.1 a 0.5 0.5 90 0 0 -0.5 0.5 v 14.2 a 0.5 0.5 90 0 0 0.5 0.5 H 2.5 V 3.6 a 1.1 1.1 90 0 1 1.1 -1.1 H 7.6 V -7.1 A 0.5 0.5 90 0 0 7.5 -7.5 Z M 5.7 -3.3 l -1.9 1.9 a 0.2 0.2 90 0 1 -0.1 0 a 0.2 0.2 90 0 1 -0.1 0 a 0.2 0.2 90 0 1 -0.1 -0 a 0.2 0.2 90 0 1 -0.1 -0 a 0.2 0.2 90 0 1 -0 -0.1 a 0.2 0.2 90 0 1 -0 -0.1 v -1 L -3.4 -2.6 l -0 1 a 0.2 0.2 90 0 1 -0.1 0.2 a 0.2 0.2 90 0 1 -0.2 0.1 a 0.2 0.2 90 0 1 -0.1 -0 a 0.2 0.2 90 0 1 -0.1 -0 L -5.7 -3.3 a 0.2 0.2 90 0 1 0 -0.2 L -3.8 -5.4 a 0.2 0.2 90 0 1 0.2 -0.1 a 0.2 0.2 90 0 1 0.2 0.1 a 0.2 0.2 90 0 1 0 0.1 a 0.2 0.2 90 0 1 0 0.1 l 0 1 l 6.8 0 V -5.3 a 0.2 0.2 90 0 1 0 -0.1 a 0.2 0.2 90 0 1 0 -0.1 a 0.2 0.2 90 0 1 0.3 -0 l 1.9 1.9 a 0.2 0.2 90 0 1 0 0.2 Z'; + +export const SENTIMENT_NEGATIVE_PATH = + 'M 0 -1 A 1 1 90 1 0 1 0 A 1 1 90 0 0 0 -1 Z M 0.3421 -0.598 A 0.2149 0.2149 90 0 1 0.5296 -0.3636 A 0.2149 0.2149 90 0 1 0.3421 -0.1292 A 0.2149 0.2149 90 0 1 0.1546 -0.3636 A 0.2149 0.2149 90 0 1 0.3421 -0.598 Z M -0.3522 -0.5916 A 0.2148 0.2148 90 0 1 -0.1647 -0.3574 A 0.2149 0.2149 90 0 1 -0.3522 -0.123 A 0.2149 0.2149 90 0 1 -0.5397 -0.3574 A 0.2148 0.2148 90 0 1 -0.3522 -0.5916 Z M 0.5548 0.4151 L 0.4959 0.4449 A 0.0625 0.0625 90 0 1 0.4257 0.4354 C 0.4049 0.4166 0.3802 0.3942 0.3739 0.3898 A 0.6554 0.6554 90 0 0 0.0026 0.2813 A 0.6546 0.6546 90 0 0 -0.3724 0.3919 C -0.3802 0.3974 -0.403 0.4184 -0.4224 0.4368 A 0.0625 0.0625 90 0 1 -0.4933 0.4468 L -0.5513 0.4174 A 0.0625 0.0625 90 0 1 -0.5694 0.3197 C -0.5549 0.3036 -0.5418 0.2895 -0.5366 0.2848 A 0.813 0.813 90 0 1 0.0026 0.0938 A 0.8106 0.8106 90 0 1 0.5481 0.2906 C 0.5511 0.2933 0.5611 0.3043 0.5731 0.3176 A 0.0625 0.0625 90 0 1 0.5548 0.4151 Z'; + +export const SENTIMENT_NEUTRAL_PATH = + 'M 0 -1 A 1 1 90 1 0 1 0 A 1 1 90 0 0 0 -1 Z M -0.3522 -0.4666 A 0.2149 0.2149 90 0 1 -0.1647 -0.2322 A 0.2149 0.2149 90 0 1 -0.3522 0.0021 A 0.2149 0.2149 90 0 1 -0.5397 -0.2322 A 0.2149 0.2149 90 0 1 -0.3522 -0.4666 Z M 0.325 0.5 H -0.325 A 0.05 0.05 90 0 1 -0.375 0.45 V 0.425 A 0.05 0.05 90 0 1 -0.325 0.375 H 0.325 A 0.05 0.05 90 0 1 0.375 0.425 V 0.45 A 0.05 0.05 90 0 1 0.325 0.5 Z M 0.3421 -0.0042 A 0.2149 0.2149 90 0 1 0.1546 -0.2386 A 0.2149 0.2149 90 0 1 0.3421 -0.473 A 0.2149 0.2149 90 0 1 0.5296 -0.2386 A 0.2149 0.2149 90 0 1 0.3421 -0.0043 Z'; + +export const SENTIMENT_POSITIVE_PATH = + 'M 0 -1 A 1 1 90 1 0 1 0 A 1 1 90 0 0 0 -1 Z M -0.3522 -0.5916 A 0.215 0.215 90 0 1 -0.1647 -0.3572 A 0.215 0.215 90 0 1 -0.3522 -0.1229 A 0.215 0.215 90 0 1 -0.5397 -0.3572 A 0.2149 0.2149 90 0 1 -0.3522 -0.5916 Z M 0.3421 -0.598 A 0.215 0.215 90 0 1 0.5296 -0.3635 A 0.2149 0.2149 90 0 1 0.3421 -0.1291 A 0.2149 0.2149 90 0 1 0.1546 -0.3635 A 0.215 0.215 90 0 1 0.3421 -0.598 Z M 0 0.6275 A 0.6161 0.6161 90 0 1 -0.625 0.1187 H 0.625 A 0.6161 0.6161 90 0 1 0 0.6275 Z'; diff --git a/src/types/Chart.ts b/src/types/Chart.ts index 194f22d0e..7c3edc167 100644 --- a/src/types/Chart.ts +++ b/src/types/Chart.ts @@ -608,7 +608,7 @@ export interface ReferenceLineProps { labelFontWeight?: FontWeight; } -export type Icon = 'date'; +export type Icon = 'date' | 'sentimentNegative' | 'sentimentNeutral' | 'sentimentPositive'; export interface MetricRangeProps { children?: Children;