@mwater/visualization 5.2.0 → 5.3.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.
Files changed (254) hide show
  1. package/lib/ColorComponent.d.ts +10 -11
  2. package/lib/ColorComponent.js +78 -29
  3. package/lib/ColorSchemeFactory.d.ts +13 -2
  4. package/lib/ColorSchemeFactory.js +7 -5
  5. package/lib/CustomColorsContext.d.ts +6 -0
  6. package/lib/CustomColorsContext.js +6 -0
  7. package/lib/FiltersDesignerComponent.d.ts +1 -4
  8. package/lib/FiltersDesignerComponent.js +2 -3
  9. package/lib/LocaleContextInjector.d.ts +5 -11
  10. package/lib/LocaleContextInjector.js +4 -12
  11. package/lib/MWaterAddRelatedFormComponent.js +3 -3
  12. package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
  13. package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
  14. package/lib/MWaterCompleteTableSelectComponent.d.ts +5 -16
  15. package/lib/MWaterCompleteTableSelectComponent.js +36 -36
  16. package/lib/MWaterContextComponent.d.ts +4 -6
  17. package/lib/MWaterContextComponent.js +4 -13
  18. package/lib/MWaterLoaderComponent.d.ts +5 -3
  19. package/lib/MWaterLoaderComponent.js +2 -1
  20. package/lib/MWaterTableSelectComponent.d.ts +1 -4
  21. package/lib/MWaterTableSelectComponent.js +10 -12
  22. package/lib/UIComponents.d.ts +2 -2
  23. package/lib/UIComponents.js +4 -12
  24. package/lib/axes/AxisBuilder.d.ts +7 -4
  25. package/lib/axes/AxisBuilder.js +3 -1
  26. package/lib/axes/AxisComponent.d.ts +2 -5
  27. package/lib/axes/AxisComponent.js +1 -2
  28. package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
  29. package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
  30. package/lib/dashboards/DashboardComponent.d.ts +4 -12
  31. package/lib/dashboards/DashboardComponent.js +18 -38
  32. package/lib/dashboards/DashboardDesign.d.ts +3 -3
  33. package/lib/dashboards/DashboardUpgrader.js +36 -1
  34. package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
  35. package/lib/dashboards/DashboardViewComponent.js +109 -132
  36. package/lib/dashboards/FontStyleEditor.d.ts +8 -0
  37. package/lib/dashboards/FontStyleEditor.js +130 -0
  38. package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
  39. package/lib/dashboards/LayoutOptionsComponent.js +211 -42
  40. package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
  41. package/lib/dashboards/ServerDashboardDataSource.js +52 -33
  42. package/lib/dashboards/WidgetComponent.d.ts +3 -3
  43. package/lib/dashboards/WidgetComponent.js +3 -6
  44. package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
  45. package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
  46. package/lib/dashboards/layoutOptions.d.ts +83 -0
  47. package/lib/dashboards/layoutOptions.js +436 -10
  48. package/lib/datagrids/DatagridDesign.d.ts +7 -6
  49. package/lib/datagrids/ServerDatagridDataSource.d.ts +7 -6
  50. package/lib/datagrids/ServerDatagridDataSource.js +87 -33
  51. package/lib/demo.js +3 -3
  52. package/lib/index.css +5 -0
  53. package/lib/index.d.ts +1 -1
  54. package/lib/index.js +0 -1
  55. package/lib/layouts/LayoutManager.d.ts +33 -29
  56. package/lib/layouts/LayoutManager.js +2 -8
  57. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -57
  58. package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
  59. package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
  60. package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
  61. package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
  62. package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
  63. package/lib/mWaterLoader.d.ts +2 -0
  64. package/lib/mWaterLoader.js +2 -1
  65. package/lib/maps/AddLayerComponent.d.ts +6 -8
  66. package/lib/maps/AddLayerComponent.js +6 -6
  67. package/lib/maps/BingLayer.js +10 -20
  68. package/lib/maps/BufferLayer.js +2 -1
  69. package/lib/maps/ChoroplethLayer.js +2 -1
  70. package/lib/maps/DirectMapDataSource.d.ts +5 -2
  71. package/lib/maps/DirectMapDataSource.js +2 -1
  72. package/lib/maps/EditPopupComponent.js +2 -1
  73. package/lib/maps/MapComponent.d.ts +1 -4
  74. package/lib/maps/MapComponent.js +3 -3
  75. package/lib/maps/MarkersLayer.js +30 -25
  76. package/lib/maps/RasterMapViewComponent.d.ts +1 -4
  77. package/lib/maps/RasterMapViewComponent.js +3 -3
  78. package/lib/maps/ServerMapDataSource.d.ts +2 -3
  79. package/lib/maps/ServerMapDataSource.js +5 -5
  80. package/lib/maps/VectorMapViewComponent.js +2 -1
  81. package/lib/maps/mapSymbols.js +2 -0
  82. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  83. package/lib/maps/vectorMaps.js +61 -55
  84. package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
  85. package/lib/quickfilter/QuickfiltersComponent.js +3 -3
  86. package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
  87. package/lib/richtext/DropdownPaletteItem.js +82 -0
  88. package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
  89. package/lib/richtext/FontColorPaletteItem.js +32 -27
  90. package/lib/richtext/ItemsHtmlConverter.js +12 -3
  91. package/lib/richtext/RichTextComponent.d.ts +26 -52
  92. package/lib/richtext/RichTextComponent.js +166 -128
  93. package/lib/valueFormatter.js +6 -1
  94. package/lib/wellknown.d.ts +5 -0
  95. package/lib/wellknown.js +288 -0
  96. package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
  97. package/lib/widgets/DropdownWidgetComponent.js +48 -25
  98. package/lib/widgets/IFrameWidgetComponent.d.ts +1 -2
  99. package/lib/widgets/ImageWidgetComponent.d.ts +2 -3
  100. package/lib/widgets/MapWidget.d.ts +2 -0
  101. package/lib/widgets/MapWidget.js +2 -1
  102. package/lib/widgets/TOCWidget.js +2 -1
  103. package/lib/widgets/Widget.d.ts +2 -0
  104. package/lib/widgets/WidgetDataSource.d.ts +3 -1
  105. package/lib/widgets/charts/Chart.d.ts +0 -1
  106. package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
  107. package/lib/widgets/charts/ChartViewComponent.js +11 -3
  108. package/lib/widgets/charts/ChartWidget.d.ts +1 -62
  109. package/lib/widgets/charts/ChartWidget.js +4 -183
  110. package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
  111. package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
  112. package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
  113. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
  114. package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
  115. package/lib/widgets/charts/layered/LayeredChart.js +6 -7
  116. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
  117. package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
  118. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
  119. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +3 -0
  120. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
  121. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -2
  122. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
  123. package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
  124. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
  125. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -112
  126. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
  127. package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
  128. package/lib/widgets/charts/pivot/PivotChart.js +47 -17
  129. package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
  130. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +1 -1
  131. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
  132. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
  133. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
  134. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
  135. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
  136. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
  137. package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
  138. package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -28
  139. package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
  140. package/lib/widgets/charts/table/TableChart.js +8 -4
  141. package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
  142. package/lib/widgets/charts/table/TableChartViewComponent.js +11 -11
  143. package/lib/widgets/text/TextComponent.d.ts +5 -12
  144. package/lib/widgets/text/TextComponent.js +19 -39
  145. package/lib/widgets/text/TextWidget.d.ts +2 -1
  146. package/lib/widgets/text/TextWidget.js +5 -1
  147. package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
  148. package/lib/widgets/text/TextWidgetComponent.js +76 -19
  149. package/lib/widgets/text/TextWidgetDesign.d.ts +13 -1
  150. package/lib/widgets/text/TextWidgetDesign.js +6 -0
  151. package/package.json +4 -4
  152. package/src/ColorComponent.tsx +177 -0
  153. package/src/ColorSchemeFactory.ts +12 -6
  154. package/src/CustomColorsContext.tsx +8 -0
  155. package/src/FiltersDesignerComponent.ts +3 -4
  156. package/src/LocaleContextInjector.tsx +14 -13
  157. package/src/MWaterAddRelatedFormComponent.ts +3 -3
  158. package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
  159. package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
  160. package/src/MWaterContextComponent.tsx +8 -17
  161. package/src/MWaterLoaderComponent.ts +6 -3
  162. package/src/MWaterTableSelectComponent.tsx +11 -12
  163. package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
  164. package/src/axes/AxisBuilder.ts +7 -5
  165. package/src/axes/AxisComponent.ts +3 -4
  166. package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
  167. package/src/dashboards/DashboardComponent.tsx +71 -107
  168. package/src/dashboards/DashboardDesign.ts +3 -3
  169. package/src/dashboards/DashboardUpgrader.ts +41 -1
  170. package/src/dashboards/DashboardViewComponent.tsx +313 -0
  171. package/src/dashboards/FontStyleEditor.tsx +166 -0
  172. package/src/dashboards/LayoutOptionsComponent.tsx +379 -75
  173. package/src/dashboards/ServerDashboardDataSource.ts +52 -33
  174. package/src/dashboards/WidgetComponent.tsx +6 -12
  175. package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
  176. package/src/dashboards/layoutOptions.tsx +581 -0
  177. package/src/datagrids/DatagridDesign.ts +8 -3
  178. package/src/datagrids/ServerDatagridDataSource.ts +106 -43
  179. package/src/demo.ts +3 -3
  180. package/src/index.css +5 -0
  181. package/src/index.ts +1 -1
  182. package/src/layouts/LayoutManager.ts +44 -42
  183. package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
  184. package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
  185. package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
  186. package/src/mWaterLoader.ts +4 -1
  187. package/src/maps/AddLayerComponent.ts +9 -9
  188. package/src/maps/BingLayer.ts +16 -26
  189. package/src/maps/BufferLayer.ts +2 -1
  190. package/src/maps/ChoroplethLayer.ts +2 -1
  191. package/src/maps/DirectMapDataSource.ts +12 -3
  192. package/src/maps/EditPopupComponent.ts +2 -1
  193. package/src/maps/MapComponent.ts +3 -3
  194. package/src/maps/MarkersLayer.ts +38 -41
  195. package/src/maps/RasterMapViewComponent.ts +3 -3
  196. package/src/maps/ServerMapDataSource.ts +7 -7
  197. package/src/maps/VectorMapViewComponent.tsx +2 -1
  198. package/src/maps/mapSymbols.ts +2 -0
  199. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  200. package/src/maps/vectorMaps.tsx +79 -74
  201. package/src/quickfilter/QuickfiltersComponent.ts +3 -3
  202. package/src/richtext/DropdownPaletteItem.tsx +144 -0
  203. package/src/richtext/FontColorPaletteItem.tsx +160 -0
  204. package/src/richtext/ItemsHtmlConverter.ts +15 -5
  205. package/src/richtext/RichTextComponent.tsx +274 -232
  206. package/src/valueFormatter.ts +5 -1
  207. package/src/wellknown.ts +286 -0
  208. package/src/widgets/DropdownWidgetComponent.tsx +75 -0
  209. package/src/widgets/MapWidget.ts +5 -2
  210. package/src/widgets/TOCWidget.ts +2 -1
  211. package/src/widgets/Widget.ts +3 -0
  212. package/src/widgets/WidgetDataSource.ts +3 -1
  213. package/src/widgets/charts/Chart.ts +1 -1
  214. package/src/widgets/charts/ChartViewComponent.ts +16 -3
  215. package/src/widgets/charts/ChartWidget.ts +3 -275
  216. package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
  217. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
  218. package/src/widgets/charts/layered/LayeredChart.ts +4 -6
  219. package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
  220. package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
  221. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
  222. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
  223. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
  224. package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
  225. package/src/widgets/charts/pivot/PivotChart.ts +56 -18
  226. package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
  227. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
  228. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
  229. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
  230. package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
  231. package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
  232. package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
  233. package/src/widgets/charts/table/TableChart.ts +8 -4
  234. package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
  235. package/src/widgets/charts/table/TableChartViewComponent.ts +13 -14
  236. package/src/widgets/text/TextComponent.tsx +47 -49
  237. package/src/widgets/text/TextWidget.ts +8 -3
  238. package/src/widgets/text/TextWidgetComponent.tsx +249 -0
  239. package/src/widgets/text/TextWidgetDesign.ts +22 -1
  240. package/src/ColorComponent.ts +0 -117
  241. package/src/dashboards/DashboardViewComponent.ts +0 -303
  242. package/src/dashboards/layoutOptions.ts +0 -40
  243. package/src/layout-styles.css +0 -263
  244. package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
  245. package/src/layouts/grid/GridLayoutComponent.ts +0 -67
  246. package/src/layouts/grid/GridLayoutManager.ts +0 -185
  247. package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
  248. package/src/layouts/grid/PaletteItemComponent.ts +0 -28
  249. package/src/layouts/grid/README.md +0 -14
  250. package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
  251. package/src/richtext/FontColorPaletteItem.ts +0 -172
  252. package/src/richtext/FontSizePaletteItem.ts +0 -110
  253. package/src/widgets/DropdownWidgetComponent.ts +0 -78
  254. package/src/widgets/text/TextWidgetComponent.ts +0 -120
