@vizzly/dashboard 0.14.4-dev-c25428d42db56a9b153be528febab668cec55785 → 0.14.4-dev-b4a15896ec5f2fffd81b6585e16fac81b314a1f1

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.
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import { BarChartRepresentation } from '../../../../../shared-logic/src/BarChartV2/types';
3
+ import { ChartTheme } from '../../../types';
4
+ export declare type BarChartProps = {
5
+ width: number;
6
+ height: number;
7
+ theme?: ChartTheme;
8
+ chart: BarChartRepresentation;
9
+ options: {
10
+ showRoundedTotal: boolean;
11
+ showLegend: boolean;
12
+ removeStroke: boolean;
13
+ axis: {
14
+ showXAxisLabels: boolean;
15
+ showYAxisLabels: boolean;
16
+ };
17
+ };
18
+ };
19
+ export declare const BarChart: ({ chart, width, height, options, theme }: BarChartProps) => JSX.Element;
@@ -0,0 +1 @@
1
+ export { BarChart } from './BarChart';
@@ -0,0 +1,7 @@
1
+ import { ConditionalFormattingRule, LegendItem } from '../../../../../shared-logic/src/BarChartV2/types';
2
+ export declare function getBarFill(bars: LegendItem[], conditionalFormattingRules: ConditionalFormattingRule[], bar: {
3
+ bar: {
4
+ data: any;
5
+ };
6
+ key: string;
7
+ }): string | undefined;
@@ -1 +1,2 @@
1
1
  export { LineChart as LineChartV2 } from './components/LineChart';
2
+ export { BarChart as BarChartV2 } from './components/BarChart';
@@ -0,0 +1,9 @@
1
+ import { Tick } from '../../../../shared-logic/src/ChartsV2/types';
2
+ export declare const buildMargin: (yTicks: Tick<number>[], showYAxisLabels: boolean, hasYAxisTitle: boolean, hasXAxisTitle: boolean) => {
3
+ top: number;
4
+ right: number;
5
+ bottom: number;
6
+ left: number;
7
+ bottomTitleOffset: number;
8
+ leftTitleOffset: number;
9
+ };
@@ -2,6 +2,7 @@
2
2
  import { ScalePoint, ScaleLinear, ScaleTime } from '@visx/vendor/d3-scale';
3
3
  import { DataItem } from '../../../../shared-logic/src/LineChartV2/types';
4
4
  import { DataType } from '../../../../shared-logic/src/Field/types';
5
+ import { ChartType } from '../../Legend/types';
5
6
  declare type TooltipData = {
6
7
  [keyId: string]: DataItem;
7
8
  };
@@ -20,11 +21,12 @@ interface getTooltipDataArgs {
20
21
  xScaleDataType: DataType;
21
22
  xScale: ScaleTime<number, number> | ScaleLinear<number, number> | ScalePoint<string>;
22
23
  xOrdering: 'asc' | 'desc' | null;
24
+ chartType: ChartType;
23
25
  }
24
26
  interface TooltipDataReturn {
25
27
  tooltipLeft: number;
26
28
  tooltipTop: number;
27
29
  tooltipData: TooltipData | null;
28
30
  }
29
- export declare const getTooltipData: ({ data, event, margin, xScaleKey, xScaleDataType, xScale, xOrdering, }: getTooltipDataArgs) => TooltipDataReturn | undefined;
31
+ export declare const getTooltipData: ({ data, event, margin, xScaleKey, xScaleDataType, xScale, xOrdering, chartType, }: getTooltipDataArgs) => TooltipDataReturn | undefined;
30
32
  export {};
@@ -9961,169 +9961,6 @@ var to100PercentResultSet = function to100PercentResultSet(resultSet) {
9961
9961
  });
9962
9962
  };
9963
9963
 
