@fto-consult/expo-ui 2.24.0 → 2.24.1

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.
@@ -40,17 +40,25 @@ import {styles as tableStyles} from "$ecomponents/Table";
40
40
  import {DialogProvider} from "$ecomponents/Form/FormData";
41
41
  import Chart,{getMaxSupportedSeriesSize} from "$ecomponents/Chart";
42
42
 
43
- const chart = "chart";
44
43
  export const donutChart = {
45
44
  isChart : true,
46
45
  code : 'donutChart',
47
- label : 'Graphique|Circulaire',
46
+ label : 'Donut',
48
47
  icon : "chart-donut",
49
48
  type: 'donut',
49
+ key : "donut",
50
50
  isDonut : true,
51
- isRendable : ({displayOnlySectionListHeaders,isSectionList})=>isSectionList && displayOnlySectionListHeaders,
51
+ isRendable : ({displayOnlySectionListHeaders,isSectionList})=> false && isSectionList && displayOnlySectionListHeaders,
52
52
  tooltip : "Pour pouvoir visulaiser ce type de graphe, vous devez : grouper les données du tableau selon le criètre de votre choix, puis afficher uniquement les totaux des données groupées"
53
53
  }
54
+ const stackSettings = {
55
+ type : 'switch',
56
+ text : "Graphe empilé?",
57
+ checkedValue : true,
58
+ uncheckedValue : false,
59
+ //le nom de la propriétés dans les propriétés du tableau
60
+ settingKey : "chart",
61
+ }
54
62
  export const displayTypes = {
55
63
  table : {
56
64
  code : "table",
@@ -62,26 +70,49 @@ export const displayTypes = {
62
70
  lineChart : {
63
71
  code : "lineChart",
64
72
  isChart : true,
65
- label : 'Graphique|Linéaire',
73
+ label : 'Linéaire',
66
74
  icon : "chart-areaspline",
67
75
  type : 'line',
76
+ key : "line",
68
77
  },
69
78
  areaChart : {
70
79
  isChart : true,
71
80
  code : 'areaChart',
72
- label : 'Graphique|Surface',
81
+ label : 'Surface',
73
82
  icon : "chart-areaspline-variant",
74
83
  type: 'area',
84
+ key : "line",
75
85
  },
76
86
  barChart : {
77
87
  isChart : true,
78
88
  code : 'barChart',
79
- label : 'Graphique|Barres',
89
+ label : 'Histogramme',
80
90
  icon : "chart-bar",
81
91
  type: 'bar',
82
- isBar : true,
92
+ key : "line",
93
+ settings : {
94
+ stacked : stackSettings,
95
+ }
96
+ },
97
+ pieChart : {
98
+ ...donutChart,
99
+ code : 'pieChart',
100
+ label : 'Pie',
101
+ icon : "chart-pie",
102
+ type: 'pie',
83
103
  },
84
104
  donutChart,
105
+ radarChart : {
106
+ isChart : true,
107
+ code : 'radarChart',
108
+ label : 'Radar',
109
+ icon : "radar",
110
+ type: 'radar',
111
+ key : "line",
112
+ settings : {
113
+ stacked : stackSettings,
114
+ }
115
+ }
85
116
  /*rangeChart : {
86
117
  code : "rangeChart",
87
118
  isChart : true,
@@ -197,6 +228,7 @@ export default class CommonDatagridComponent extends AppComponent {
197
228
  sectionListDataSize : {value : {current : 0}},
198
229
  enablePointerEventsRef : {value : {current:false}},
199
230
  configureSectionListSelectedValues : {value : {}},
231
+ chartIdPrefix : {value : uniqid("datagrid-chart-id-prefix")},
200
232
  ///la liste des fonctions d'aggregations supportées
201
233
  aggregatorFunctions : {value : extendAggreagatorFunctions(this.props.aggregatorFunctions)},
202
234
  ///les types d'affichage
@@ -1345,13 +1377,7 @@ export default class CommonDatagridComponent extends AppComponent {
1345
1377
  items : yItems,
1346
1378
  multiple : true,
1347
1379
  },
1348
- stacked : {
1349
- type : 'switch',
1350
- text : "Graphe empilé?",
1351
- disabled : this.state.displayType !== "barChart",
1352
- checkedValue : true,
1353
- uncheckedValue : false,
1354
- },
1380
+ stacked : stackSettings,
1355
1381
  title : {
1356
1382
  text : "Titre du graphe",
1357
1383
  format :'hashtag',
@@ -1494,6 +1520,7 @@ export default class CommonDatagridComponent extends AppComponent {
1494
1520
  if(!isValidAggregator(aggregatorFunction)){
1495
1521
  aggregatorFunction = this.getActiveAggregatorFunction();
1496
1522
  }
1523
+
1497
1524
  const code = aggregatorFunction.code;
1498
1525
  const isDonut = chartType.isDonut || chartType.isRadial;
1499
1526
  const config = this.getCharConfig();
@@ -1523,12 +1550,10 @@ export default class CommonDatagridComponent extends AppComponent {
1523
1550
  const loopForFooter = ({column,serieName,footers,header})=>{
1524
1551
  if(!isObj(column) || !isObj(footers)) return null;
1525
1552
  if(!isObj(footers[column.field])) return null;
1526
- const footer = footers[column.field]
1553
+ const footer = footers[column.field];
1527
1554
  if(typeof footer[code] !== 'number') return null;
1528
- const label = defaultStr(footer.label,footer.text,footer.field);
1529
1555
  if(typeof footer[code] !== 'number') return null;
1530
1556
  if(isDonut){
1531
- serieName = label;
1532
1557
  dataIndexes[header] = footer[code];
1533
1558
  } else {
1534
1559
  dataIndexes[serieName] = defaultArray(dataIndexes[serieName]);
@@ -1555,6 +1580,7 @@ export default class CommonDatagridComponent extends AppComponent {
1555
1580
  labels.push(index);
1556
1581
  });
1557
1582
  return {
1583
+ name : defaultStr(yAxisColumn.label,yAxisColumn.text,yAxisColumn.field),
1558
1584
  series,
1559
1585
  labels,
1560
1586
  }
@@ -1567,6 +1593,10 @@ export default class CommonDatagridComponent extends AppComponent {
1567
1593
  series
1568
1594
  }
1569
1595
  }
1596
+ }
1597
+ /*** permet de formatter les valeurs de la courbe en fonction du type passé en paramètre */
1598
+ chartValueFormattter(value,columnType){
1599
+
1570
1600
  }
1571
1601
  renderChart(){
1572
1602
  if(!this.canRenderChart()) return null;
@@ -1577,6 +1607,7 @@ export default class CommonDatagridComponent extends AppComponent {
1577
1607
  console.warn("impossible d'afficher le graphe de type ",chartType.label," car le type de données requis pour le rendu de ce graphe est invalide")
1578
1608
  return null;
1579
1609
  }
1610
+ const isDonut = chartType.isDonut || chartType.isRadial;
1580
1611
  const config = this.getCharConfig();
1581
1612
  if(!this.state.columns[config.y]) return null;
1582
1613
  const yAxisColumn = this.state.columns[config.y];
@@ -1656,38 +1687,54 @@ export default class CommonDatagridComponent extends AppComponent {
1656
1687
  customConfig = defaultObj(customConfig);
1657
1688
  customConfig.chart = defaultObj(customConfig.chart);
1658
1689
  const chartProps = extendObj(true,{},this.props.chartProps,customConfig);
1659
- if(chartType.isBar){
1660
- chartProps.chart.stacked = !!config.stacked;
1661
- } else chartProps.chart.stacked = undefined;
1662
- return <Chart
1663
- options = {{
1664
- ...chartProps,
1665
- title : {
1666
- text: defaultStr(config.title,chartProps.title),
1667
- align: 'left',
1668
- //margin: 10,
1669
- //offsetX: 0,
1670
- //offsetY: 0,
1671
- //floating: false,
1672
- style: {
1673
- //fontSize: '14px',
1674
- //fontWeight: 'bold',
1675
- //fontFamily: undefined,
1676
- color: theme.Colors.isValid(config.titleColor)?config.titleColor : undefined,
1677
- },
1678
- },
1679
- series,
1680
- chart : {
1681
- height :350,
1682
- ...defaultObj(chartProps.chart),
1683
- type : chartType.type,
1690
+ const settings = defaultObj(chartType.settings);
1691
+ Object.map(settings,(s,key)=>{
1692
+ if(!isObj(s) || !(key in config)) return null;
1693
+ const settingKey = defaultStr(s.settingKey,"chart");
1694
+ chartProps[settingKey] = defaultObj(chartProps[settingKey]);
1695
+ chartProps[settingKey][key] = config[key];
1696
+ });
1697
+ const chartOptions = {
1698
+ ...chartProps,
1699
+ title :extendObj(true,{}, {
1700
+ text: defaultStr(config.title,chartProps.title),
1701
+ align: 'left',
1702
+ //margin: 10,
1703
+ //offsetX: 0,
1704
+ //offsetY: 0,
1705
+ //floating: false,
1706
+ style: {
1707
+ //fontSize: '14px',
1708
+ //fontWeight: 'bold',
1709
+ //fontFamily: undefined,
1710
+ color: theme.Colors.isValid(config.titleColor)?config.titleColor : undefined,
1684
1711
  },
1685
- xaxis: {
1686
- ...defaultObj(chartProps.xaxis),
1687
- type: 'category',
1688
- ...defaultObj(xaxis)
1689
- }
1690
- }}
1712
+ },chartProps.title),
1713
+ series,
1714
+ chart : extendObj(true,{},{height :350},chartProps.chart,{
1715
+ type : chartType.type,
1716
+ })
1717
+ }
1718
+ //console.log(chartOptions," is chart options");
1719
+ const labelColor = theme.Colors.isValid(config.labelColor)? config.labelColor : theme.colors.text;
1720
+ if(!isDonut){
1721
+ chartOptions.xaxis = extendObj(true,{},{type: 'category'},chartProps.xaxis,{xaxis});
1722
+ const xLabels = chartOptions.xaxis.labels = defaultObj(chartOptions.xaxis.labels);
1723
+ xLabels.style = defaultObj(xLabels.style)
1724
+ xLabels.style.colors = (Array.isArray(xLabels.style.colors) && xLabels.style.colors.length || theme.Colors.isValid(xLabels.style.colors)) ? xLabels.style.colors : labelColor;
1725
+ chartOptions.yaxis = extendObj(true,{},{type: 'category'},chartProps.yaxis);
1726
+ const yLabels = chartOptions.yaxis.labels = defaultObj(chartOptions.yaxis.labels);
1727
+ yLabels.style = defaultObj(yLabels.style)
1728
+ yLabels.style.colors = (Array.isArray(yLabels.style.colors) && yLabels.style.colors.length || theme.Colors.isValid(yLabels.style.colors)) ? yLabels.style.colors : labelColor;
1729
+
1730
+ } else {
1731
+ delete chartOptions.xaxis;
1732
+ delete chartOptions.yaxis;
1733
+ }
1734
+ chartOptions.chart.id = this.chartIdPrefix+defaultStr(chartType.key,"no-key")
1735
+ return <Chart
1736
+ options = {chartOptions}
1737
+ key = {chartOptions.chart.id}
1691
1738
  />
1692
1739
  }
1693
1740
  canShowFooters(){