@@ -41,13 +41,13 @@ const chartTypes = {
41
41
  scatter: billboard_js_1.scatter,
42
42
  area: billboard_js_1.area,
43
43
  pie: billboard_js_1.pie,
44
- donut: billboard_js_1.donut,
44
+ donut: billboard_js_1.donut
45
45
  };
46
46
  const commaFormatter = d3Format.format(",");
47
47
  const compactFormatter = (d) => {
48
48
  // Only if large, otherwise use standard formatting
49
49
  if (Math.abs(d) > 999) {
50
- return d3Format.format("~s")(d).replace('G', 'B');
50
+ return d3Format.format("~s")(d).replace("G", "B");
51
51
  }
52
52
  else {
53
53
  return commaFormatter(d);
@@ -240,7 +240,11 @@ class LayeredChartCompiler {
240
240
  },
241
241
  // Hide if one layer with no color axis
242
242
  legend: {
243
- hide: options.design.layers.length === 1 && !options.design.layers[0].axes.color ? true : c3Data.legendHide
243
+ hide: options.design.layers.length === 1 && !options.design.layers[0].axes.color
244
+ ? true
245
+ : options.design.hideLegend === true
246
+ ? true
247
+ : c3Data.legendHide
244
248
  },
245
249
  grid: { focus: { show: false } },
246
250
  axis: {
@@ -250,7 +254,12 @@ class LayeredChartCompiler {
250
254
  text: cleanString(c3Data.xAxisLabelText),
251
255
  position: options.design.transpose ? "outer-middle" : "outer-center"
252
256
  },
253
- tick: { fit: c3Data.xAxisTickFit }
257
+ tick: {
258
+ multiline: options.design.xAxisTickMultiline,
259
+ culling: false,
260
+ fit: c3Data.xAxisTickFit
261
+ },
262
+ clipPath: false
254
263
  },
255
264
  y: {
256
265
  label: {
@@ -291,14 +300,15 @@ class LayeredChartCompiler {
291
300
  },
292
301
  expand: false // Don't expand/contract
293
302
  },
294
- transition: { duration: 0 } // Transitions interfere with scoping
303
+ transition: { duration: 0 }, // Transitions interfere with scoping
304
+ // padding: !isPolar ? { mode: "fit" } : undefined
295
305
  };
296
306
  // && (options.design.type === "pie" || options.design.type === "donut")
297
307
  if (options.design.labels) {
298
308
  // same color values gets hidden!! https://github.com/naver/billboard.js/issues/871
299
309
  chartDesign.data.labels = {
300
310
  colors: chartDesign.data.columns.reduce((a, c) => {
301
- a[c[0]] = '#000';
311
+ a[c[0]] = "#000";
302
312
  return a;
303
313
  }, {})
304
314
  };
@@ -307,7 +317,7 @@ class LayeredChartCompiler {
307
317
  ...chartDesign.data.labels,
308
318
  position: {
309
319
  y: 15
310
- }, // TODO why does this not type correctly?
320
+ } // TODO why does this not type correctly?
311
321
  };
312
322
  }
313
323
  }