9964
- var DEFAULT_ROW_HEIGHT = 350;
9965
- var HEADER_ROW_HEIGHT = 52;
9966
- var linearScale = function linearScale(colors, colorCount) {
9967
- return chroma.scale(colors).colors(colorCount);
9968
- };
9969
- var themeToColorScale = function themeToColorScale(colors, colorCount) {
9970
- var _colors$length;
9971
- if ((colorCount != null ? colorCount : 0) <= ((_colors$length = colors == null ? void 0 : colors.length) != null ? _colors$length : 0)) {
9972
- return colors;
9973
- }
9974
- return shuffle(linearScale(colors, colorCount));
9975
- };
9976
- var vizzlyDefaultTheme = {
9977
- colors: ['#feae4a', '#5fbaff', '#e15e9d'],
9978
- detail: 'minimal',
9979
- fontFamily: 'Inter, sans-serif',
9980
- rowLimit: 6,
9981
- fontSize: '0.65rem'
9982
- };
9983
- var darkerColor = function darkerColor(color, darkenBy, opacity) {
9984
- var newColor = chroma(color).darken(darkenBy);
9985
- if (opacity) newColor = setOpacity(newColor, opacity);
9986
- return newColor.hex();
9987
- };
9988
- var darkenListOfColors = function darkenListOfColors(colors, darkenBy) {
9989
- if (darkenBy === void 0) {
9990
- darkenBy = 1;
9991
- }
9992
- return [].concat(colors).map(function (color) {
9993
- return darkerColor(color, darkenBy);
9994
- });
9995
- };
9996
- var setOpacity = function setOpacity(color, opacity) {
9997
- return chroma(color).alpha(opacity);
9998
- };
9999
- var highestContrast = function highestContrast(baseColor, colorOptions) {
10000
- return _.maxBy(colorOptions, function (potentialTextColour) {
10001
- return chroma.contrast(potentialTextColour, baseColor);
10002
- }) || baseColor;
10003
- };
10004
-
10005
- // Typically anything over 4.5 is high enough contrast.
10006
- var pickBestTextColor = function pickBestTextColor(backgroundColour, possibleTextColours) {
10007
- return highestContrast(backgroundColour, possibleTextColours);
10008
- };
10009
-
10010
- // ------------------------------------------------------------------------------------
10011
- // ------------------------------------------------------------------------------------
10012
- // ------------------------------------------------------------------------------------
10013
- // ------------------------------------------------------------------------------------
10014
- // https://stackoverflow.com/questions/16801687/javascript-random-ordering-with-seed
10015
-
10016
- var random = function random(seed) {
10017
- var x = Math.sin(seed++) * 10000;
10018
- return x - Math.floor(x);
10019
- };
10020
- var DEFAULT_RANDOM_SEED = 5;
10021
- var shuffle = function shuffle(array, seed) {
10022
- if (seed === void 0) {
10023
- seed = DEFAULT_RANDOM_SEED;
10024
- }
10025
- var m = array.length,
10026
- t,
10027
- i;
10028
-
10029
- // While there remain elements to shuffle…
10030
- while (m) {
10031
- // Pick a remaining element…
10032
- i = Math.floor(random(seed) * m--);
10033
-
10034
- // And swap it with the current element.
10035
- t = array[m];
10036
- array[m] = array[i];
10037
- array[i] = t;
10038
- ++seed;
10039
- }
10040
- return array;
10041
- };
10042
- // ------------------------------------------------------------------------------------
10043
- // ------------------------------------------------------------------------------------
10044
- // ------------------------------------------------------------------------------------
10045
- // ------------------------------------------------------------------------------------
10046
-
10047
- function getFormattedByRule(_ref) {
10048
- var type = _ref.type,
10049
- value = _ref.value;
10050
- var fontColor = pickBestTextColor(value != null ? value : '', ['white', 'black']);
10051
- switch (type) {
10052
- case 'fontColor':
10053
- {
10054
- return {
10055
- color: value
10056
- };
10057
- }
10058
- case 'backgroundColor':
10059
- {
10060
- return {
10061
- backgroundColor: value,
10062
- color: fontColor
10063
- };
10064
- }
10065
- }
10066
- return {};
10067
- }
10068
- var unsupportedNullComparisons = ['contains_substring', 'does_not_contain_substring', 'ends_with', 'starts_with', '<', '<=', '>', '>='];
10069
- var compare = function compare(filter, recordValue) {
10070
- if (recordValue == null && unsupportedNullComparisons.includes(filter.op)) return false;
10071
- switch (filter.op) {
10072
- case 'starts_with':
10073
- return ("" + recordValue).startsWith(filter.value);
10074
- case 'ends_with':
10075
- return ("" + recordValue).endsWith(filter.value);
10076
- case 'is_one_of':
10077
- return filter.value.includes(recordValue);
10078
- case 'is_not_one_of':
10079
- return !filter.value.includes(recordValue);
10080
- case 'contains_substring':
10081
- return ("" + recordValue).includes(filter.value);
10082
- case 'does_not_contain_substring':
10083
- return !("" + recordValue).includes(filter.value);
10084
- case '<':
10085
- return recordValue < filter.value;
10086
- case '>':
10087
- return recordValue > filter.value;
10088
- case '=':
10089
- return recordValue == filter.value;
10090
- case '!=':
10091
- return recordValue != filter.value;
10092
- case '>=':
10093
- return recordValue >= filter.value;
10094
- case '<=':
10095
- return recordValue <= filter.value;
10096
- case 'array_contains':
10097
- // For some reason a datumKey being passed as the recordValue in certain situations here? // isDatumKey but don't implement yet
10098
- if (!_.isArray(recordValue)) return false;
10099
- return recordValue.some(function (v) {
10100
- return filter.value.includes(v);
10101
- });
10102
- case 'array_does_not_contain':
10103
- // For some reason a datumKey being passed as the recordValue in certain situations here?
10104
- if (!_.isArray(recordValue)) return false;
10105
- return !recordValue.some(function (v) {
10106
- return filter.value.includes(v);
10107
- });
10108
- case 'array_contains_any_of':
10109
- if (!_.isArray(recordValue)) return false;
10110
- return recordValue.some(function (v) {
10111
- return filter.value.includes(v);
10112
- });
10113
- case 'array_contains_all_of':
10114
- if (!_.isArray(recordValue)) return false;
10115
- // write a function to check if all elements in filter.value are in recordValue
10116
- return recordValue.every(function (v) {
10117
- return filter.value.includes(v);
10118
- });
10119
- }
10120
- console.log('Unsupported comparison op.', filter.op);
10121
- throw 'Unsupported comparison op.';
10122
- };
10123
- var conditionIsMet = function conditionIsMet(filter, value) {
10124
- return compare(filter, value);
10125
- };
10126
-
10127
9964
  var defaultNumberFormatOptions = function defaultNumberFormatOptions(textOverride) {
10128
9965
  var noValue = textOverride('number_format_option.noValueReplacement', 'No value');
10129
9966
  var formattingError = textOverride('number_format_option.formattingError', 'Formatting error');
@@ -10480,6 +10317,65 @@ var acceptedTimeDimensions = function acceptedTimeDimensions(timeDimension) {
10480
10317
  return ['week', 'month', 'quarter', 'year'].includes(timeDimension.truncate);
10481
10318
  };
10482
10319
 
10320
+ var unsupportedNullComparisons = ['contains_substring', 'does_not_contain_substring', 'ends_with', 'starts_with', '<', '<=', '>', '>='];
10321
+ var compare = function compare(filter, recordValue) {
10322
+ if (recordValue == null && unsupportedNullComparisons.includes(filter.op)) return false;
10323
+ switch (filter.op) {
10324
+ case 'starts_with':
10325
+ return ("" + recordValue).startsWith(filter.value);
10326
+ case 'ends_with':
10327
+ return ("" + recordValue).endsWith(filter.value);
10328
+ case 'is_one_of':
10329
+ return filter.value.includes(recordValue);
10330
+ case 'is_not_one_of':
10331
+ return !filter.value.includes(recordValue);
10332
+ case 'contains_substring':
10333
+ return ("" + recordValue).includes(filter.value);
10334
+ case 'does_not_contain_substring':
10335
+ return !("" + recordValue).includes(filter.value);
10336
+ case '<':
10337
+ return recordValue < filter.value;
10338
+ case '>':
10339
+ return recordValue > filter.value;
10340
+ case '=':
10341
+ return recordValue == filter.value;
10342
+ case '!=':
10343
+ return recordValue != filter.value;
10344
+ case '>=':
10345
+ return recordValue >= filter.value;
10346
+ case '<=':
10347
+ return recordValue <= filter.value;
10348
+ case 'array_contains':
10349
+ // For some reason a datumKey being passed as the recordValue in certain situations here? // isDatumKey but don't implement yet
10350
+ if (!_.isArray(recordValue)) return false;
10351
+ return recordValue.some(function (v) {
10352
+ return filter.value.includes(v);
10353
+ });
10354
+ case 'array_does_not_contain':
10355
+ // For some reason a datumKey being passed as the recordValue in certain situations here?
10356
+ if (!_.isArray(recordValue)) return false;
10357
+ return !recordValue.some(function (v) {
10358
+ return filter.value.includes(v);
10359
+ });
10360
+ case 'array_contains_any_of':
10361
+ if (!_.isArray(recordValue)) return false;
10362
+ return recordValue.some(function (v) {
10363
+ return filter.value.includes(v);
10364
+ });
10365
+ case 'array_contains_all_of':
10366
+ if (!_.isArray(recordValue)) return false;
10367
+ // write a function to check if all elements in filter.value are in recordValue
10368
+ return recordValue.every(function (v) {
10369
+ return filter.value.includes(v);
10370
+ });
10371
+ }
10372
+ console.log('Unsupported comparison op.', filter.op);
10373
+ throw 'Unsupported comparison op.';
10374
+ };
10375
+ var conditionIsMet = function conditionIsMet(filter, value) {
10376
+ return compare(filter, value);
10377
+ };
10378
+
10483
10379
  var mergeProps = function mergeProps(explicitProps, remoteProps, defaultProps) {
10484
10380
  var devDefined = _.merge({}, remoteProps, explicitProps);
10485
10381
  return _.merge({}, defaultProps, devDefined);
@@ -11183,6 +11079,89 @@ var TableLibraryWrapper = function TableLibraryWrapper(props) {
11183
11079
  });
11184
11080
  };
