@statisticsfinland/pxvisualizer 1.0.1-d.1 → 1.0.2-d.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -7,7 +7,58 @@ The software is provided as is and Statistics Finland will **not** offer any sup
|
|
|
7
7
|
**IMPORTANT:** PxVisualizer package uses HighCharts for rendering the visualizations. Please note that commercial use of HighCharts requires a commercial license. Non-commercial use may qualify for a free educational or personal license. Read more about licenses
|
|
8
8
|
in the [HighCharts shop](https://shop.highsoft.com/?utm_source=npmjs&utm_medium=referral&utm_campaign=highchartspage&utm_content=licenseinfo).
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Implementation
|
|
11
|
+
Implementing a visualization requires importing either the Chart or drawChart component from the PxVisualizer package and passing required and optional props to it. The Chart component will then render the visualization based on the provided data.
|
|
12
|
+
|
|
13
|
+
### React
|
|
14
|
+
````
|
|
15
|
+
import { Chart } from '@statisticsfinland/pxvisualizer';
|
|
16
|
+
<Chart locale={[string]} pxGraphData={[visualizationResponse]} />
|
|
17
|
+
````
|
|
18
|
+
|
|
19
|
+
- locale: string - Code of the locale to be used in the visualization. The provided locale code must match with the available language codes in the PxVisualizer translations.
|
|
20
|
+
- pxGraphData: object - Visualization response data from the PxGraf API. More details about the visualization response can be found below. The object must implement the IQueryVisualizationResponse interface. A documentation for building this object can be found from PxGraf documentation [here](https://github.com/StatisticsFinland/PxGraf/blob/dev/docs/VISUALIZATION_RESPONSE.md)
|
|
21
|
+
### Non-React implementation
|
|
22
|
+
|
|
23
|
+
````
|
|
24
|
+
import { drawChart } from '@statisticsfinland/pxvisualizer';
|
|
25
|
+
drawChart(container, pxGraphData, locale);>
|
|
26
|
+
````
|
|
27
|
+
- container: string - ID of the container element where the visualization will be drawn.
|
|
28
|
+
|
|
29
|
+
### Optional props
|
|
30
|
+
- selectedVariableCodes: [key: string]: string[] - Dictionary of the currently selected value codes for selectable variables.
|
|
31
|
+
- showContextMenu: boolean - Flag to show or hide the context menu in the visualization.
|
|
32
|
+
- menuItemDefinitions: object[] - Definitions for custom context menu items. These can be either links or run custom functions. The provided object must implement either the IFunctionalMenuItem or ILinkMenuItem interface.
|
|
33
|
+
- menuIconInheritColor: boolean - Flag to inherit the color of the context menu icons from the parent element.
|
|
34
|
+
- showTableTitles: boolean - Flag to show or hide the titles in the table view.
|
|
35
|
+
- showTableUnits: boolean - Flag to show or hide the units in the table view.
|
|
36
|
+
- showTableSources: boolean - Flag to show or hide the sources in the table view.
|
|
37
|
+
- footnote: string - Custom footnote to be displayed in the visualization.
|
|
38
|
+
|
|
39
|
+
### IFunctionalMenuItem interface
|
|
40
|
+
IFunctionalMenuItem interface is used to define custom context menu items that execute a function when clicked. The interface extends IBaseMenuItem interface and contains the following property:
|
|
41
|
+
- onClick: () => void - Defines the function to be executed when the menu item is clicked.
|
|
42
|
+
|
|
43
|
+
### ILinkMenuItem interface
|
|
44
|
+
- url: string - URL to be opened when the menu item is clicked.
|
|
45
|
+
- isExternal (optional): boolean - Flag to indicate if the URL is external.
|
|
46
|
+
- openNewTab (optional): boolean - Flag to open the URL in a new tab.
|
|
47
|
+
|
|
48
|
+
#### IBaseMenuItem interface
|
|
49
|
+
- text: string - Text to be displayed in the menu item.
|
|
50
|
+
- prefixIcon (optional): TIcon | Exclude<React.ReactNode, string> - Icon to be displayed before the text. Must either implement the TIcon type or be a valid React node.
|
|
51
|
+
- suffixIcon (optional): TIcon | Exclude<React.ReactNode, string> - Icon to be displayed after the text. Must either implement the TIcon type or be a valid React node.
|
|
52
|
+
|
|
53
|
+
#### TIcon type
|
|
54
|
+
- TIcon type defines the type of an icon. It is a string that must be one of the following values:
|
|
55
|
+
- 'Bars'
|
|
56
|
+
- 'Times'
|
|
57
|
+
- 'Download'
|
|
58
|
+
- 'ExternalLink'
|
|
59
|
+
- 'Copy'
|
|
60
|
+
|
|
61
|
+
## Development
|
|
11
62
|
1. Installation process
|
|
12
63
|
- npm run build to build a working package, or npm run dev if you intend to develop the package using npm link
|
|
13
64
|
- run npm link in the root folder
|
|
@@ -25,7 +76,7 @@ in the [HighCharts shop](https://shop.highsoft.com/?utm_source=npmjs&utm_medium=
|
|
|
25
76
|
3. Software dependencies
|
|
26
77
|
- check package.json for dependencies
|
|
27
78
|
|
|
28
|
-
## Structure
|
|
79
|
+
## Project Structure
|
|
29
80
|
1. react
|
|
30
81
|
- contains react specific files, mainly components that can be used in a specific react based projects for visualizing pxgraf data. Depends on React and core folder functionality.
|
|
31
82
|
2. core
|