@@ -340,7 +350,7 @@ class LayeredChartCompiler {
340
350
  }
341
351
  if (options.design.yThresholds) {
342
352
  chartDesign.grid.y = {
343
- lines: lodash_1.default.map(options.design.yThresholds, (t) => ({
353
+ lines: lodash_1.default.map(options.design.yThresholds, t => ({
344
354
  value: t.value,
345
355
  text: t.label
346
356
  }))
@@ -355,7 +365,7 @@ class LayeredChartCompiler {
355
365
  }
356
366
  isCategoricalX(design) {
357
367
  // Check if categorical x axis (bar charts always are)
358
- let categoricalX = design.type === "bar" || lodash_1.default.any(design.layers, (l) => l.type === "bar");
368
+ let categoricalX = design.type === "bar" || lodash_1.default.any(design.layers, l => l.type === "bar");
359
369
  // Check if x axis is categorical type
360
370
  const xType = this.axisBuilder.getAxisType(design.layers[0].axes.x);
361
371
  if (["enum", "text", "boolean"].includes(xType || "")) {
@@ -371,7 +381,7 @@ class LayeredChartCompiler {
371
381
  // Outputs: columns, types, names, colors. Also dataMap which is a map of "layername:index" to { layerIndex, row }
372
382
  compileData(design, data, locale) {
373
383
  // If polar chart (no x axis)
374
- if (["pie", "donut"].includes(design.type) || lodash_1.default.any(design.layers, (l) => ["pie", "donut"].includes(l.type))) {
384
+ if (["pie", "donut"].includes(design.type) || lodash_1.default.any(design.layers, l => ["pie", "donut"].includes(l.type))) {
375
385
  return this.compileDataPolar(design, data, locale);
376
386
  }
377
387
  if (this.isCategoricalX(design)) {
@@ -400,7 +410,7 @@ class LayeredChartCompiler {
400
410
  // Get indexed ordering of categories (lookup from value to index) without removing excluded values
401
411
  const categoryOrder = lodash_1.default.zipObject(lodash_1.default.map(categories, (c, i) => [c.value, i]));
402
412
  // Sort by category order
403
- layerData = lodash_1.default.sortBy(layerData, (row) => categoryOrder[row.color]);
413
+ layerData = lodash_1.default.sortBy(layerData, row => categoryOrder[row.color]);
404
414
  // Create a series for each row
405
415
  lodash_1.default.each(layerData, (row, rowIndex) => {
406
416
  // Skip if value excluded
@@ -487,7 +497,7 @@ class LayeredChartCompiler {
487
497
  layerData = this.makeRowsCumulative(layerData);
488
498
  }
489
499
  // Remove excluded values
490
- layerData = lodash_1.default.filter(layerData, (row) => !lodash_1.default.includes(layer.axes.x.excludedValues || [], row.x));
500
+ layerData = lodash_1.default.filter(layerData, row => !lodash_1.default.includes(layer.axes.x.excludedValues || [], row.x));
491
501
  // If has color axis
492
502
  if (layer.axes.color) {
493
503
  // Create a series for each color value
@@ -498,11 +508,11 @@ class LayeredChartCompiler {
498
508
  // Get indexed ordering of categories (lookup from value to index) without removing excluded values
499
509
  const categoryOrder = lodash_1.default.zipObject(lodash_1.default.map(categories, (c, i) => [c.value, i]));
500
510
  // Sort
501
- colorValues = lodash_1.default.sortBy(colorValues, (v) => categoryOrder[v]);
511
+ colorValues = lodash_1.default.sortBy(colorValues, v => categoryOrder[v]);
502
512
  // Exclude excluded ones
503
513
  colorValues = lodash_1.default.difference(colorValues, layer.axes.color.excludedValues || []);
504
514
  // For each color value
505
- lodash_1.default.each(colorValues, (colorValue) => {
515
+ lodash_1.default.each(colorValues, colorValue => {
506
516
  // One series for x values, one for y
507
517
  const seriesX = `${layerIndex}:${colorValue}:x`;
508
518
  const seriesY = `${layerIndex}:${colorValue}:y`;
@@ -614,7 +624,7 @@ class LayeredChartCompiler {
614
624
  }
615
625
  for (var x of xs) {
616
626
  // Find existing row
617
- const existingRow = lodash_1.default.find(flatRows, (r) => r.x === x && r.color === row.color);
627
+ const existingRow = lodash_1.default.find(flatRows, r => r.x === x && r.color === row.color);
618
628
  if (existingRow) {
619
629
  existingRow.y += row.y;
620
630
  }
@@ -651,11 +661,14 @@ class LayeredChartCompiler {
651
661
  return (xValues = lodash_1.default.union(xValues, lodash_1.default.uniq(lodash_1.default.pluck(layerData, "x"))));
652
662
  });
653
663
  // Categories will be in form [{ value, label }]
654
- let categories = this.axisBuilder.getCategories(xAxis, xValues, { locale, onlyValuesPresent: design.layers[0].xAxisOnlyValuesPresent });
664
+ let categories = this.axisBuilder.getCategories(xAxis, xValues, {
665
+ locale,
666
+ onlyValuesPresent: design.layers[0].xAxisOnlyValuesPresent
667
+ });
655
668
  // Get indexed ordering of categories (lookup from value to index) without removing excluded values
656
669
  const categoryOrder = lodash_1.default.zipObject(lodash_1.default.map(categories, (c, i) => [c.value, i]));
657
670
  // Exclude excluded values
658
- categories = lodash_1.default.filter(categories, (category) => !lodash_1.default.includes(xAxis.excludedValues || [], category.value));
671
+ categories = lodash_1.default.filter(categories, category => !lodash_1.default.includes(xAxis.excludedValues || [], category.value));
659
672
  // Limit categories to prevent crashes in C3 (https://github.com/mWater/mwater-visualization/issues/272)
660
673
  if (xType !== "enumset") {
661
674
  // Take last ones to make dates prettier (enough to show all weeks)
@@ -665,7 +678,7 @@ class LayeredChartCompiler {
665
678
  // Create map of category value to index
666
679
  const categoryMap = lodash_1.default.object(lodash_1.default.map(categories, (c, i) => [c.value, i]));
667
680
  // Create common x series
668
- columns.push(["x"].concat(lodash_1.default.map(categories, (category) => this.axisBuilder.formatCategory(xAxis, category))));
681
+ columns.push(["x"].concat(lodash_1.default.map(categories, category => this.axisBuilder.formatCategory(xAxis, category))));
669
682
  // For each layer
670
683
  lodash_1.default.each(design.layers, (layer, layerIndex) => {
671
684
  // Get data of layer
@@ -678,14 +691,14 @@ class LayeredChartCompiler {
678
691
  layerData = this.flattenRowData(layerData);
679
692
  }
680
693
  // Reorder to category order for x-axis
681
- layerData = lodash_1.default.sortBy(layerData, (row) => categoryOrder[row.x]);
694
+ layerData = lodash_1.default.sortBy(layerData, row => categoryOrder[row.x]);
682
695
  // Make rows cumulative
683
696
  if (layer.cumulative) {
684
697
  layerData = this.makeRowsCumulative(layerData);
685
698
  }
686
699
  // Filter out categories that were removed
687
700
  if (xType !== "enumset") {
688
- layerData = lodash_1.default.filter(layerData, (row) => categoryXs[row.x] != null);
701
+ layerData = lodash_1.default.filter(layerData, row => categoryXs[row.x] != null);
689
702
  }
690
703
  // If has color axis
691
704
  if (layer.axes.color) {
@@ -697,11 +710,11 @@ class LayeredChartCompiler {
697
710
  // Get indexed ordering of categories (lookup from value to index) without removing excluded values
698
711
  const colorCategoryOrder = lodash_1.default.zipObject(lodash_1.default.map(colorCategories, (c, i) => [c.value, i]));
699
712
  // Sort
700
- colorValues = lodash_1.default.sortBy(colorValues, (v) => colorCategoryOrder[v]);
713
+ colorValues = lodash_1.default.sortBy(colorValues, v => colorCategoryOrder[v]);
701
714
  // Exclude excluded ones
702
715
  colorValues = lodash_1.default.difference(colorValues, layer.axes.color.excludedValues || []);
703
716
  if (colorValues.length > 0) {
704
- lodash_1.default.each(colorValues, (colorValue) => {
717
+ lodash_1.default.each(colorValues, colorValue => {
705
718
  // One series for y values
706
719
  const series = `${layerIndex}:${colorValue}`;
707
720
  // Get specific color if present
@@ -713,9 +726,9 @@ class LayeredChartCompiler {
713
726
  // Get rows for this series
714
727
  const rows = lodash_1.default.where(layerData, { color: colorValue });
715
728
  // Create empty series
716
- const column = lodash_1.default.map(categories, (c) => null);
729
+ const column = lodash_1.default.map(categories, c => null);
717
730
  // Set rows
718
- lodash_1.default.each(rows, (row) => {
731
+ lodash_1.default.each(rows, row => {
719
732
  // Get index
720
733
  const index = categoryMap[row.x];
721
734
  if (index != null) {
@@ -742,7 +755,7 @@ class LayeredChartCompiler {
742
755
  else {
743
756
  //c3 acts funny when there is a split axis but no data
744
757
  series = `${layerIndex}:dumm`;
745
- column = lodash_1.default.map(categories, (c) => null);
758
+ column = lodash_1.default.map(categories, c => null);
746
759
  columns.push([series].concat(column));
747
760
  types[series] = this.getLayerType(design, layerIndex);
748
761
  names[series] = this.axisBuilder.formatValue(layer.axes.color, null, locale, true);
@@ -754,9 +767,9 @@ class LayeredChartCompiler {
754
767
  // One series for y
755
768
  series = `${layerIndex}`;
756
769
  // Create empty series
757
- column = lodash_1.default.map(categories, (c) => null);
770
+ column = lodash_1.default.map(categories, c => null);
758
771
  // Set rows
759
- lodash_1.default.each(layerData, (row) => {
772
+ lodash_1.default.each(layerData, row => {
760
773
  // Skip if value excluded
761
774
  if (lodash_1.default.includes(layer.axes.x.excludedValues || [], row.x)) {
762
775
  return;
@@ -813,11 +826,11 @@ class LayeredChartCompiler {
813
826
  const defaultStacked = layer.axes.color != null;
814
827
  const stacked = layer.stacked != null ? layer.stacked : defaultStacked;
815
828
  if (stacked) {
816
- groups.push(lodash_1.default.filter(lodash_1.default.keys(names), (series) => series.split(":")[0] === `${layerIndex}`));
829
+ groups.push(lodash_1.default.filter(lodash_1.default.keys(names), series => series.split(":")[0] === `${layerIndex}`));
817
830
  }
818
831
  }
819
832
  // Remove empty groups
820
- groups = lodash_1.default.filter(groups, (g) => g.length > 1);
833
+ groups = lodash_1.default.filter(groups, g => g.length > 1);
821
834
  }
822
835
  // If proportional
823
836
  if (design.proportional) {
@@ -859,6 +872,7 @@ class LayeredChartCompiler {
859
872
  classes,
860
873
  xAxisType: "category",
861
874
  xAxisTickFit: xType !== "date",
875
+ xAxisTickMultiline: design.xAxisTickMultiline,
862
876
  xAxisLabelText: this.compileXAxisLabelText(design, locale),
863
877
  yAxisLabelText: this.compileYAxisLabelText(design, locale),
864
878
  titleText: this.compileTitleText(design, locale),
@@ -1072,14 +1086,14 @@ function cleanString(str) {
1072
1086
  function calculateLinearRegression(ys, xs) {
1073
1087
  // If xs are dates, convert to numbers
1074
1088
  if (lodash_1.default.isString(xs[0])) {
1075
- xs = lodash_1.default.map(xs, (x) => Date.parse(x));
1089
+ xs = lodash_1.default.map(xs, x => Date.parse(x));
1076
1090
  }
1077
1091
  // Remove null ys
1078
1092
  const nonNullxs = lodash_1.default.filter(xs, (x, index) => ys[index] !== null);
1079
1093
  const nonNullys = lodash_1.default.filter(ys, (y, index) => ys[index] !== null);
1080
1094
  const n = nonNullys.length;
1081
1095
  const sumXY = lodash_1.default.sum(lodash_1.default.map(nonNullxs, (x, i) => x * nonNullys[i]));
1082
- const sumXX = lodash_1.default.sum(lodash_1.default.map(nonNullxs, (x) => x * x));
1096
+ const sumXX = lodash_1.default.sum(lodash_1.default.map(nonNullxs, x => x * x));
1083
1097
  const sumX = lodash_1.default.sum(nonNullxs);
1084
1098
  const sumY = lodash_1.default.sum(nonNullys);
1085
1099
  // Calculate denominator
@@ -1088,5 +1102,5 @@ function calculateLinearRegression(ys, xs) {
1088
1102
  const slope = (n * sumXY - sumX * sumY) / den;
1089
1103
  // Calculate intercept
1090
1104
  const intercept = (sumY * sumXX - sumX * sumXY) / den;
1091
- return lodash_1.default.map(xs, (x) => x * slope + intercept);
1105
+ return lodash_1.default.map(xs, x => x * slope + intercept);
1092
1106
  }
@@ -38,6 +38,10 @@ export interface LayeredChartDesign {
38
38
  yMin?: number;
39
39
  /** true to show popout lines for small values */
40
40
  popoutSmallValues?: boolean;
41
+ /** true to hide the legend */
42
+ hideLegend?: boolean;
43
+ /** Whether to allow multiline x axis tick labels (default true) */
44
+ xAxisTickMultiline?: boolean;
41
45
  }
42
46
  export interface LayeredChartDesignLayer {
43
47
  /** bar/line/spline/scatter/area/pie/donut (overrides main one) */
@@ -16,6 +16,7 @@ export default class LayeredChartDesignerComponent extends React.Component<Layer
16
16
  updateDesign(changes: any): void;
17
17
  handleTypeChange: (type: any) => void;
18
18
  handleTransposeChange: (value: any) => void;
19
+ handleHideLegendChange: (value: any) => void;
19
20
  handleStackedChange: (value: any) => void;
20
21
  handleProportionalChange: (value: any) => void;
21
22
  handleLabelsChange: (value: any) => void;
@@ -32,7 +33,9 @@ export default class LayeredChartDesignerComponent extends React.Component<Layer
32
33
  handleToggleYAxisLabelClick: (ev: any) => void;
33
34
  handleYMinChange: (yMin: any) => void;
34
35
  handleYMaxChange: (yMax: any) => void;
36
+ handleXAxisTickMultilineChange: (value: boolean) => void;
35
37
  renderLabels(): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement> | undefined;
38
+ renderChartOptions(): React.JSX.Element;
36
39
  renderType(): React.CElement<uiComponents.SectionComponentProps, uiComponents.SectionComponent>;
37
40
  renderLayer: (index: any) => React.DetailedReactHTMLElement<{
38
41
  style: {
@@ -52,6 +52,9 @@ class LayeredChartDesignerComponent extends react_1.default.Component {
52
52
  handleTransposeChange = (value) => {
53
53
  return this.updateDesign({ transpose: value });
54
54
  };
55
+ handleHideLegendChange = (value) => {
56
+ return this.updateDesign({ hideLegend: value });
57
+ };
55
58
  handleStackedChange = (value) => {
56
59
  return this.updateDesign({ stacked: value });
57
60
  };
@@ -106,6 +109,9 @@ class LayeredChartDesignerComponent extends react_1.default.Component {
106
109
  handleYMaxChange = (yMax) => {
107
110
  return this.updateDesign({ yMax });
108
111
  };
112
+ handleXAxisTickMultilineChange = (value) => {
113
+ this.updateDesign({ xAxisTickMultiline: value });
114
+ };
109
115
  renderLabels() {
110
116
  if (!this.props.design.type) {
111
117
  return;
@@ -133,6 +139,11 @@ class LayeredChartDesignerComponent extends react_1.default.Component {
133
139
  : undefined)
134
140
  : undefined);
135
141
  }
142
+ renderChartOptions() {
143
+ return (react_1.default.createElement("div", null,
144
+ react_1.default.createElement(bootstrap_1.Checkbox, { key: "hideLegend", value: this.props.design.hideLegend, onChange: this.handleHideLegendChange }, "Hide legend"),
145
+ react_1.default.createElement(bootstrap_1.Checkbox, { key: "xAxisTickMultiline", value: this.props.design.xAxisTickMultiline ?? true, onChange: this.handleXAxisTickMultilineChange }, "Multiline X-Axis Labels")));
146
+ }
136
147
  renderType() {
137
148
  const chartTypes = [
138
149
  { id: "bar", name: "Bar", desc: "Best for most charts" },
@@ -150,7 +161,7 @@ class LayeredChartDesignerComponent extends react_1.default.Component {
150
161
  editor: (onClose) => {
151
162
  return R(uiComponents.OptionListComponent, {
152
163
  hint: "Select a Chart Type",
153
- items: lodash_1.default.map(chartTypes, (ct) => ({
164
+ items: lodash_1.default.map(chartTypes, ct => ({
154
165
  name: ct.name,
155
166
  desc: ct.desc,
156
167
  onClick: () => {
@@ -208,7 +219,9 @@ class LayeredChartDesignerComponent extends react_1.default.Component {
208
219
  { value: "natural", label: "Natural Order" }
209
220
  ], inline: true })
210
221
  ]
211
- : undefined, (design.labels && design.type === "bar" && !design.transpose) ? R('div', null, react_1.default.createElement(bootstrap_1.Checkbox, { inline: true, key: "labels", value: design.popoutSmallValues || false, onChange: this.handleLabelsPopoutChange }, "Show Popout labels for small values")) : undefined);
222
+ : undefined, design.labels && design.type === "bar" && !design.transpose
223
+ ? R("div", null, react_1.default.createElement(bootstrap_1.Checkbox, { inline: true, key: "labels", value: design.popoutSmallValues || false, onChange: this.handleLabelsPopoutChange }, "Show Popout labels for small values"))
224
+ : undefined);
212
225
  }
213
226
  renderThresholds() {
214
227
  // Doesn't apply to polar
@@ -256,6 +269,11 @@ class LayeredChartDesignerComponent extends react_1.default.Component {
256
269
  elem: R("div", null, R("br"), this.renderLabels())
257
270
  });
258
271
  }
272
+ tabs.push({
273
+ id: "options",
274
+ label: "Options",
275
+ elem: R("div", null, R("br"), this.renderChartOptions())
276
+ });
259
277
  return R(TabbedComponent_1.default, {
260
278
  initialTabId: "design",
261
279
  tabs
@@ -298,7 +316,7 @@ class ThresholdComponent extends react_1.default.Component {
298
316
  style: { display: "inline-block" },
299
317
  size: "sm",
300
318
  value: this.props.threshold.value,
301
- onChange: (v) => this.props.onThresholdChange(lodash_1.default.extend({}, this.props.threshold, { value: v }))
319
+ onChange: v => this.props.onThresholdChange(lodash_1.default.extend({}, this.props.threshold, { value: v }))
302
320
  })), " ", R(LabeledInlineComponent, { key: "label", label: "Label:" }, R(ui.TextInput, {
303
321
  style: { display: "inline-block", width: "8em" },
304
322
  size: "sm",
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { DataSource, Schema } from "@mwater/expressions";
3
3
  import * as uiComponents from "../../../UIComponents";
4
- import * as ui from "@mwater/react-library/lib/bootstrap";
5
4
  export interface LayeredChartLayerDesignerComponentProps {
6
5
  design: any;
7
6
  schema: Schema;
@@ -47,7 +46,7 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
47
46
  }, HTMLElement> | null;
48
47
  renderTable(): React.CElement<uiComponents.SectionComponentProps, uiComponents.SectionComponent>;
49
48
  handlexAxisOnlyValuesPresentChange: (xAxisOnlyValuesPresent: boolean) => void;
50
- renderXAxis(): (React.CElement<ui.CheckboxProps, ui.Checkbox> | React.CElement<uiComponents.SectionComponentProps, uiComponents.SectionComponent> | undefined)[] | undefined;
49
+ renderXAxis(): (React.JSX.Element | null)[] | undefined;
51
50
  renderColorAxis(): React.DetailedReactHTMLElement<{
52
51
  className: string;
53
52
  }, HTMLElement> | undefined;
@@ -214,7 +214,8 @@ class LayeredChartLayerDesignerComponent extends react_1.default.Component {
214
214
  categoricalX ? R(ui.Checkbox, {
215
215
  value: layer.xAxisOnlyValuesPresent,
216
216
  onChange: this.handlexAxisOnlyValuesPresentChange
217
- }, "Only show values actually present", R(PopoverHelpComponent_1.default, { placement: 'bottom' }, "Limits values to those that are present in the data, as opposed to all choices or all dates within range")) : undefined
217
+ }, "Only show values actually present ", R(PopoverHelpComponent_1.default, { placement: 'bottom' }, "Limits values to those that are present in the data, as opposed to all choices or all dates within range")) : null,
218
+ react_1.default.createElement("br", null)
218
219
  ];
219
220
  }
220
221
  renderColorAxis() {
@@ -1,4 +1,3 @@
1
- import PropTypes from "prop-types";
2
1
  import React from "react";
3
2
  import { DataSource, Schema } from "@mwater/expressions";
4
3
  import { LayeredChartDesign } from "./LayeredChartDesign";
@@ -21,9 +20,7 @@ interface LayeredChartViewComponentState {
21
20
  footerHeight: any;
22
21
  }
23
22
  export default class LayeredChartViewComponent extends React.Component<LayeredChartViewComponentProps, LayeredChartViewComponentState> {
24
- static contextTypes: {
25
- locale: PropTypes.Requireable<string>;
26
- };
23
+ static contextType: React.Context<string>;
27
24
  header: HTMLElement | null;
28
25
  footer: HTMLElement | null;
29
26
  constructor(props: any);
@@ -26,7 +26,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const prop_types_1 = __importDefault(require("prop-types"));
30
29
  const lodash_1 = __importDefault(require("lodash"));
31
30
  const react_1 = __importDefault(require("react"));
32
31
  const R = react_1.default.createElement;
@@ -34,9 +33,11 @@ const LayeredChartCompiler_1 = __importDefault(require("./LayeredChartCompiler")
34
33
  const TextComponent_1 = __importDefault(require("../../text/TextComponent"));
35
34
  const d3 = __importStar(require("d3"));
36
35
  const billboard_js_1 = __importDefault(require("billboard.js"));
36
+ const contexts_1 = require("@mwater/expressions-ui/lib/contexts");
37
+ const TextWidgetDesign_1 = require("../../text/TextWidgetDesign");
37
38
  // Displays a layered chart
38
39
  class LayeredChartViewComponent extends react_1.default.Component {
39
- static contextTypes = { locale: prop_types_1.default.string };
40
+ static contextType = contexts_1.LocaleContext;
40
41
  header;
41
42
  footer;
42
43
  constructor(props) {
@@ -54,18 +55,24 @@ class LayeredChartViewComponent extends react_1.default.Component {
54
55
  if (this.props.design != prevProps.design ||
55
56
  this.props.height != prevProps.height ||
56
57
  this.props.width != prevProps.width) {
57
- console.log(`componentDidUpdate: ${this.props.height} vs ${prevProps.height} and ${this.props.width} vs ${prevProps.width}`);
58
+ // console.log(
59
+ // `componentDidUpdate: ${this.props.height} vs ${prevProps.height} and ${this.props.width} vs ${prevProps.width}`
60
+ // )
58
61
  this.updateHeights();
59
62
  }
60
63
  }
61
64
  updateHeights() {
62
65
  // Calculate header and footer heights
63
66
  if (this.header && this.state.headerHeight !== this.header.offsetHeight) {
64
- console.log(`headerHeight: ${this.state.headerHeight} vs ${this.header.offsetHeight} => ${this.header.offsetHeight}`);
67
+ // console.log(
68
+ // `headerHeight: ${this.state.headerHeight} vs ${this.header.offsetHeight} => ${this.header.offsetHeight}`
69
+ // )
65
70
  this.setState({ headerHeight: this.header.offsetHeight });
66
71
  }
67
72
  if (this.footer && this.state.footerHeight !== this.footer.offsetHeight) {
68
- console.log(`footerHeight: ${this.state.footerHeight} vs ${this.footer.offsetHeight} => ${this.footer.offsetHeight}`);
73
+ // console.log(
74
+ // `footerHeight: ${this.state.footerHeight} vs ${this.footer.offsetHeight} => ${this.footer.offsetHeight}`
75
+ // )
69
76
  this.setState({ footerHeight: this.footer.offsetHeight });
70
77
  }
71
78
  }
@@ -77,7 +84,7 @@ class LayeredChartViewComponent extends react_1.default.Component {
77
84
  };
78
85
  renderHeader() {
79
86
  return R("div", {
80
- ref: (c) => {
87
+ ref: c => {
81
88
  return (this.header = c);
82
89
  }
83
90
  }, R(TextComponent_1.default, {
@@ -91,10 +98,12 @@ class LayeredChartViewComponent extends react_1.default.Component {
91
98
  }
92
99
  renderFooter() {
93
100
  return R("div", {
94
- ref: (c) => {
101
+ ref: c => {
95
102
  return (this.footer = c);
96
103
  }
97
- }, R(TextComponent_1.default, {
104
+ },
105
+ // Don't render footer if it's empty and no onDesignChange
106
+ (0, TextWidgetDesign_1.isEmptyTextWidgetDesign)(this.props.design.footer) && this.props.onDesignChange == null ? null : R(TextComponent_1.default, {
98
107
  design: this.props.design.footer,
99
108
  onDesignChange: this.props.onDesignChange ? this.handleFooterChange : undefined,
100
109
  schema: this.props.schema,
@@ -114,7 +123,7 @@ class LayeredChartViewComponent extends react_1.default.Component {
114
123
  height: this.props.height - this.state.headerHeight - this.state.footerHeight,
115
124
  scope: this.props.scope,
116
125
  onScopeChange: this.props.onScopeChange,
117
- locale: this.context.locale
126
+ locale: this.context
118
127
  })
119
128
  : undefined, this.renderFooter());
120
129
  }
@@ -156,9 +165,32 @@ class C3ChartComponent extends react_1.default.Component {
156
165
  this.chart = billboard_js_1.default.generate(chartOptions);
157
166
  }
158
167
  catch (error) {
159
- throw (error);
168
+ throw error;
169
+ }
170
+ const el = this.chartDiv;
171
+ // https://github.com/mWater/monorepo/issues/8
172
+ if (props.design.type === "bar" && props.design.stacked && props.design.transpose) {
173
+ d3.select(el)
174
+ .selectAll(".bb-chart-text .bb-text")
175
+ .each(function (t, i) {
176
+ const bar = d3
177
+ .select(el)
178
+ .selectAll(".bb-chart-bar .bb-bar")
179
+ .filter((d) => {
180
+ return d.id === t.id && t.index === d.index;
181
+ })
182
+ .nodes()[0];
183
+ const text = d3.select(this);
184
+ const barBox = bar.getBBox();
185
+ const textBox = text.nodes()[0].getBBox();
186
+ if (barBox.width > textBox.width + 10) {
187
+ text.attr("x", barBox.x + (barBox.width - textBox.width) / 2);
188
+ }
189
+ else {
190
+ text.style("opacity", 0);
191
+ }
192
+ });
160
193
  }
161
- console.log(this.chartDiv);
162
194
  // Remove listener for window focus (https://github.com/c3js/c3/issues/2742)
163
195
  window.removeEventListener("focus", this.chart.internal.windowFocusHandler);
164
196
  this.chart.internal.windowFocusHandler = () => { };
@@ -231,62 +263,81 @@ class C3ChartComponent extends react_1.default.Component {
231
263
  if (box.height < 12) {
232
264
  d3.select(el)
233
265
  .selectAll(".bb-chart-text .bb-text")
234
- .filter(function (p, j) { return i === j; })
266
+ .filter(function (p, j) {
267
+ return i === j;
268
+ })
235
269
  .each(function (_p) {
236
270
  smalls.push({
237
271
  origin_x: box.x,
238
272
  origin_y: box.y,
239
273
  series: map.get(p.id),
240
- textY: box.y - (12 * map.get(p.id)) - 10,
241
- textX: box.x + 25,
274
+ textY: box.y - 12 * map.get(p.id) - 10,
275
+ textX: box.x + 25
242
276
  });
243
277
  d3.select(this).node().classList.add("needs_adjustment");
244
278
  })
245
- .attr('data-boxX', box.x)
246
- .attr('y', function () {
247
- return box.y - (12 * map.get(p.id)) - 10;
279
+ .attr("data-boxX", box.x)
280
+ .attr("y", function () {
281
+ return box.y - 12 * map.get(p.id) - 10;
248
282
  // return Number(d3.select(this).attr('y')) - 7
249
283
  });
250
284
  }
251
285
  });
252
286
  if (smalls.length > 0) {
253
287
  const sliceWidth = 4;
254
- const seriesToBeDrawn = lodash_1.default.uniq(smalls.map((s) => s.series)).length;
288
+ const seriesToBeDrawn = lodash_1.default.uniq(smalls.map(s => s.series)).length;
255
289
  d3.select(el)
256
290
  .selectAll(".needs_adjustment")
257
- .attr('x', function () {
291
+ .attr("x", function () {
258
292
  const self = d3.select(this);
259
- return Number(self.attr('data-boxX')) + ((seriesToBeDrawn) * sliceWidth) + 10;
293
+ return Number(self.attr("data-boxX")) + seriesToBeDrawn * sliceWidth + 10;
260
294
  })
261
- .attr('text-anchor', 'left');
262
- const hackGroup = d3.select(el)
295
+ .attr("text-anchor", "left");
296
+ const hackGroup = d3
297
+ .select(el)
263
298
  .selectAll(".bb-chart")
264
299
  .selectAll(".popout_labels")
265
300
  .data(["1"])
266
301
  .enter()
267
- .append('g')
268
- .attr('class', 'popout_labels');
302
+ .append("g")
303
+ .attr("class", "popout_labels");
269
304
  hackGroup
270
- .selectAll('line')
305
+ .selectAll("line")
271
306
  .data(smalls)
272
307
  .enter()
273
- .append('line')
274
- .attr('x1', function (d) { return stacked ? d.origin_x + (sliceWidth * (seriesToBeDrawn - d.series)) : d.origin_x + 5; })
275
- .attr('y1', function (d) { return d.origin_y; })
276
- .attr('x2', function (d) { return stacked ? d.origin_x + (sliceWidth * (seriesToBeDrawn - d.series)) : d.origin_x + 5; })
277
- .attr('y2', function (d) { return d.textY + 3; })
278
- .attr('shape-rendering', 'crispEdges')
308
+ .append("line")
309
+ .attr("x1", function (d) {
310
+ return stacked ? d.origin_x + sliceWidth * (seriesToBeDrawn - d.series) : d.origin_x + 5;
311
+ })
312
+ .attr("y1", function (d) {
313
+ return d.origin_y;
314
+ })
315
+ .attr("x2", function (d) {
316
+ return stacked ? d.origin_x + sliceWidth * (seriesToBeDrawn - d.series) : d.origin_x + 5;
317
+ })
318
+ .attr("y2", function (d) {
319
+ return d.textY + 3;
320
+ })
321
+ .attr("shape-rendering", "crispEdges")
279
322
  .style("stroke", "black")
280
323
  .style("stroke-width", 0.5)
281
324
  .exit()
282
325
  .data(smalls)
283
326
  .enter()
284
- .append('line')
285
- .attr('x1', function (d) { return stacked ? d.origin_x + (sliceWidth * (seriesToBeDrawn - d.series)) : d.origin_x + 5; })
286
- .attr('y1', function (d) { return d.textY + 3; })
287
- .attr('x2', function (d) { return d.origin_x + ((seriesToBeDrawn) * sliceWidth) + 8; })
288
- .attr('y2', function (d) { return d.textY; })
289
- .attr('shape-rendering', 'crispEdges')
327
+ .append("line")
328
+ .attr("x1", function (d) {
329
+ return stacked ? d.origin_x + sliceWidth * (seriesToBeDrawn - d.series) : d.origin_x + 5;
330
+ })
331
+ .attr("y1", function (d) {
332
+ return d.textY + 3;
333
+ })
334
+ .attr("x2", function (d) {
335
+ return d.origin_x + seriesToBeDrawn * sliceWidth + 8;
336
+ })
337
+ .attr("y2", function (d) {
338
+ return d.textY;
339
+ })
340
+ .attr("shape-rendering", "crispEdges")
290
341
  .style("stroke", "black")
291
342
  .style("stroke-width", 0.5)
292
343
  .exit();
@@ -398,7 +449,7 @@ class C3ChartComponent extends react_1.default.Component {
398
449
  // css += ".c3-chart-arc text { font-size: #{scale * 13}px; }\n"
399
450
  // css += ".c3-title { font-size: #{scale * 14}px; }\n"
400
451
  return R("div", {
401
- ref: (c) => {
452
+ ref: c => {
402
453
  return (this.chartDiv = c);
403
454
  }
404
455
  });