11185
11081
 
11082
+ var DEFAULT_ROW_HEIGHT = 350;
11083
+ var HEADER_ROW_HEIGHT = 52;
11084
+ var linearScale = function linearScale(colors, colorCount) {
11085
+ return chroma.scale(colors).colors(colorCount);
11086
+ };
11087
+ var themeToColorScale = function themeToColorScale(colors, colorCount) {
11088
+ var _colors$length;
11089
+ if ((colorCount != null ? colorCount : 0) <= ((_colors$length = colors == null ? void 0 : colors.length) != null ? _colors$length : 0)) {
11090
+ return colors;
11091
+ }
11092
+ return shuffle(linearScale(colors, colorCount));
11093
+ };
11094
+ var vizzlyDefaultTheme = {
11095
+ colors: ['#feae4a', '#5fbaff', '#e15e9d'],
11096
+ detail: 'minimal',
11097
+ fontFamily: 'Inter, sans-serif',
11098
+ rowLimit: 6,
11099
+ fontSize: '0.65rem'
11100
+ };
11101
+ var darkerColor = function darkerColor(color, darkenBy, opacity) {
11102
+ var newColor = chroma(color).darken(darkenBy);
11103
+ if (opacity) newColor = setOpacity(newColor, opacity);
11104
+ return newColor.hex();
11105
+ };
11106
+ var darkenListOfColors = function darkenListOfColors(colors, darkenBy) {
11107
+ if (darkenBy === void 0) {
11108
+ darkenBy = 1;
11109
+ }
11110
+ return [].concat(colors).map(function (color) {
11111
+ return darkerColor(color, darkenBy);
11112
+ });
11113
+ };
11114
+ var setOpacity = function setOpacity(color, opacity) {
11115
+ return chroma(color).alpha(opacity);
11116
+ };
11117
+ var highestContrast = function highestContrast(baseColor, colorOptions) {
11118
+ return _.maxBy(colorOptions, function (potentialTextColour) {
11119
+ return chroma.contrast(potentialTextColour, baseColor);
11120
+ }) || baseColor;
11121
+ };
11122
+
11123
+ // Typically anything over 4.5 is high enough contrast.
11124
+ var pickBestTextColor = function pickBestTextColor(backgroundColour, possibleTextColours) {
11125
+ return highestContrast(backgroundColour, possibleTextColours);
11126
+ };
11127
+
11128
+ // ------------------------------------------------------------------------------------
11129
+ // ------------------------------------------------------------------------------------
11130
+ // ------------------------------------------------------------------------------------
11131
+ // ------------------------------------------------------------------------------------
11132
+ // https://stackoverflow.com/questions/16801687/javascript-random-ordering-with-seed
11133
+
11134
+ var random = function random(seed) {
11135
+ var x = Math.sin(seed++) * 10000;
11136
+ return x - Math.floor(x);
11137
+ };
11138
+ var DEFAULT_RANDOM_SEED = 5;
11139
+ var shuffle = function shuffle(array, seed) {
11140
+ if (seed === void 0) {
11141
+ seed = DEFAULT_RANDOM_SEED;
11142
+ }
11143
+ var m = array.length,
11144
+ t,
11145
+ i;
11146
+
11147
+ // While there remain elements to shuffle…
11148
+ while (m) {
11149
+ // Pick a remaining element…
11150
+ i = Math.floor(random(seed) * m--);
11151
+
11152
+ // And swap it with the current element.
11153
+ t = array[m];
11154
+ array[m] = array[i];
11155
+ array[i] = t;
11156
+ ++seed;
11157
+ }
11158
+ return array;
11159
+ };
11160
+ // ------------------------------------------------------------------------------------
11161
+ // ------------------------------------------------------------------------------------
11162
+ // ------------------------------------------------------------------------------------
11163
+ // ------------------------------------------------------------------------------------
11164
+
11186
11165
  var _excluded$1 = ["fill", "width", "height"],
