Skip to content

Commit

Permalink
Merge pull request #114 from pegasystems/feature/trendDisplay
Browse files Browse the repository at this point in the history
add new TrendDisplay component
  • Loading branch information
ricmars authored Jan 6, 2025
2 parents 057b78b + 5eedd78 commit 69de6b9
Show file tree
Hide file tree
Showing 13 changed files with 1,800 additions and 338 deletions.
Binary file added .storybook/static/TrendDisplay_Demo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .storybook/static/TrendDisplay_Demo1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,269 changes: 937 additions & 332 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
"@fullcalendar/react": "^6.1.15",
"@fullcalendar/timegrid": "^6.1.15",
"@hello-pangea/dnd": "^16.6.0",
"@pega/cosmos-react-core": "^7.2.3",
"@pega/cosmos-react-rte": "^7.2.3",
"@pega/cosmos-react-social": "^7.2.3",
"@pega/cosmos-react-work": "^7.2.3",
"@pega/cosmos-react-core": "^7.2.5",
"@pega/cosmos-react-rte": "^7.2.5",
"@pega/cosmos-react-social": "^7.2.5",
"@pega/cosmos-react-work": "^7.2.5",
"gantt-task-react": "^0.3.9",
"imask": "^7.6.1",
"jsbarcode": "^3.11.6",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Pega_Extensions_Meter/Docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The meter should not be used to indicate progress, such as loading or percent co

<Controls />

## Samples
## Examples

Example of using a multiple meter to display test coverage

Expand All @@ -25,7 +25,7 @@ Example of using a multiple meter to display the storage capacity

<Story of={DemoStories.Grouped1} />

## Configuration
## Demo

Here is an example of using the meter in different views (Case Summary, Details and form view)

Expand Down
49 changes: 49 additions & 0 deletions src/components/Pega_Extensions_TrendDisplay/Docs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Meta, Primary, Controls, Story } from '@storybook/blocks';
import * as DemoStories from './demo.stories';

<Meta of={DemoStories} />

# Overview

Trend display....

<Primary />

## Props

<Controls />

## Examples

This component is a flexible component that can render a currency value or a string using different custom color - It can also display a trend of the value (up or down) as well as render a line chart of multiple pieces of data.

<Story of={DemoStories.Demo1} />

Display a currency or percentage value based on the trend (positive or negative)

<Story of={DemoStories.Demo2} />
<Story of={DemoStories.Demo3} />
<Story of={DemoStories.Demo4} />
<Story of={DemoStories.Demo5} />

Same as before but displayed using renderingMode='badge'

<Story of={DemoStories.Demo2_badge} />
<Story of={DemoStories.Demo3_badge} />
<Story of={DemoStories.Demo4_badge} />
<Story of={DemoStories.Demo5_badge} />

Display values with custom colors

<Story of={DemoStories.Demo6_1} />
<Story of={DemoStories.Demo6_2} />

## Demo

Here is an example of using the trend display in a list view

![Configuration](TrendDisplay_Demo.jpg)

and in a case view summary

![Configuration](TrendDisplay_Demo1.jpg)
41 changes: 41 additions & 0 deletions src/components/Pega_Extensions_TrendDisplay/TrendGraph.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { buildSmoothPath, normalizeDataset } from './utils';

type TrendGraphProps = {
colorValue: string;
radius?: number;
padding?: number;
data: number[];
width?: number;
height?: number;
};

const TrendGraph = (props: TrendGraphProps) => {
const { colorValue, radius = 3, padding = 2, width = 300, height = 75, data = [] } = props;

if (!data || data.length < 2) {
return null;
}

const normalizedValues = normalizeDataset(data, {
minX: padding,
maxX: width - padding,
minY: height - padding,
maxY: padding
});

const path = buildSmoothPath(normalizedValues, radius);

return (
<svg
width='120px'
strokeWidth='1'
strokeLinecap='butt'
stroke={colorValue}
viewBox={`0 0 ${width} ${height}`}
>
<path d={path} fill='none' />
</svg>
);
};

