@visactor/vseed 0.0.32 → 0.0.33

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/dist/index.js CHANGED
@@ -175,7 +175,7 @@ const autoMeasures = (advancedVSeed, context)=>{
175
175
  const { measures, dataset } = vseed;
176
176
  if (!dataset) throw new Error('dataset is required');
177
177
  if (0 === dataset.length) return result;
178
- if (measures && measures.length > 0) {
178
+ if (measures) {
179
179
  result.measures = measures;
180
180
  return result;
181
181
  }
@@ -255,7 +255,7 @@ const autoDimensions = (advancedVSeed, context)=>{
255
255
  const measures = findAllMeasures(advancedVSeed.measures);
256
256
  if (!dataset) throw new Error('dataset is required');
257
257
  if (0 === dataset.length) return result;
258
- if (dimensions && dimensions.length > 0) {
258
+ if (dimensions) {
259
259
  result.dimensions = dimensions;
260
260
  return result;
261
261
  }
@@ -552,7 +552,7 @@ const autoPivotMeasures = (advancedVSeed, context)=>{
552
552
  const measures = findAllMeasures(vseed.measures);
553
553
  if (!dataset) throw new Error('dataset is required');
554
554
  if (0 === dataset.length) return result;
555
- if (measures && measures.length > 0) {
555
+ if (measures) {
556
556
  result.measures = findAllMeasures(measures);
557
557
  return result;
558
558
  }
@@ -615,7 +615,7 @@ const autoPivotDimensions = (advancedVSeed, context)=>{
615
615
  const measures = findAllMeasures(advancedVSeed.measures);
616
616
  if (!dataset) throw new Error('dataset is required');
617
617
  if (0 === dataset.length) return result;
618
- if (dimensions && dimensions.length > 0) {
618
+ if (dimensions) {
619
619
  const newDimensions = findAllDimensions(dimensions);
620
620
  result.dimensions = newDimensions.map((item, index)=>{
621
621
  if ('rowDimension' === item.location || 'columnDimension' === item.location) return item;
@@ -2303,7 +2303,7 @@ const annotationPoint_annotationPoint = (spec, context)=>{
2303
2303
  annotationPoint
2304
2304
  ];
2305
2305
  const markPoint = annotationPointList.flatMap((annotationPoint)=>{
2306
- const { selector: selectorPoint, text = '', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'center', textBaseline = 'middle', backgroundBorderColor, backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundColor = '#212121', backgroundPadding = 2, backgroundVisible = true, offsetX = 0, offsetY = 0 } = annotationPoint;
2306
+ const { selector: selectorPoint, text = '', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'center', textBaseline = 'top', backgroundBorderColor, backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundColor = '#212121', backgroundPadding = 2, backgroundVisible = true, offsetX = 0, offsetY = 0 } = annotationPoint;
2307
2307
  const dataset = advancedVSeed.dataset.flat();
2308
2308
  const selectedData = selectorPoint ? dataset.filter((datum)=>selector_selector(datum, selectorPoint)) : [];
2309
2309
  return selectedData.map((datum)=>({
@@ -2335,7 +2335,8 @@ const annotationPoint_annotationPoint = (spec, context)=>{
2335
2335
  stroke: backgroundColor,
2336
2336
  lineWidth: 1,
2337
2337
  fontSize: textFontSize,
2338
- fontWeight: textFontWeight
2338
+ fontWeight: textFontWeight,
2339
+ dy: textFontSize
2339
2340
  },
2340
2341
  labelBackground: {
2341
2342
  visible: backgroundVisible,
@@ -2344,7 +2345,8 @@ const annotationPoint_annotationPoint = (spec, context)=>{
2344
2345
  cornerRadius: backgroundBorderRadius ?? 4,
2345
2346
  fill: backgroundColor,
2346
2347
  stroke: backgroundBorderColor,
2347
- lineWidth: backgroundBorderWidth
2348
+ lineWidth: backgroundBorderWidth,
2349
+ dy: textFontSize
2348
2350
  }
2349
2351
  }
2350
2352
  }
@@ -2373,7 +2375,7 @@ const annotationVerticalLine_annotationVerticalLine = (spec, context)=>{
2373
2375
  insideEnd: 'insideEndTop'
2374
2376
  };
2375
2377
  const markLine = annotationVerticalLineList.flatMap((annotationVerticalLine)=>{
2376
- const { selector: selectorPoint, xValue, text = '', textPosition = 'insideEnd', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'right', textBaseline = 'top', backgroundBorderColor, backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundColor = '#212121', backgroundPadding = 2, backgroundVisible = true, lineColor = '#212121', lineStyle = 'dashed', lineVisible = true, lineWidth = 1, offsetX = 0, offsetY = 0 } = annotationVerticalLine;
2378
+ const { selector: selectorPoint, xValue, text = '', textPosition = 'insideEnd', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'right', textBaseline = 'top', backgroundVisible = true, backgroundBorderColor = '#212121', backgroundColor = '#212121', backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundPadding = 2, lineVisible = true, lineColor = '#212121', lineWidth = 1, lineStyle = 'dashed', offsetX = 0, offsetY = 0 } = annotationVerticalLine;
2377
2379
  const dataset = advancedVSeed.dataset.flat();
2378
2380
  const generateOneMarkLine = (x)=>({
2379
2381
  x: x,
@@ -2472,7 +2474,7 @@ const annotationHorizontalLine_annotationHorizontalLine = (spec, context)=>{
2472
2474
  insideEnd: 'insideEndTop'
2473
2475
  };
2474
2476
  const markLine = annotationVerticalLineList.flatMap((annotationVerticalLine)=>{
2475
- const { selector: selectorPoint, yValue, text = '', textPosition = 'insideEnd', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'right', textBaseline = 'top', backgroundBorderColor, backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundColor = '#212121', backgroundPadding = 2, backgroundVisible = true, lineColor = '#212121', lineStyle = 'dashed', lineVisible = true, lineWidth = 1, offsetX = 0, offsetY = 0 } = annotationVerticalLine;
2477
+ const { selector: selectorPoint, yValue, text = '', textPosition = 'insideEnd', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'right', textBaseline = 'top', lineColor = '#212121', lineStyle = 'dashed', lineVisible = true, lineWidth = 1, backgroundVisible = true, backgroundColor = '#212121', backgroundBorderColor = '#212121', backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundPadding = 2, offsetX = 0, offsetY = 0 } = annotationVerticalLine;
2476
2478
  const dataset = advancedVSeed.dataset.flat();
2477
2479
  const generateOneMarkLine = (y)=>({
2478
2480
  y,
@@ -2573,7 +2575,7 @@ const annotationArea_annotationArea = (spec, context)=>{
2573
2575
  right: 'insideRight'
2574
2576
  };
2575
2577
  const markArea = annotationAreaList.flatMap((annotationArea)=>{
2576
- const { selector: selectorPoint, text = '', textPosition = 'top', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'center', textBaseline = 'top', backgroundBorderColor, backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundColor = '#191d24', backgroundPadding = 10, backgroundVisible = true, outerPadding = 4, areaColor = '#888888', areaColorOpacity = 0.15, areaBorderColor, areaBorderRadius, areaBorderWidth, offsetX = 0, offsetY = 0 } = annotationArea;
2578
+ const { selector: selectorPoint, text = '', textPosition = 'top', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'center', textBaseline = 'top', backgroundVisible = true, backgroundColor = '#191d24', backgroundBorderColor = '#191d24', backgroundBorderWidth = 1, backgroundBorderRadius = 4, backgroundPadding = 4, areaColor = '#888888', areaColorOpacity = 0.15, areaBorderColor = '#888888', areaBorderRadius = 4, areaBorderWidth = 1, outerPadding = 4, offsetX = 0, offsetY = 0 } = annotationArea;
2577
2579
  const dataset = advancedVSeed.dataset.flat();
2578
2580
  const selectedData = selectorPoint ? dataset.filter((datum)=>selector_selector(datum, selectorPoint)) : [];
2579
2581
  return {
@@ -2643,6 +2645,7 @@ const annotationArea_annotationArea = (spec, context)=>{
2643
2645
  visible: true,
2644
2646
  text: text,
2645
2647
  style: {
2648
+ dy: textFontSize,
2646
2649
  textAlign: textAlign,
2647
2650
  textBaseline: textBaseline,
2648
2651
  fill: textColor,
@@ -2655,6 +2658,7 @@ const annotationArea_annotationArea = (spec, context)=>{
2655
2658
  visible: backgroundVisible,
2656
2659
  padding: backgroundPadding,
2657
2660
  style: {
2661
+ dy: textFontSize,
2658
2662
  cornerRadius: backgroundBorderRadius ?? 4,
2659
2663
  fill: backgroundColor,
2660
2664
  stroke: backgroundBorderColor,
@@ -3410,7 +3414,7 @@ const annotationAreaBand = (spec, context)=>{
3410
3414
  right: 'insideRight'
3411
3415
  };
3412
3416
  const markArea = annotationAreaList.flatMap((annotationArea)=>{
3413
- const { selector: selectorPoint, text = '', textPosition = 'top', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'center', textBaseline = 'top', backgroundBorderColor, backgroundBorderRadius = 4, backgroundBorderWidth = 1, backgroundColor = '#191d24', backgroundPadding = 4, backgroundVisible = true, outerPadding = 8, areaColor = '#888888', areaColorOpacity = 0.15, areaBorderColor, areaBorderRadius, areaBorderWidth, offsetX, offsetY } = annotationArea;
3417
+ const { selector: selectorPoint, text = '', textPosition = 'top', textColor = '#ffffff', textFontSize = 12, textFontWeight = 400, textAlign = 'center', textBaseline = 'top', backgroundVisible = true, backgroundColor = '#191d24', backgroundBorderColor = '#191d24', backgroundBorderWidth = 1, backgroundBorderRadius = 4, backgroundPadding = 4, areaColor = '#888888', areaColorOpacity = 0.15, areaBorderColor = '#888888', areaBorderRadius = 4, areaBorderWidth = 1, outerPadding = 4, offsetX = 0, offsetY = 0 } = annotationArea;
3414
3418
  const dataset = advancedVSeed.dataset.flat();
3415
3419
  const selectedData = selectorPoint ? dataset.filter((datum)=>selector_selector(datum, selectorPoint)) : [];
3416
3420
  return {
@@ -3484,6 +3488,7 @@ const annotationAreaBand = (spec, context)=>{
3484
3488
  visible: true,
3485
3489
  text: text,
3486
3490
  style: {
3491
+ dy: textFontSize,
3487
3492
  textAlign: textAlign,
3488
3493
  textBaseline: textBaseline,
3489
3494
  stroke: backgroundColor,
@@ -3496,6 +3501,7 @@ const annotationAreaBand = (spec, context)=>{
3496
3501
  visible: backgroundVisible,
3497
3502
  padding: backgroundPadding,
3498
3503
  style: {
3504
+ dy: textFontSize,
3499
3505
  cornerRadius: backgroundBorderRadius ?? 4,
3500
3506
  fill: backgroundColor,
3501
3507
  stroke: backgroundBorderColor,
@@ -7830,20 +7836,20 @@ const zAnnotationVerticalLine = z.object({
7830
7836
  'middle',
7831
7837
  'bottom'
7832
7838
  ]).default('top').optional(),
7833
- lineVisible: z.boolean().optional(),
7834
- lineColor: z.string().optional(),
7835
- lineWidth: z.number().optional(),
7839
+ lineVisible: z.boolean().default(true).optional(),
7840
+ lineColor: z.string().default('#212121').optional(),
7841
+ lineWidth: z.number().default(1).optional(),
7836
7842
  lineStyle: z.union([
7837
7843
  z.literal('solid'),
7838
7844
  z.literal('dashed'),
7839
7845
  z.literal('dotted')
7840
- ]).optional(),
7846
+ ]).default('dashed').optional(),
7841
7847
  backgroundVisible: z.boolean().default(true).optional(),
7842
7848
  backgroundColor: z.string().default('#212121').optional(),
7843
- backgroundBorderColor: z.string().optional(),
7844
- backgroundBorderWidth: z.number().default(1).optional(),
7849
+ backgroundBorderColor: z.string().default('#212121').optional(),
7845
7850
  backgroundBorderRadius: z.number().default(4).optional(),
7846
- backgroundPadding: z.number().optional(),
7851
+ backgroundBorderWidth: z.number().default(1).optional(),
7852
+ backgroundPadding: z.number().default(2).optional(),
7847
7853
  offsetX: z.number().default(0),
7848
7854
  offsetY: z.number().default(0)
7849
7855
  });
@@ -7868,7 +7874,7 @@ const zAnnotationHorizontalLine = z.object({
7868
7874
  'insideStart',
7869
7875
  'insideMiddle',
7870
7876
  'insideEnd'
7871
- ]).default('insideMiddle').optional(),
7877
+ ]).default('insideEnd').optional(),
7872
7878
  textColor: z.string().default('#ffffff').optional(),
7873
7879
  textFontSize: z.number().default(12).optional(),
7874
7880
  textFontWeight: z.number().default(400).optional(),
@@ -7876,26 +7882,26 @@ const zAnnotationHorizontalLine = z.object({
7876
7882
  'left',
7877
7883
  'right',
7878
7884
  'center'
7879
- ]).default('center').optional(),
7885
+ ]).default('right').optional(),
7880
7886
  textBaseline: z["enum"]([
7881
7887
  'top',
7882
7888
  'middle',
7883
7889
  'bottom'
7884
- ]).default('bottom').optional(),
7885
- lineVisible: z.boolean().optional(),
7886
- lineColor: z.string().optional(),
7887
- lineWidth: z.number().optional(),
7890
+ ]).default('top').optional(),
7891
+ lineVisible: z.boolean().default(true).optional(),
7892
+ lineColor: z.string().default('#212121').optional(),
7893
+ lineWidth: z.number().default(1).optional(),
7888
7894
  lineStyle: z.union([
7889
7895
  z.literal('solid'),
7890
7896
  z.literal('dashed'),
7891
7897
  z.literal('dotted')
7892
- ]).optional(),
7898
+ ]).default('dashed').optional(),
7893
7899
  backgroundVisible: z.boolean().default(true).optional(),
7894
7900
  backgroundColor: z.string().default('#212121').optional(),
7895
- backgroundBorderColor: z.string().optional(),
7896
- backgroundBorderWidth: z.number().default(1).optional(),
7901
+ backgroundBorderColor: z.string().default('#212121').optional(),
7897
7902
  backgroundBorderRadius: z.number().default(4).optional(),
7898
- backgroundPadding: z.number().optional(),
7903
+ backgroundBorderWidth: z.number().default(1).optional(),
7904
+ backgroundPadding: z.number().default(2).optional(),
7899
7905
  offsetX: z.number().default(0),
7900
7906
  offsetY: z.number().default(0)
7901
7907
  });
@@ -7927,21 +7933,21 @@ const zAnnotationArea = z.object({
7927
7933
  'top',
7928
7934
  'middle',
7929
7935
  'bottom'
7930
- ]).default('middle').optional(),
7936
+ ]).default('top').optional(),
7931
7937
  backgroundVisible: z.boolean().default(true).optional(),
7932
- backgroundColor: z.string().default('#212121').optional(),
7933
- backgroundBorderColor: z.string().optional(),
7938
+ backgroundColor: z.string().default('#191d24').optional(),
7939
+ backgroundBorderColor: z.string().default('#191d24').optional(),
7934
7940
  backgroundBorderWidth: z.number().default(1).optional(),
7935
7941
  backgroundBorderRadius: z.number().default(4).optional(),
7936
- backgroundPadding: z.number().optional(),
7937
- areaColor: z.string().default('red').optional(),
7938
- areaColorOpacity: z.number().default(0.5).optional(),
7939
- areaBorderColor: z.number().optional(),
7940
- areaBorderWidth: z.number().default(2).optional(),
7942
+ backgroundPadding: z.number().default(4).optional(),
7943
+ areaColor: z.string().default('#888888').optional(),
7944
+ areaColorOpacity: z.number().default(0.15).optional(),
7945
+ areaBorderColor: z.string().default('#888888').optional(),
7946
+ areaBorderWidth: z.number().default(1).optional(),
7941
7947
  areaBorderRadius: z.number().default(4).optional(),
7942
- outerPadding: z.number().optional(),
7943
- offsetX: z.number().optional(),
7944
- offsetY: z.number().optional()
7948
+ outerPadding: z.number().default(4).optional(),
7949
+ offsetX: z.number().default(0).optional(),
7950
+ offsetY: z.number().default(0).optional()
7945
7951
  });
7946
7952
  const zAnnotation = z.object({
7947
7953
  annotationPoint: zAnnotationPoint.or(z.array(zAnnotationPoint)).optional(),