11187
11166
  _excluded2 = ["fill", "width", "height"],
11188
11167
  _excluded3 = ["fill", "gradient"],
@@ -39877,7 +39856,8 @@ var getTooltipData = function getTooltipData(_ref) {
39877
39856
  xScaleKey = _ref.xScaleKey,
39878
39857
  xScaleDataType = _ref.xScaleDataType,
39879
39858
  xScale = _ref.xScale,
39880
- xOrdering = _ref.xOrdering;
39859
+ xOrdering = _ref.xOrdering,
39860
+ chartType = _ref.chartType;
39881
39861
  var descending = xOrdering === 'desc';
39882
39862
  var point = event.localPoint(event$1) || {
39883
39863
  x: 0,
@@ -39945,7 +39925,12 @@ var getTooltipData = function getTooltipData(_ref) {
39945
39925
  tooltipData = Math.abs(_x - _d0Value) > Math.abs(_d1Value - _x) ? _d2 : _d;
39946
39926
  }
39947
39927
  } else if (xScaleDataType === 'string' && 'step' in xScale) {
39928
+ var barWidth = 0;
39948
39929
  // 1. Get the band width in pixels of the xScale so we can use it to determine how wide each column is
39930
+
39931
+ if (chartType === 'bar') {
39932
+ barWidth = xScale.bandwidth();
39933
+ }
39949
39934
  var scaleBandWidth = xScale.step();
39950
39935
  // 2. Get the horizontal x position by removing the margin.left value
39951
39936
  var _x2 = point.x - margin.left;
@@ -39957,7 +39942,7 @@ var getTooltipData = function getTooltipData(_ref) {
39957
39942
  tooltipData = _d3;
39958
39943
  if (_d4) {
39959
39944
  // If x is closer to scaleBandWidth * d0 or scaleBandWidth * d1, then use d0 or d1 respectively
39960
- tooltipData = Math.abs(_x2 - scaleBandWidth * _indexOfX2) > Math.abs(scaleBandWidth * (_indexOfX2 + 1) - _x2) ? _d4 : _d3;
39945
+ tooltipData = Math.abs(_x2 - (scaleBandWidth + barWidth) * _indexOfX2) > Math.abs((scaleBandWidth + barWidth) * (_indexOfX2 + 1) - _x2) ? _d4 : _d3;
39961
39946
  }
39962
39947
  }
39963
39948
  return {
@@ -40140,7 +40125,7 @@ var LegendItem = function LegendItem(_ref) {
40140
40125
  color: rule.color,
40141
40126
  style: style,
40142
40127
  yKey: yKey
40143
- });
40128
+ }, "rule-" + JSON.stringify(rule));
40144
40129
  })]