export default TrendGraph;
237 changes: 237 additions & 0 deletions src/components/Pega_Extensions_TrendDisplay/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
{
"name": "Pega_Extensions_TrendDisplay",
"label": "Trend Display",
"description": "Trend Display",
"organization": "Pega",
"version": "1.0.0",
"library": "Extensions",
"allowedApplications": [],
"componentKey": "Pega_Extensions_TrendDisplay",
"type": "Field",
"subtype": "Decimal-Currency",
"properties": [
{
"key": "trendData",
"format": "PROPERTY",
"name": "trendData",
"label": "Trend data if showing a percentage or trend of values"
},
{
"name": "labelOption",
"label": "Label value",
"format": "SELECT",
"defaultValue": "custom",
"source": [
{
"key": "default",
"value": "Default"
},
{
"key": "custom",
"value": "Custom"
}
]
},
{
"name": "label",
"label": "Custom label value",
"format": "VALUEINPUT",
"required": true,
"ruleType": "Paragraph"
},
{
"format": "CASCADE",
"source": {
"format": "SELECT",
"label": "ISO Code Selection",
"name": "isoCodeSelection",
"defaultValue": "constant",
"source": [
{
"key": "constant",
"value": "Constant"
},
{
"key": "propertyRef",
"value": "Property Reference"
}
]
},
"cascadeElements": [
{
"key": "currencyISOCode",
"format": "TEXT",
"name": "currencyISOCode",
"label": "Currency ISO Code",
"defaultValue": "USD",
"match": "constant"
},
{
"key": "currencyISOCode",
"format": "PROPERTY",
"name": "currencyISOCode",
"label": "Currency ISO Code",
"match": "propertyRef"
}
]
},
{
"format": "CASCADE",
"source": {
"format": "SELECT",
"label": "Color selection",
"name": "ColorSelection",
"defaultValue": "constant",
"source": [
{
"key": "constant",
"value": "Constant"
},
{
"key": "propertyRef",
"value": "Property Reference"
}
]
},
"cascadeElements": [
{
"key": "colorMode",
"format": "TEXT",
"name": "colorMode",
"label": "Color Mode",
"defaultValue": "auto",
"match": "constant"
},
{
"key": "colorMode",
"format": "PROPERTY",
"name": "colorMode",
"label": "Color Mode",
"match": "propertyRef"
}
]
},
{
"format": "SELECT",
"name": "renderingMode",
"label": "renderingMode",
"defaultValue": "normal",
"source": [
{
"key": "normal",
"value": "normal"
},
{
"key": "badge",
"value": "badge"
}
]
},
{
"label": "Formatting",
"format": "GROUP",
"properties": [
{
"format": "SELECT",
"name": "currencyDisplay",
"label": "Currency display",
"defaultValue": "symbol",
"source": [
{
"key": "symbol",
"value": "Auto"
},
{
"key": "code",
"value": "Code"
},
{
"key": "name",
"value": "Name"
}
]
},
{
"format": "SELECT",
"name": "negative",
"label": "Negative number display",
"defaultValue": "minus-sign",
"source": [
{
"key": "minus-sign",
"value": "Standard"
},
{
"key": "parentheses",
"value": "Accounting"
}
]
},
{
"format": "SELECT",
"name": "notation",
"label": "Notation",
"visibility": "(!negative = parentheses)",
"defaultValue": "standard",
"source": [
{
"key": "standard",
"value": "Standard"
},
{
"key": "compact",
"value": "Compact"
}
]
},
{
"format": "SELECT",
"name": "currencyDecimalPrecision",
"label": "Decimal places shown",
"defaultValue": "auto",
"source": [
{
"key": "auto",
"value": "Auto"
},
{
"key": "0",
"value": "None"
},
{
"key": "1",
"value": "1"
},
{
"key": "2",
"value": "2"
},
{
"key": "3",
"value": "3"
},
{
"key": "4",
"value": "4"
}
]
}
]
},
{
"label": "Conditions",
"format": "GROUP",
"properties": [
{
"name": "visibility",
"label": "Visibility",
"format": "VISIBILITY"
}
]
}
],
"defaultConfig": {
"label": "@L $this.label",
"detailFVLItem": true
}
}
Loading

0 comments on commit 69de6b9

Please sign in to comment.