generic-dashboard
generic build of dashboard customizing ng2-angular-chart
Table of Contents
Install
npm i generic-dashboard --save
Usage
Import the GenericDashboardModule
in your app.module.ts
:
; @
in addition you should add link for the follwing styles and scripts in your application
If you are using Angular CLI you can follow the example below...
angular.json
"styles": [ "src/styles.scss",+ "node_modules/bootstrap/dist/css/bootstrap.css"+ "node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css"],"scripts": [+ "node_modules/jquery/dist/jquery.min.js",+ "node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"],
index.html
<link rel="icon" type="image/x-icon" href="favicon.ico">+ <link rel="stylesheet" href="http://jobmanager.seldatech.com/images/dashboard/fonts/fontawesome-pro-5.0.13/css/fontawesome-all.min.css" >+ <link href="https://fonts.googleapis.com/css?family=Montserrat:100,100i,200,200i,300,300i,400i,500,500i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">+ <script src="//cdn.ckeditor.com/4.7.1/full-all/ckeditor.js"></script></head>
polyfills.ts
/*************************************************************************************************** * APPLICATION IMPORTS */+ (window as any).global = window;
create xml according to instruction in xml section
In your templates, use the lib-dashboard
component like this:
and in the corresponding .ts
dashboard settings:
//partial exampledashboardSettings =
Settings
The following list of settings are supported by the component. Configure the settings to meet your requirement.
Setting | Type | Description | Default Value |
---|---|---|---|
chartsPerRow | Number | Number of charts per row | 3 |
xmlUrl | String | Url for chart structure xml | http://jobmanager.seldatech.com/images/XMLs/xml-file.xml |
loadingImage | String | Url for loading image | http://jobmanager.seldatech.com/images/dashboard/loading.gif |
getChartsOfUserUrl | String | Url to get charts of user - should be get method | '' |
getIndicatorsOfUserUrl | String | Url to get indicators of user - should be get method | '' |
getChartDataUrl | String | Url to get data of specific chart - recieves chart id - should be get method | '' |
getIndicatorDataUrl | String | Url to get data of specific indicator - recieves indicator id - should be get method | '' |
addChartUrl | String | Url for add chart or indicator - should be post method | '' |
updateChartUrl | String | Url for update chart or indicator - should be put methodn | '' |
deleteChartUrl | String | Url for delete chart or indicator - should be delete method | '' |
addChartText | String | Text for add chart button | Add chart |
noDataText | String | Text to display when no data to show | No data to show |
pieTooltip | String | Pie chart icon tooltip | Pie |
barsTooltip | String | Bars chart icon tooltip | Bars |
linesTooltip | String | Lines chart icon tooltip | Lines |
areaTooltip | String | Area chart icon tooltip | Area |
stackedAreaTooltip | String | Stacked area chart icon tooltip | Stacked area |
stackedArea100Tooltip | String | Stacked area 100% chart icon tooltip | Stacked area 100% |
zoomInTooltip | String | Zoom in tooltip | Zoom in |
zoomOutTooltip | String | Zoom out tooltip | Zoom out |
resetTooltip | String | Reset tooltip | Reset |
leftTooltip | String | Left tooltip | Left |
rightTooltip | String | Right tooltip | Right |
expandTooltip | String | Expand tooltip | Expand |
collapseTooltip | String | Collapse tooltip | Collapse |
editTooltip | String | Edit tooltip | Edit |
deleteTooltip | String | Delete tooltip | Delete |
kpiSettingsTitle | String | Chart settings dialog title | KPI Settings |
defaultChartText | String | label for chart type select | Default chart: |
saveText | String | Save button text | Save |
cancelText | String | Cancel button text | Cancel |
selectText | String | Text to be show in the dropdown, when no items are selected | Select Items |
selectAllText | String | Text to display as the label of select all option | Select All |
unSelectAllText | String | Text to display as the label of unSelect option | UnSelect All |
componentType | any | Array of reference to custom components | not set |
XML
In order to define chart structure you should create xml according to this schema
A two-dimensional diagram is consists of the x-axis range and legend definition, according to the given data the chart is able to calculate the v-axis.
In the kpi section you will need to provide a type. kpi type could be one of the following:
- "chart"- the simple case.
- "indicator"- indicators are used for one dimensional data,specific value for specific parameter.
- "custom-html"- provide ckeditor for your custom html
- "componentName" - allow you to define your own component and let the user supply inputs in case of needed. inputs are defined by properties and nodes.
- iconUrl is optional ,in case you want to override the default provided icon.
In the properties section you should provide chart properties like name , creation date etc. Note : define of property with id 'name' is required. example:
In the node section you should provide nodes which describe the x-axis range and the legend. each node can have values that represent the selection options. you need to provide 'id' and 'name' properties for each value. node type can be one of the following: select, multiselect, autocomplete, date
for example:
another way to provide the values is by setting url address that returns list of id name pairs. you can set the base url in baseUrl attribute of dashboard section. the urls params can be based on previous node by sending its id.
example of a list based on values retrieves from server
ChartValues parameter now contains the value of the chosen option in "ChartValues" node.
a node might be depends on one or more other nodes. that means that it will not be displayed untill user choose its dependencies. the dependencies are seperated by a semicolon. use 'showIf' property if node should be visibile only in specific values of depends. initialize 'showIf' with values to be shown separated by semicolon or url with dependency as parameter.
example:
node value can contain one or more nodes. this is limited for one level only. example:
view full xml example
API
For function supplied for getChartDataUrl: if data is base on 2 diemnsions only, the second column with sum value should be called sum.
License
MIT