40145
40130
  }), jsxRuntime.jsx("span", {
40146
40131
  style: {
@@ -40269,69 +40254,13 @@ var GoalLine = function GoalLine(_ref) {
40269
40254
  */
40270
40255
 
40271
40256
  var ASSUMED_AVERAGE_CHAR_WIDTH = 8.8;
40272
- function calculateWordWidth(word, avgCharWidth) {
40273
- if (avgCharWidth === void 0) {
40274
- avgCharWidth = ASSUMED_AVERAGE_CHAR_WIDTH;
40275
- }
40276
- return word.length * avgCharWidth;
40277
- }
40278
-
40279
- /** Reduce width proportionally to simulate spacing / padding between ticks. */
40280
- var widthWithSpacing = function widthWithSpacing(width) {
40281
- var THIRTY_PERCENT = 0.3;
40282
- return width - width * THIRTY_PERCENT;
40283
- };
40284
- function howManyTicksFitInWidth(ticks, maxWidth, avgCharWidth) {
40285
- if (avgCharWidth === void 0) {
40286
- avgCharWidth = ASSUMED_AVERAGE_CHAR_WIDTH;
40287
- }
40288
- var fittedTicks = [];
40289
- var currentWidth = 0;
40290
- for (var _iterator = _createForOfIteratorHelperLoose(ticks), _step; !(_step = _iterator()).done;) {
40291
- var tick = _step.value;
40292
- var word = (tick == null ? void 0 : tick.formattedValue) || '';
40293
- var wordWidth = calculateWordWidth(word, avgCharWidth);
40294
- if (currentWidth + wordWidth <= widthWithSpacing(maxWidth)) {
40295
- fittedTicks.push(tick);
40296
- currentWidth += wordWidth + avgCharWidth; // Add space between words
40297
- } else {
40298
- break; // Stop if adding the word exceeds maxWidth
40299
- }
40300
- }
40301
- return fittedTicks.length;
40302
- }
40303
- function pickEquallySpaced(arr, numPicks) {
40304
- if (numPicks >= arr.length) {
40305
- return arr; // If numPicks is greater than or equal to the array length, return the whole array
40306
- }
40307
- var result = [];
40308
- var interval = (arr.length - 1) / (numPicks - 1);
40309
- for (var i = 0; i < numPicks; i++) {
40310
- var index = Math.round(i * interval); // Calculate index and round it
40311
- result.push(arr[index]);
40312
- }
40313
- return result;
40314
- }
40315
- var adjustTicks = function adjustTicks(lineChartRepresentation, width) {
40316
- lineChartRepresentation = _.cloneDeep(lineChartRepresentation);
40317
-
40318
- // TODO; take this from the theme override...
40319
- var averageCharacterWidth = ASSUMED_AVERAGE_CHAR_WIDTH;
40320
- var numberOfTicksFittingIntoSpace = howManyTicksFitInWidth(lineChartRepresentation.x.ticks || [], width, averageCharacterWidth);
40321
-
40322
- // @ts-ignore
40323
- lineChartRepresentation.x.ticks = pickEquallySpaced(lineChartRepresentation.x.ticks, numberOfTicksFittingIntoSpace);
40324
- return lineChartRepresentation;
40325
- };
40326
40257
 
40327
- var buildMargin = function buildMargin(chart, showYAxisLabels) {
40328
- var maxWidth = _.max(chart.y.ticks.map(function (tick) {
40258
+ var buildMargin = function buildMargin(yTicks, showYAxisLabels, hasYAxisTitle, hasXAxisTitle) {
40259
+ var maxWidth = _.max(yTicks.map(function (tick) {
40329
40260
  return (tick.formattedValue || '').length * ASSUMED_AVERAGE_CHAR_WIDTH;
40330
40261
  }));
40331
- var showYTicks = showYAxisLabels && chart.y.ticks.length > 0;
40262
+ var showYTicks = showYAxisLabels && yTicks.length > 0;
40332
40263
  var MINIMUM_Y_AXIS_WIDTH = 40;
40333
- var hasYAxisTitle = !!chart.y.title;
40334
- var hasXAxisTitle = !!chart.x.title;
40335
40264
  var yAxisTitleOffset = hasYAxisTitle ? 40 : 0;
40336
40265
  var xAxisTitleOffset = hasXAxisTitle ? 40 : 0;
40337
40266
  var left = showYTicks ? _.max([maxWidth, MINIMUM_Y_AXIS_WIDTH]) : MINIMUM_Y_AXIS_WIDTH;
@@ -40378,7 +40307,7 @@ var LineChart$5 = function LineChart(_ref) {
40378
40307
  tooltipData = _useTooltip.tooltipData,
40379
40308
  hideTooltip = _useTooltip.hideTooltip,
40380
40309
  showTooltip = _useTooltip.showTooltip;
40381
- var margin = buildMargin(chart, options.axis.showYAxisLabels);
40310
+ var margin = buildMargin(chart.y.ticks, options.axis.showYAxisLabels, chart.y.title != null, chart.x.title != null);
40382
40311
  var _useState = React.useState(chart.lines.map(function (legendItem) {
40383
40312
  return legendItem.yKey;
40384
40313
  })),
@@ -40468,7 +40397,8 @@ var LineChart$5 = function LineChart(_ref) {
40468
40397
  xScaleKey: xScaleKey,
40469
40398
  xScaleDataType: xScaleDataType,
40470
40399
  xOrdering: chart.x.scale.ordering,
40471
- xScale: xScale
40400
+ xScale: xScale,
40401
+ chartType: 'lines'
40472
40402
  });
40473
40403
  showTooltip({
40474
40404
  tooltipLeft: tooltipData == null ? void 0 : tooltipData.tooltipLeft,
@@ -41531,6 +41461,62 @@ var buildLineChartRepresentation = function buildLineChartRepresentation(_ref) {
41531
41461
  return chart;
41532
41462
  };
41533
41463
 
41464
+ var ASSUMED_AVERAGE_CHAR_WIDTH$1 = 8.8;
41465
+ function calculateWordWidth(word, avgCharWidth) {
41466
+ if (avgCharWidth === void 0) {
41467
+ avgCharWidth = ASSUMED_AVERAGE_CHAR_WIDTH$1;
41468
+ }
41469
+ return word.length * avgCharWidth;
41470
+ }
41471
+
41472
+ /** Reduce width proportionally to simulate spacing / padding between ticks. */
41473
+ var widthWithSpacing = function widthWithSpacing(width) {
41474
+ var THIRTY_PERCENT = 0.3;
41475
+ return width - width * THIRTY_PERCENT;
41476
+ };
41477
+ function howManyTicksFitInWidth(ticks, maxWidth, avgCharWidth) {
41478
+ if (avgCharWidth === void 0) {
41479
+ avgCharWidth = ASSUMED_AVERAGE_CHAR_WIDTH$1;
41480
+ }
41481
+ var fittedTicks = [];
41482
+ var currentWidth = 0;
41483
+ for (var _iterator = _createForOfIteratorHelperLoose(ticks), _step; !(_step = _iterator()).done;) {
41484
+ var tick = _step.value;
41485
+ var word = (tick == null ? void 0 : tick.formattedValue) || '';
41486
+ var wordWidth = calculateWordWidth(word, avgCharWidth);
41487
+ if (currentWidth + wordWidth <= widthWithSpacing(maxWidth)) {
41488
+ fittedTicks.push(tick);
41489
+ currentWidth += wordWidth + avgCharWidth; // Add space between words
41490
+ } else {
41491
+ break; // Stop if adding the word exceeds maxWidth
41492
+ }
41493
+ }
41494
+ return fittedTicks.length;
41495
+ }
41496
+ function pickEquallySpaced(arr, numPicks) {
41497
+ if (numPicks >= arr.length) {
41498
+ return arr; // If numPicks is greater than or equal to the array length, return the whole array
41499
+ }
41500
+ var result = [];
41501
+ var interval = (arr.length - 1) / (numPicks - 1);
41502
+ for (var i = 0; i < numPicks; i++) {
41503
+ var index = Math.round(i * interval); // Calculate index and round it
41504
+ result.push(arr[index]);
41505
+ }
41506
+ return result;
41507
+ }
41508
+ var adjustTicks = function adjustTicks(lineChartRepresentation, width) {
41509
+ lineChartRepresentation = _.cloneDeep(lineChartRepresentation);
41510
+
41511
+ // TODO; take this from the theme override...
41512
+ var averageCharacterWidth = ASSUMED_AVERAGE_CHAR_WIDTH$1;
41513
+ var numberOfTicksFittingIntoSpace = howManyTicksFitInWidth(lineChartRepresentation.x.ticks || [], width, averageCharacterWidth);
41514
+
41515
+ // @ts-ignore
41516
+ lineChartRepresentation.x.ticks = pickEquallySpaced(lineChartRepresentation.x.ticks, numberOfTicksFittingIntoSpace);
41517
+ return lineChartRepresentation;
41518
+ };
41519
+
41534
41520
  var LineChartV2View = function LineChartV2View(props) {
41535
41521
  var _props$library, _props$attributes$vie;
41536
41522
  var _useDashboardBehaviou = useDashboardBehaviourContext(),
@@ -43807,6 +43793,28 @@ function buildColumnWidth(datumKey, sizing, defaultColumnWidth, alternativeColum
43807
43793
  return (_sizing$width = (_sizing = sizing[datumKey]) == null ? void 0 : _sizing.width) != null ? _sizing$width : defaultColumnWidth;
43808
43794
  }
43809
43795
 
43796
+ function getFormattedByRule(_ref) {
43797
+ var type = _ref.type,
43798
+ value = _ref.value;
43799
+ var fontColor = pickBestTextColor(value != null ? value : '', ['white', 'black']);
43800
+ switch (type) {
43801
+ case 'fontColor':
43802
+ {
43803
+ return {
43804
+ color: value
43805
+ };
43806
+ }
43807
+ case 'backgroundColor':
43808
+ {
43809
+ return {
43810
+ backgroundColor: value,
43811
+ color: fontColor
43812
+ };
43813
+ }
43814
+ }
43815
+ return {};
43816
+ }
43817
+
43810
43818
  var DataTableTR = function DataTableTR(props) {
43811
43819
  var row = props.row,
43812
43820
  rowIndex = props.rowIndex,