@unovis/ts 1.7.0-Phoenix.0 → 1.7.0-stellar.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.
Files changed (54) hide show
  1. package/components/area/config.d.ts +2 -0
  2. package/components/area/config.js +1 -1
  3. package/components/area/config.js.map +1 -1
  4. package/components/area/index.js +6 -3
  5. package/components/area/index.js.map +1 -1
  6. package/components/crosshair/config.d.ts +1 -1
  7. package/components/crosshair/config.js.map +1 -1
  8. package/components/crosshair/index.d.ts +1 -1
  9. package/components/crosshair/index.js.map +1 -1
  10. package/components/sankey/config.d.ts +0 -8
  11. package/components/sankey/config.js +1 -1
  12. package/components/sankey/config.js.map +1 -1
  13. package/components/sankey/index.d.ts +0 -29
  14. package/components/sankey/index.js +0 -70
  15. package/components/sankey/index.js.map +1 -1
  16. package/components/sankey/modules/link.js +3 -16
  17. package/components/sankey/modules/link.js.map +1 -1
  18. package/components/sankey/types.d.ts +0 -2
  19. package/components/sankey/types.js.map +1 -1
  20. package/components/tooltip/index.js +2 -2
  21. package/components/tooltip/index.js.map +1 -1
  22. package/components/topojson-map/config.d.ts +57 -1
  23. package/components/topojson-map/config.js +6 -2
  24. package/components/topojson-map/config.js.map +1 -1
  25. package/components/topojson-map/index.d.ts +25 -0
  26. package/components/topojson-map/index.js +708 -32
  27. package/components/topojson-map/index.js.map +1 -1
  28. package/components/topojson-map/modules/donut.d.ts +3 -0
  29. package/components/topojson-map/modules/donut.js +25 -0
  30. package/components/topojson-map/modules/donut.js.map +1 -0
  31. package/components/topojson-map/style.d.ts +6 -0
  32. package/components/topojson-map/style.js +45 -1
  33. package/components/topojson-map/style.js.map +1 -1
  34. package/components/topojson-map/types.d.ts +82 -0
  35. package/components/topojson-map/types.js +8 -1
  36. package/components/topojson-map/types.js.map +1 -1
  37. package/components/topojson-map/utils.d.ts +17 -0
  38. package/components/topojson-map/utils.js +177 -3
  39. package/components/topojson-map/utils.js.map +1 -1
  40. package/components.d.ts +2 -0
  41. package/components.js +1 -0
  42. package/components.js.map +1 -1
  43. package/containers/single-container/config.d.ts +3 -0
  44. package/containers/single-container/config.js.map +1 -1
  45. package/containers/single-container/index.js +2 -1
  46. package/containers/single-container/index.js.map +1 -1
  47. package/containers/xy-container/config.d.ts +3 -0
  48. package/containers/xy-container/config.js.map +1 -1
  49. package/containers/xy-container/index.d.ts +1 -0
  50. package/containers/xy-container/index.js +13 -9
  51. package/containers/xy-container/index.js.map +1 -1
  52. package/index.js +1 -1
  53. package/package.json +1 -1
  54. package/types.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/components/topojson-map/types.ts"],"sourcesContent":["import { Feature, Geometry } from 'geojson'\nimport {\n GeoProjection,\n geoMercator,\n geoEquirectangular,\n geoAzimuthalEqualArea,\n geoAzimuthalEquidistant,\n geoGnomonic,\n geoOrthographic,\n geoStereographic,\n geoEqualEarth,\n geoAlbersUsa,\n geoAlbers,\n geoConicConformal,\n geoConicEqualArea,\n geoConicEquidistant,\n geoTransverseMercator,\n geoNaturalEarth1,\n} from 'd3-geo'\n\nimport {\n geoBromley,\n geoNaturalEarth2,\n geoKavrayskiy7,\n geoHufnagel,\n geoFoucautSinusoidal,\n geoFahey,\n geoEckert1,\n geoEckert3,\n geoBoggs,\n geoCylindricalStereographic,\n geoCraster,\n geoBaker,\n geoArmadillo,\n geoAitoff,\n geoRobinson,\n} from 'd3-geo-projection'\n\nexport type MapData<AreaDatum, PointDatum = unknown, LinkDatum = unknown> = {\n areas?: AreaDatum[];\n points?: PointDatum[];\n links?: LinkDatum[] ;\n}\n\nexport enum MapPointLabelPosition {\n Center = 'center',\n Bottom = 'bottom',\n}\n\nexport type MapFeature<D> = Feature<Geometry> & { data: D }\n\nexport enum MapProjectionKind {\n // Projections form `d3-geo`\n Mercator = 'Mercator',\n Equirectangular = 'Equirectangular',\n AzimuthalEqualArea = 'AzimuthalEqualArea',\n AzimuthalEquidistant = 'AzimuthalEquidistant',\n Gnomonic = 'Gnomonic',\n Orthographic = 'Orthographic',\n Stereographic = 'Stereographic',\n EqualEarth = 'EqualEarth',\n AlbersUsa = 'AlbersUsa',\n Albers = 'Albers',\n ConicConformal = 'ConicConformal',\n ConicEqualArea = 'ConicEqualArea',\n ConicEquidistant = 'ConicEquidistant',\n TransverseMercator = 'TransverseMercator',\n NaturalEarth1 = 'NaturalEarth1',\n\n // Projections form `d3-geo-projection`\n Bromley = 'Bromley',\n NaturalEarth2 = 'NaturalEarth2',\n Kavrayskiy7 = 'Kavrayskiy7',\n Hufnagel = 'Hufnagel',\n FoucautSinusoidal = 'FoucautSinusoidal',\n Eckert1 = 'Eckert1',\n Eckert3 = 'Eckert3',\n Boggs = 'Boggs',\n CylindricalStereographic = 'CylindricalStereographic',\n Craster = 'Craster',\n Baker = 'Baker',\n Armadillo = 'Armadillo',\n Aitoff = 'Aitoff',\n Fahey = 'Fahey',\n Robinson = 'Robinson',\n}\n\nexport const MapProjection = {\n // Projections form `d3-geo`\n [MapProjectionKind.Mercator]: geoMercator,\n [MapProjectionKind.Equirectangular]: geoEquirectangular,\n [MapProjectionKind.AzimuthalEqualArea]: geoAzimuthalEqualArea,\n [MapProjectionKind.AzimuthalEquidistant]: geoAzimuthalEquidistant,\n [MapProjectionKind.Gnomonic]: geoGnomonic,\n [MapProjectionKind.Orthographic]: geoOrthographic,\n [MapProjectionKind.Stereographic]: geoStereographic,\n [MapProjectionKind.EqualEarth]: geoEqualEarth,\n [MapProjectionKind.AlbersUsa]: geoAlbersUsa,\n [MapProjectionKind.Albers]: geoAlbers,\n [MapProjectionKind.ConicConformal]: geoConicConformal,\n [MapProjectionKind.ConicEqualArea]: geoConicEqualArea,\n [MapProjectionKind.ConicEquidistant]: geoConicEquidistant,\n [MapProjectionKind.TransverseMercator]: geoTransverseMercator,\n [MapProjectionKind.NaturalEarth1]: geoNaturalEarth1,\n\n // Projections form `d3-geo-projection`\n [MapProjectionKind.Bromley]: geoBromley as () => GeoProjection,\n [MapProjectionKind.NaturalEarth2]: geoNaturalEarth2 as () => GeoProjection,\n [MapProjectionKind.Kavrayskiy7]: geoKavrayskiy7 as () => GeoProjection,\n [MapProjectionKind.Hufnagel]: geoHufnagel as () => GeoProjection,\n [MapProjectionKind.FoucautSinusoidal]: geoFoucautSinusoidal as () => GeoProjection,\n [MapProjectionKind.Eckert1]: geoEckert1 as () => GeoProjection,\n [MapProjectionKind.Eckert3]: geoEckert3 as () => GeoProjection,\n [MapProjectionKind.Boggs]: geoBoggs as () => GeoProjection,\n [MapProjectionKind.CylindricalStereographic]: geoCylindricalStereographic as () => GeoProjection,\n [MapProjectionKind.Craster]: geoCraster as () => GeoProjection,\n [MapProjectionKind.Baker]: geoBaker as () => GeoProjection,\n [MapProjectionKind.Armadillo]: geoArmadillo as () => GeoProjection,\n [MapProjectionKind.Aitoff]: geoAitoff as () => GeoProjection,\n [MapProjectionKind.Fahey]: geoFahey as () => GeoProjection,\n [MapProjectionKind.Robinson]: geoRobinson as () => GeoProjection,\n}\n\n"],"names":[],"mappings":";;;IA4CY,sBAGX;AAHD,CAAA,UAAY,qBAAqB,EAAA;AAC/B,IAAA,qBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,qBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACnB,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,GAGhC,EAAA,CAAA,CAAA,CAAA;IAIW,kBAkCX;AAlCD,CAAA,UAAY,iBAAiB,EAAA;;AAE3B,IAAA,iBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,iBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACnC,IAAA,iBAAA,CAAA,oBAAA,CAAA,GAAA,oBAAyC,CAAA;AACzC,IAAA,iBAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C,CAAA;AAC7C,IAAA,iBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA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GAAG,cAAqC;AACtE,IAAA,CAAC,iBAAiB,CAAC,QAAQ,GAAG,WAAkC;AAChE,IAAA,CAAC,iBAAiB,CAAC,iBAAiB,GAAG,oBAA2C;AAClF,IAAA,CAAC,iBAAiB,CAAC,OAAO,GAAG,UAAiC;AAC9D,IAAA,CAAC,iBAAiB,CAAC,OAAO,GAAG,UAAiC;AAC9D,IAAA,CAAC,iBAAiB,CAAC,KAAK,GAAG,QAA+B;AAC1D,IAAA,CAAC,iBAAiB,CAAC,wBAAwB,GAAG,2BAAkD;AAChG,IAAA,CAAC,iBAAiB,CAAC,OAAO,GAAG,UAAiC;AAC9D,IAAA,CAAC,iBAAiB,CAAC,KAAK,GAAG,QAA+B;AAC1D,IAAA,CAAC,iBAAiB,CAAC,SAAS,GAAG,YAAmC;AAClE,IAAA,CAAC,iBAAiB,CAAC,MAAM,GAAG,SAAgC;AAC5D,IAAA,CAAC,iBAAiB,CAAC,KAAK,GAAG,QAA+B;AAC1D,IAAA,CAAC,iBAAiB,CAAC,QAAQ,GAAG,WAAkC;;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/components/topojson-map/types.ts"],"sourcesContent":["import { Feature, Geometry } from 'geojson'\nimport Supercluster from 'supercluster'\nimport {\n GeoProjection,\n geoMercator,\n geoEquirectangular,\n geoAzimuthalEqualArea,\n geoAzimuthalEquidistant,\n geoGnomonic,\n geoOrthographic,\n geoStereographic,\n geoEqualEarth,\n geoAlbersUsa,\n geoAlbers,\n geoConicConformal,\n geoConicEqualArea,\n geoConicEquidistant,\n geoTransverseMercator,\n geoNaturalEarth1,\n} from 'd3-geo'\n\nimport {\n geoBromley,\n geoNaturalEarth2,\n geoKavrayskiy7,\n geoHufnagel,\n geoFoucautSinusoidal,\n geoFahey,\n geoEckert1,\n geoEckert3,\n geoBoggs,\n geoCylindricalStereographic,\n geoCraster,\n geoBaker,\n geoArmadillo,\n geoAitoff,\n geoRobinson,\n} from 'd3-geo-projection'\n\nexport type MapData<AreaDatum, PointDatum = unknown, LinkDatum = unknown> = {\n areas?: AreaDatum[];\n points?: PointDatum[];\n links?: LinkDatum[] ;\n}\n\nexport enum MapPointLabelPosition {\n Center = 'center',\n Bottom = 'bottom',\n}\n\nexport enum TopoJSONMapPointShape {\n Square = 'square',\n Circle = 'circle',\n Triangle = 'triangle',\n Ring = 'ring',\n}\n\nexport type MapFeature<D> = Feature<Geometry> & { data: D }\n\nexport type TopoJSONMapPieDatum = {\n value: number;\n name: string;\n color: string;\n className?: string;\n}\n\nexport interface TopoJSONMapPointStyle {\n color: string;\n className?: string;\n}\n\nexport type TopoJSONMapPointStyles<D> = { [key in keyof D]?: TopoJSONMapPointStyle }\n\nexport type TopoJSONMapPointDatum<D> = D & {\n id: string | number;\n shape: TopoJSONMapPointShape;\n _index: number;\n}\n\nexport type TopoJSONMapClusterDatum<D> = Partial<D> & {\n cluster?: boolean;\n clusterId?: number;\n pointCount?: number;\n pointCountAbbreviated?: string;\n clusterPoints?: D[];\n clusterIndex?: Supercluster<D>;\n}\n\nexport type TopoJSONMapPoint<D> = {\n geometry: GeoJSON.Point;\n bbox: { x1: number; x2: number; y1: number; y2: number };\n radius: number;\n path: string;\n color: string;\n id: number | string;\n properties: TopoJSONMapPointDatum<D> | TopoJSONMapClusterDatum<D>;\n donutData: TopoJSONMapPieDatum[];\n isCluster: boolean;\n clusterIndex?: Supercluster<D>;\n _zIndex: number;\n}\n\nexport interface FlowParticle {\n // Geographical properties\n source: { lat: number; lon: number };\n target: { lat: number; lon: number };\n location: { lat: number; lon: number };\n velocity: number;\n\n // Screen properties\n x: number;\n y: number;\n radius: number;\n color: string;\n\n // Flow data reference\n flowData: any;\n\n // Animation state\n progress: number; // 0 to 1, how far along the path\n\n // Unique identifier for data binding\n id: string;\n}\n\nexport interface FlowSourcePoint {\n lat: number;\n lon: number;\n x: number;\n y: number;\n radius: number;\n color: string;\n flowData: any;\n}\n\nexport enum MapProjectionKind {\n // Projections form `d3-geo`\n Mercator = 'Mercator',\n Equirectangular = 'Equirectangular',\n AzimuthalEqualArea = 'AzimuthalEqualArea',\n AzimuthalEquidistant = 'AzimuthalEquidistant',\n Gnomonic = 'Gnomonic',\n Orthographic = 'Orthographic',\n Stereographic = 'Stereographic',\n EqualEarth = 'EqualEarth',\n AlbersUsa = 'AlbersUsa',\n Albers = 'Albers',\n ConicConformal = 'ConicConformal',\n ConicEqualArea = 'ConicEqualArea',\n ConicEquidistant = 'ConicEquidistant',\n TransverseMercator = 'TransverseMercator',\n NaturalEarth1 = 'NaturalEarth1',\n\n // Projections form `d3-geo-projection`\n Bromley = 'Bromley',\n NaturalEarth2 = 'NaturalEarth2',\n Kavrayskiy7 = 'Kavrayskiy7',\n Hufnagel = 'Hufnagel',\n FoucautSinusoidal = 'FoucautSinusoidal',\n Eckert1 = 'Eckert1',\n Eckert3 = 'Eckert3',\n Boggs = 'Boggs',\n CylindricalStereographic = 'CylindricalStereographic',\n Craster = 'Craster',\n Baker = 'Baker',\n Armadillo = 'Armadillo',\n Aitoff = 'Aitoff',\n Fahey = 'Fahey',\n Robinson = 'Robinson',\n}\n\nexport const MapProjection = {\n // Projections form `d3-geo`\n [MapProjectionKind.Mercator]: geoMercator,\n [MapProjectionKind.Equirectangular]: geoEquirectangular,\n [MapProjectionKind.AzimuthalEqualArea]: geoAzimuthalEqualArea,\n [MapProjectionKind.AzimuthalEquidistant]: geoAzimuthalEquidistant,\n [MapProjectionKind.Gnomonic]: geoGnomonic,\n [MapProjectionKind.Orthographic]: geoOrthographic,\n [MapProjectionKind.Stereographic]: geoStereographic,\n [MapProjectionKind.EqualEarth]: geoEqualEarth,\n [MapProjectionKind.AlbersUsa]: geoAlbersUsa,\n [MapProjectionKind.Albers]: geoAlbers,\n [MapProjectionKind.ConicConformal]: geoConicConformal,\n [MapProjectionKind.ConicEqualArea]: geoConicEqualArea,\n [MapProjectionKind.ConicEquidistant]: geoConicEquidistant,\n [MapProjectionKind.TransverseMercator]: geoTransverseMercator,\n [MapProjectionKind.NaturalEarth1]: geoNaturalEarth1,\n\n // Projections form `d3-geo-projection`\n [MapProjectionKind.Bromley]: geoBromley as () => GeoProjection,\n [MapProjectionKind.NaturalEarth2]: geoNaturalEarth2 as () => GeoProjection,\n [MapProjectionKind.Kavrayskiy7]: geoKavrayskiy7 as () => GeoProjection,\n [MapProjectionKind.Hufnagel]: geoHufnagel as () => GeoProjection,\n [MapProjectionKind.FoucautSinusoidal]: geoFoucautSinusoidal as () => GeoProjection,\n [MapProjectionKind.Eckert1]: geoEckert1 as () => GeoProjection,\n [MapProjectionKind.Eckert3]: geoEckert3 as () => GeoProjection,\n [MapProjectionKind.Boggs]: geoBoggs as () => GeoProjection,\n [MapProjectionKind.CylindricalStereographic]: geoCylindricalStereographic as () => GeoProjection,\n [MapProjectionKind.Craster]: geoCraster as () => GeoProjection,\n [MapProjectionKind.Baker]: geoBaker as () => GeoProjection,\n [MapProjectionKind.Armadillo]: geoArmadillo as () => GeoProjection,\n [MapProjectionKind.Aitoff]: geoAitoff as () => GeoProjection,\n [MapProjectionKind.Fahey]: geoFahey as () => GeoProjection,\n [MapProjectionKind.Robinson]: geoRobinson as () => GeoProjection,\n}\n\n"],"names":[],"mappings":";;;IA6CY,sBAGX;AAHD,CAAA,UAAY,qBAAqB,EAAA;AAC/B,IAAA,qBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,qBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACnB,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,GAGhC,EAAA,CAAA,CAAA,CAAA;IAEW,sBAKX;AALD,CAAA,UAAY,qBAAqB,EAAA;AAC/B,IAAA,qBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,qBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,qBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,qBAAA,CAAA,MAAA,CAAA,GAAA,MAAa,C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AG,SAAS;AACrC,IAAA,CAAC,iBAAiB,CAAC,cAAc,GAAG,iBAAiB;AACrD,IAAA,CAAC,iBAAiB,CAAC,cAAc,GAAG,iBAAiB;AACrD,IAAA,CAAC,iBAAiB,CAAC,gBAAgB,GAAG,mBAAmB;AACzD,IAAA,CAAC,iBAAiB,CAAC,kBAAkB,GAAG,qBAAqB;AAC7D,IAAA,CAAC,iBAAiB,CAAC,aAAa,GAAG,gBAAgB;;AAGnD,IAAA,CAAC,iBAAiB,CAAC,OAAO,GAAG,UAAiC;AAC9D,IAAA,CAAC,iBAAiB,CAAC,aAAa,GAAG,gBAAuC;AAC1E,IAAA,CAAC,iBAAiB,CAAC,WAAW,GAAG,cAAqC;AACtE,IAAA,CAAC,iBAAiB,CAAC,QAAQ,GAAG,WAAkC;AAChE,IAAA,CAAC,iBAAiB,CAAC,iBAAiB,GAAG,oBAA2C;AAClF,IAAA,CAAC,iBAAiB,CAAC,OAAO,GAAG,UAAiC;AAC9D,IAAA,CAAC,iBAAiB,CAAC,OAAO,GAAG,UAAiC;AAC9D,IAAA,CAAC,iBAAiB,CAAC,KAAK,GAAG,QAA+B;AAC1D,IAAA,CAAC,iBAAiB,CAAC,wBAAwB,GAAG,2BAAkD;AAChG,IAAA,CAAC,iBAAiB,CAAC,OAAO,GAAG,UAAiC;AAC9D,IAAA,CAAC,iBAAiB,CAAC,KAAK,GAAG,QAA+B;AAC1D,IAAA,CAAC,iBAAiB,CAAC,SAAS,GAAG,YAAmC;AAClE,IAAA,CAAC,iBAAiB,CAAC,MAAM,GAAG,SAAgC;AAC5D,IAAA,CAAC,iBAAiB,CAAC,KAAK,GAAG,QAA+B;AAC1D,IAAA,CAAC,iBAAiB,CAAC,QAAQ,GAAG,WAAkC;;;;;"}
@@ -1,3 +1,20 @@
1
+ import Supercluster, { ClusterFeature, PointFeature } from 'supercluster';
1
2
  import { NumericAccessor } from "../../types/accessor";
3
+ import { GenericDataRecord } from "../../types/data";
4
+ import { TopoJSONMapPieDatum, TopoJSONMapPointStyles, TopoJSONMapPointShape, TopoJSONMapPoint, TopoJSONMapPointDatum, TopoJSONMapClusterDatum } from './types';
5
+ import { TopoJSONMapConfigInterface } from './config';
2
6
  export declare function getLonLat<Datum>(d: Datum, pointLongitude: NumericAccessor<Datum>, pointLatitude: NumericAccessor<Datum>): [number, number];
3
7
  export declare function arc(source?: number[], target?: number[], curvature?: number): string;
8
+ export declare function getPointPathData({ x, y }: {
9
+ x: number;
10
+ y: number;
11
+ }, radius: number, shape: TopoJSONMapPointShape): string;
12
+ export declare function getDonutData<PointDatum>(d: PointDatum, colorMap: TopoJSONMapPointStyles<PointDatum>): TopoJSONMapPieDatum[];
13
+ export declare function getAggregatedClusterDonutData<D extends GenericDataRecord>(clusterPoint: ClusterFeature<TopoJSONMapClusterDatum<D>>, colorMap: TopoJSONMapPointStyles<D>): TopoJSONMapPieDatum[];
14
+ export declare function toGeoJSONPoint<D extends GenericDataRecord>(d: D, i: number, pointLatitude: NumericAccessor<D>, pointLongitude: NumericAccessor<D>): PointFeature<D>;
15
+ export declare function calculateClusterIndex<D extends GenericDataRecord>(data: D[], config: TopoJSONMapConfigInterface<any, D, any>, maxClusterZoomLevel?: number): Supercluster<D>;
16
+ export declare function getPointRadius<D extends GenericDataRecord>(geoPoint: ClusterFeature<TopoJSONMapClusterDatum<D>> | PointFeature<TopoJSONMapPointDatum<D>>, pointRadius: NumericAccessor<D>, zoomLevel: number): number;
17
+ export declare function geoJsonPointToScreenPoint<D extends GenericDataRecord>(geoPoint: ClusterFeature<TopoJSONMapClusterDatum<D>> | PointFeature<TopoJSONMapPointDatum<D>>, i: number, projection: (coordinates: [number, number]) => [number, number], config: TopoJSONMapConfigInterface<any, D, any>, zoomLevel: number): TopoJSONMapPoint<D>;
18
+ export declare function getClustersAndPoints<D extends GenericDataRecord>(clusterIndex: Supercluster<D>, bounds: [number, number, number, number], zoom: number): (ClusterFeature<TopoJSONMapClusterDatum<D>> | PointFeature<D>)[];
19
+ export declare function shouldClusterExpand<D extends GenericDataRecord>(cluster: TopoJSONMapPoint<D>, zoomLevel: number, midLevel?: number, maxLevel?: number, maxClusterZoomLevel?: number): boolean;
20
+ export declare const getNextZoomLevelOnClusterClick: (level: number) => number;
@@ -1,4 +1,9 @@
1
- import { getNumber } from '../../utils/data.js';
1
+ import { max } from 'd3-array';
2
+ import Supercluster from 'supercluster';
3
+ import { getNumber, getString, clamp } from '../../utils/data.js';
4
+ import { getColor } from '../../utils/color.js';
5
+ import { circlePath, polygon } from '../../utils/path.js';
6
+ import { TopoJSONMapPointShape } from './types.js';
2
7
 
3
8
  function getLonLat(d, pointLongitude, pointLatitude) {
4
9
  const lat = getNumber(d, pointLatitude);
@@ -24,7 +29,176 @@ function arc(source, target, curvature) {
24
29
  const dds = { x: (cs * ds.x) - (ss * ds.y), y: (ss * ds.x) + (cs * ds.y) };
25
30
  const ddt = { x: (ct * dt.x) - (st * dt.y), y: (st * dt.x) + (ct * dt.y) };
26
31
  return `M${s.x},${s.y} C${s.x + dds.x},${s.y + dds.y} ${t.x + ddt.x},${t.y + ddt.y} ${t.x},${t.y}`;
27
- }
32
+ }
33
+ function getPointPathData({ x, y }, radius, shape) {
34
+ switch (shape) {
35
+ case TopoJSONMapPointShape.Triangle:
36
+ return polygon(radius * 2, 3);
37
+ case TopoJSONMapPointShape.Square:
38
+ return polygon(radius * 2, 4);
39
+ case TopoJSONMapPointShape.Circle:
40
+ case TopoJSONMapPointShape.Ring:
41
+ default:
42
+ return circlePath(x, y, radius);
43
+ }
44
+ }
45
+ function getDonutData(d, colorMap) {
46
+ if (!colorMap || Object.keys(colorMap).length === 0) {
47
+ return [];
48
+ }
49
+ return Object.keys(colorMap).map(key => {
50
+ const keyTyped = key;
51
+ const config = colorMap[keyTyped];
52
+ const value = d[key] || 0;
53
+ return {
54
+ name: key,
55
+ value,
56
+ color: (config === null || config === void 0 ? void 0 : config.color) || '#000',
57
+ className: config === null || config === void 0 ? void 0 : config.className,
58
+ };
59
+ }).filter(item => item.value > 0);
60
+ }
61
+ // Aggregate donut data from all points in a cluster
62
+ function getAggregatedClusterDonutData(clusterPoint, colorMap) {
63
+ if (!colorMap || Object.keys(colorMap).length === 0 || !clusterPoint.properties.clusterIndex) {
64
+ return [];
65
+ }
66
+ const clusterId = clusterPoint.properties.clusterId;
67
+ const clusterIndex = clusterPoint.properties.clusterIndex;
68
+ const points = clusterIndex.getLeaves(clusterId, Infinity);
69
+ // Aggregate values for each colorMap key across all points in the cluster
70
+ const aggregatedData = {};
71
+ for (const point of points) {
72
+ const pointData = point.properties;
73
+ for (const key of Object.keys(colorMap)) {
74
+ const value = pointData[key] || 0;
75
+ aggregatedData[key] = (aggregatedData[key] || 0) + value;
76
+ }
77
+ }
78
+ return Object.keys(colorMap).map(key => {
79
+ const keyTyped = key;
80
+ const config = colorMap[keyTyped];
81
+ const value = aggregatedData[key] || 0;
82
+ return {
83
+ name: key,
84
+ value,
85
+ color: (config === null || config === void 0 ? void 0 : config.color) || '#000',
86
+ className: config === null || config === void 0 ? void 0 : config.className,
87
+ };
88
+ }).filter(item => item.value > 0);
89
+ }
90
+ function toGeoJSONPoint(d, i, pointLatitude, pointLongitude) {
91
+ const lat = getNumber(d, pointLatitude);
92
+ const lon = getNumber(d, pointLongitude);
93
+ return {
94
+ type: 'Feature',
95
+ properties: Object.assign(Object.assign({}, d), { _index: i }),
96
+ geometry: {
97
+ type: 'Point',
98
+ coordinates: [lon, lat],
99
+ },
100
+ };
101
+ }
102
+ function calculateClusterIndex(data, config, maxClusterZoomLevel = 8) {
103
+ const { colorMap, pointShape, latitude, longitude, clusteringDistance } = config;
104
+ return new Supercluster({
105
+ radius: clusteringDistance,
106
+ maxZoom: maxClusterZoomLevel,
107
+ map: (d) => {
108
+ const shape = getString(d, pointShape);
109
+ const clusterPoint = { shape };
110
+ for (const key of Object.keys(colorMap || {})) {
111
+ clusterPoint[key] = d[key] || 0;
112
+ }
113
+ return clusterPoint;
114
+ },
115
+ reduce: (acc, clusterPoint) => {
116
+ var _a, _b;
117
+ acc.shape = acc.shape === clusterPoint.shape ? acc.shape : TopoJSONMapPointShape.Circle;
118
+ acc.value = ((_a = acc.value) !== null && _a !== void 0 ? _a : 0) + ((_b = clusterPoint.value) !== null && _b !== void 0 ? _b : 0);
119
+ for (const key of Object.keys(colorMap || {})) {
120
+ acc[key] += clusterPoint[key];
121
+ }
122
+ },
123
+ }).load(data.map((d, i) => toGeoJSONPoint(d, i, latitude, longitude)));
124
+ }
125
+ function getPointRadius(geoPoint, pointRadius, zoomLevel) {
126
+ const isDynamic = !pointRadius;
127
+ const radius = isDynamic
128
+ ? 1 + 2 * Math.pow(zoomLevel, 0.80)
129
+ : getNumber(geoPoint.properties, pointRadius);
130
+ const isCluster = geoPoint.properties.cluster;
131
+ return (isCluster && isDynamic)
132
+ ? Math.max(Math.pow(geoPoint.properties.point_count || geoPoint.properties.pointCount || 1, 0.35) * radius, radius * 1.1)
133
+ : radius;
134
+ }
135
+ function geoJsonPointToScreenPoint(geoPoint, i, projection, config, zoomLevel) {
136
+ var _a;
137
+ const isCluster = geoPoint.properties.cluster;
138
+ const pos = projection(geoPoint.geometry.coordinates);
139
+ const x = pos[0];
140
+ const y = pos[1];
141
+ const id = isCluster
142
+ ? `cluster-${geoPoint.id}`
143
+ : ((_a = getString(geoPoint.properties, config.pointId)) !== null && _a !== void 0 ? _a : geoPoint.geometry.coordinates.join(''));
144
+ const pointColor = getColor(geoPoint.properties, (isCluster ? config.clusterColor : config.pointColor));
145
+ const radius = isCluster
146
+ ? getPointRadius(geoPoint, config.clusterRadius, zoomLevel)
147
+ : getPointRadius(geoPoint, config.pointRadius, zoomLevel);
148
+ const shape = isCluster
149
+ ? TopoJSONMapPointShape.Circle
150
+ : (getString(geoPoint.properties, config.pointShape) || TopoJSONMapPointShape.Circle);
151
+ const isRing = shape === TopoJSONMapPointShape.Ring;
152
+ // For clusters, aggregate donut data from all points in the cluster
153
+ const donutData = isCluster
154
+ ? getAggregatedClusterDonutData(geoPoint, config.colorMap)
155
+ : getDonutData(geoPoint.properties, config.colorMap);
156
+ const maxValue = max(donutData, d => d.value);
157
+ const maxValueIndex = donutData.map(d => d.value).indexOf(maxValue || 0);
158
+ const biggestDatum = donutData[maxValueIndex !== null && maxValueIndex !== void 0 ? maxValueIndex : 0];
159
+ const color = isCluster
160
+ ? (donutData.length > 0 ? 'transparent' : pointColor) // Hide fill if cluster has donut data
161
+ : (isRing ? null : (pointColor !== null && pointColor !== void 0 ? pointColor : biggestDatum === null || biggestDatum === void 0 ? void 0 : biggestDatum.color));
162
+ const bbox = { x1: x - radius, y1: y - radius, x2: x + radius, y2: y + radius };
163
+ const path = getPointPathData({ x: 0, y: 0 }, radius, shape);
164
+ const _zIndex = 0;
165
+ const screenPoint = Object.assign(Object.assign({}, geoPoint), { id,
166
+ bbox,
167
+ radius,
168
+ donutData,
169
+ path,
170
+ color,
171
+ isCluster, clusterIndex: isCluster ? geoPoint.properties.clusterIndex : undefined, _zIndex });
172
+ return screenPoint;
173
+ }
174
+ function getClustersAndPoints(clusterIndex, bounds, zoom) {
175
+ const points = clusterIndex.getClusters(bounds, zoom);
176
+ for (const p of points) {
177
+ const point = p;
178
+ const isCluster = point.properties.cluster;
179
+ if (isCluster) {
180
+ // Supercluster uses snake_case internally, so we need to map to camelCase
181
+ const superclusterProps = point.properties;
182
+ point.properties.clusterId = superclusterProps.cluster_id;
183
+ point.properties.pointCount = superclusterProps.point_count;
184
+ point.properties.pointCountAbbreviated = superclusterProps.point_count_abbreviated;
185
+ point.properties.clusterIndex = clusterIndex;
186
+ point.properties.clusterPoints = clusterIndex.getLeaves(superclusterProps.cluster_id, Infinity).map(d => d.properties);
187
+ }
188
+ }
189
+ return points;
190
+ }
191
+ function shouldClusterExpand(cluster, zoomLevel, midLevel = 4, maxLevel = 8, maxClusterZoomLevel = 23) {
192
+ if (!cluster || !cluster.isCluster)
193
+ return false;
194
+ const clusterProps = cluster.properties;
195
+ if (!clusterProps.clusterId || !cluster.clusterIndex)
196
+ return false;
197
+ const clusterExpansionZoomLevel = cluster.clusterIndex.getClusterExpansionZoom(clusterProps.clusterId);
198
+ return zoomLevel >= maxLevel ||
199
+ (zoomLevel >= midLevel && (clusterProps.pointCount < 20 || clusterExpansionZoomLevel >= maxClusterZoomLevel));
200
+ }
201
+ const getNextZoomLevelOnClusterClick = (level) => clamp(1 + level * 1.5, level, 12);
28
202
 
29
- export { arc, getLonLat };
203
+ export { arc, calculateClusterIndex, geoJsonPointToScreenPoint, getAggregatedClusterDonutData, getClustersAndPoints, getDonutData, getLonLat, getNextZoomLevelOnClusterClick, getPointPathData, getPointRadius, shouldClusterExpand, toGeoJSONPoint };
30
204
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/components/topojson-map/utils.ts"],"sourcesContent":["import { getNumber } from 'utils/data'\n\n// Config\nimport { NumericAccessor } from 'types/accessor'\n\nexport function getLonLat<Datum> (d: Datum, pointLongitude: NumericAccessor<Datum>, pointLatitude: NumericAccessor<Datum>): [number, number] {\n const lat = getNumber(d, pointLatitude)\n const lon = getNumber(d, pointLongitude)\n return [lon, lat]\n}\n\nexport function arc (source?: number[], target?: number[], curvature?: number): string {\n if (!target || !source) return 'M0,0,l0,0z'\n const d = 3\n const angleOffset = curvature || 0\n const s = { x: source[0], y: source[1] }\n const t = { x: target[0], y: target[1] }\n const ds = { x: (t.x - s.x) / d, y: (t.y - s.y) / d }\n const dt = { x: (s.x - t.x) / d, y: (s.y - t.y) / d }\n let angle = 0.16667 * Math.PI * (1 + angleOffset)\n if (s.x < t.x) angle = -angle\n const cs = Math.cos(angle)\n const ss = Math.sin(angle)\n const ct = Math.cos(-angle)\n const st = Math.sin(-angle)\n const dds = { x: (cs * ds.x) - (ss * ds.y), y: (ss * ds.x) + (cs * ds.y) }\n const ddt = { x: (ct * dt.x) - (st * dt.y), y: (st * dt.x) + (ct * dt.y) }\n return `M${s.x},${s.y} C${s.x + dds.x},${s.y + dds.y} ${t.x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,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,CAAE,CAAA;AACpG;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/components/topojson-map/utils.ts"],"sourcesContent":["import { max } from 'd3-array'\nimport Supercluster, { ClusterFeature, PointFeature } from 'supercluster'\nimport { getNumber, getString, clamp } from 'utils/data'\nimport { getColor } from 'utils/color'\nimport { polygon, circlePath } from 'utils/path'\n\n// Config\nimport { NumericAccessor, ColorAccessor } from 'types/accessor'\nimport { GenericDataRecord } from 'types/data'\n\n// Local Types\nimport {\n TopoJSONMapPieDatum,\n TopoJSONMapPointStyles,\n TopoJSONMapPointShape,\n TopoJSONMapPoint,\n TopoJSONMapPointDatum,\n TopoJSONMapClusterDatum,\n} from './types'\n\n// Config Interface\nimport { TopoJSONMapConfigInterface } from './config'\n\nexport function getLonLat<Datum> (d: Datum, pointLongitude: NumericAccessor<Datum>, pointLatitude: NumericAccessor<Datum>): [number, number] {\n const lat = getNumber(d, pointLatitude)\n const lon = getNumber(d, pointLongitude)\n return [lon, lat]\n}\n\nexport function arc (source?: number[], target?: number[], curvature?: number): string {\n if (!target || !source) return 'M0,0,l0,0z'\n const d = 3\n const angleOffset = curvature || 0\n const s = { x: source[0], y: source[1] }\n const t = { x: target[0], y: target[1] }\n const ds = { x: (t.x - s.x) / d, y: (t.y - s.y) / d }\n const dt = { x: (s.x - t.x) / d, y: (s.y - t.y) / d }\n let angle = 0.16667 * Math.PI * (1 + angleOffset)\n if (s.x < t.x) angle = -angle\n const cs = Math.cos(angle)\n const ss = Math.sin(angle)\n const ct = Math.cos(-angle)\n const st = Math.sin(-angle)\n const dds = { x: (cs * ds.x) - (ss * ds.y), y: (ss * ds.x) + (cs * ds.y) }\n const ddt = { x: (ct * dt.x) - (st * dt.y), y: (st * dt.x) + (ct * dt.y) }\n return `M${s.x},${s.y} C${s.x + dds.x},${s.y + dds.y} ${t.x + ddt.x},${t.y + ddt.y} ${t.x},${t.y}`\n}\n\nexport function getPointPathData ({ x, y }: { x: number; y: number }, radius: number, shape: TopoJSONMapPointShape): string {\n switch (shape) {\n case TopoJSONMapPointShape.Triangle:\n return polygon(radius * 2, 3)\n case TopoJSONMapPointShape.Square:\n return polygon(radius * 2, 4)\n case TopoJSONMapPointShape.Circle:\n case TopoJSONMapPointShape.Ring:\n default:\n return circlePath(x, y, radius)\n }\n}\n\nexport function getDonutData<PointDatum> (\n d: PointDatum,\n colorMap: TopoJSONMapPointStyles<PointDatum>\n): TopoJSONMapPieDatum[] {\n if (!colorMap || Object.keys(colorMap).length === 0) {\n return []\n }\n\n return Object.keys(colorMap).map(key => {\n const keyTyped = key as keyof PointDatum\n const config = colorMap[keyTyped]\n const value = (d as any)[key] as number || 0\n return {\n name: key,\n value,\n color: config?.color || '#000',\n className: config?.className,\n }\n }).filter(item => item.value > 0)\n}\n\n// Aggregate donut data from all points in a cluster\nexport function getAggregatedClusterDonutData<D extends GenericDataRecord> (\n clusterPoint: ClusterFeature<TopoJSONMapClusterDatum<D>>,\n colorMap: TopoJSONMapPointStyles<D>\n): TopoJSONMapPieDatum[] {\n if (!colorMap || Object.keys(colorMap).length === 0 || !clusterPoint.properties.clusterIndex) {\n return []\n }\n\n const clusterId = clusterPoint.properties.clusterId\n const clusterIndex = clusterPoint.properties.clusterIndex\n const points = clusterIndex.getLeaves(clusterId, Infinity)\n\n // Aggregate values for each colorMap key across all points in the cluster\n const aggregatedData: { [key: string]: number } = {}\n\n for (const point of points) {\n const pointData = point.properties as D\n for (const key of Object.keys(colorMap)) {\n const value = (pointData as any)[key] as number || 0\n aggregatedData[key] = (aggregatedData[key] || 0) + value\n }\n }\n\n return Object.keys(colorMap).map(key => {\n const keyTyped = key as keyof D\n const config = colorMap[keyTyped]\n const value = aggregatedData[key] || 0\n\n return {\n name: key,\n value,\n color: config?.color || '#000',\n className: config?.className,\n }\n }).filter(item => item.value > 0)\n}\n\nexport function toGeoJSONPoint<D extends GenericDataRecord> (\n d: D,\n i: number,\n pointLatitude: NumericAccessor<D>,\n pointLongitude: NumericAccessor<D>\n): PointFeature<D> {\n const lat = getNumber(d, pointLatitude) as number\n const lon = getNumber(d, pointLongitude) as number\n\n return {\n type: 'Feature',\n properties: {\n ...d,\n _index: i,\n },\n geometry: {\n type: 'Point',\n coordinates: [lon, lat],\n },\n }\n}\n\nexport function calculateClusterIndex<D extends GenericDataRecord> (\n data: D[],\n config: TopoJSONMapConfigInterface<any, D, any>,\n maxClusterZoomLevel = 8\n): Supercluster<D> {\n const { colorMap, pointShape, latitude, longitude, clusteringDistance } = config\n return new Supercluster<D, Supercluster.AnyProps>({\n radius: clusteringDistance,\n maxZoom: maxClusterZoomLevel,\n map: (d): Supercluster.AnyProps => {\n const shape = getString(d, pointShape)\n\n const clusterPoint = { shape } as Supercluster.AnyProps\n for (const key of Object.keys(colorMap || {})) {\n clusterPoint[key] = d[key] || 0\n }\n\n return clusterPoint\n },\n reduce: (acc, clusterPoint): void => {\n acc.shape = acc.shape === clusterPoint.shape ? acc.shape : TopoJSONMapPointShape.Circle\n acc.value = (acc.value ?? 0) + (clusterPoint.value ?? 0)\n\n for (const key of Object.keys(colorMap || {})) {\n acc[key] += clusterPoint[key]\n }\n },\n }).load(data.map((d, i) => toGeoJSONPoint(d, i, latitude, longitude)))\n}\n\nexport function getPointRadius<D extends GenericDataRecord> (\n geoPoint: ClusterFeature<TopoJSONMapClusterDatum<D>> | PointFeature<TopoJSONMapPointDatum<D>>,\n pointRadius: NumericAccessor<D>,\n zoomLevel: number\n): number {\n const isDynamic = !pointRadius\n const radius = isDynamic\n ? 1 + 2 * Math.pow(zoomLevel, 0.80)\n : getNumber(geoPoint.properties as D, pointRadius)\n\n const isCluster = (geoPoint as ClusterFeature<TopoJSONMapClusterDatum<D>>).properties.cluster\n return (isCluster && isDynamic)\n ? Math.max(\n Math.pow((geoPoint as any).properties.point_count || (geoPoint as ClusterFeature<TopoJSONMapClusterDatum<D>>).properties.pointCount || 1, 0.35) * radius,\n radius * 1.1\n )\n : radius\n}\n\nexport function geoJsonPointToScreenPoint<D extends GenericDataRecord> (\n geoPoint: ClusterFeature<TopoJSONMapClusterDatum<D>> | PointFeature<TopoJSONMapPointDatum<D>>,\n i: number,\n projection: (coordinates: [number, number]) => [number, number],\n config: TopoJSONMapConfigInterface<any, D, any>,\n zoomLevel: number\n): TopoJSONMapPoint<D> {\n const isCluster = (geoPoint.properties as TopoJSONMapClusterDatum<D>).cluster\n const pos = projection(geoPoint.geometry.coordinates as [number, number])\n const x = pos[0]\n const y = pos[1]\n\n const id = isCluster\n ? `cluster-${geoPoint.id}`\n : (getString(geoPoint.properties as D, config.pointId) ?? geoPoint.geometry.coordinates.join(''))\n\n const pointColor = getColor(\n geoPoint.properties as D,\n (isCluster ? config.clusterColor : config.pointColor) as ColorAccessor<D>\n )\n\n const radius = isCluster\n ? getPointRadius(geoPoint as ClusterFeature<TopoJSONMapClusterDatum<D>>, config.clusterRadius as NumericAccessor<TopoJSONMapClusterDatum<D>>, zoomLevel)\n : getPointRadius(geoPoint as PointFeature<TopoJSONMapPointDatum<D>>, config.pointRadius as NumericAccessor<D>, zoomLevel)\n const shape = isCluster\n ? TopoJSONMapPointShape.Circle\n : (getString(geoPoint.properties as D, config.pointShape) as TopoJSONMapPointShape || TopoJSONMapPointShape.Circle)\n const isRing = shape === TopoJSONMapPointShape.Ring\n\n // For clusters, aggregate donut data from all points in the cluster\n const donutData = isCluster\n ? getAggregatedClusterDonutData(geoPoint as ClusterFeature<TopoJSONMapClusterDatum<D>>, config.colorMap)\n : getDonutData(geoPoint.properties, config.colorMap)\n const maxValue = max(donutData, d => d.value)\n const maxValueIndex = donutData.map(d => d.value).indexOf(maxValue || 0)\n const biggestDatum = donutData[maxValueIndex ?? 0]\n\n const color = isCluster\n ? (donutData.length > 0 ? 'transparent' : pointColor) // Hide fill if cluster has donut data\n : (isRing ? null : (pointColor ?? biggestDatum?.color))\n\n const bbox = { x1: x - radius, y1: y - radius, x2: x + radius, y2: y + radius }\n const path = getPointPathData({ x: 0, y: 0 }, radius, shape)\n const _zIndex = 0\n\n const screenPoint: TopoJSONMapPoint<D> = {\n ...geoPoint,\n id,\n bbox,\n radius,\n donutData,\n path,\n color,\n isCluster,\n clusterIndex: isCluster ? (geoPoint.properties as TopoJSONMapClusterDatum<D>).clusterIndex : undefined,\n _zIndex,\n }\n\n return screenPoint\n}\n\nexport function getClustersAndPoints<D extends GenericDataRecord> (\n clusterIndex: Supercluster<D>,\n bounds: [number, number, number, number],\n zoom: number\n): (ClusterFeature<TopoJSONMapClusterDatum<D>> | PointFeature<D>)[] {\n const points = clusterIndex.getClusters(bounds, zoom)\n\n for (const p of points) {\n const point = p as ClusterFeature<TopoJSONMapClusterDatum<D>>\n const isCluster = point.properties.cluster\n if (isCluster) {\n // Supercluster uses snake_case internally, so we need to map to camelCase\n const superclusterProps = point.properties as any\n point.properties.clusterId = superclusterProps.cluster_id\n point.properties.pointCount = superclusterProps.point_count\n point.properties.pointCountAbbreviated = superclusterProps.point_count_abbreviated\n point.properties.clusterIndex = clusterIndex\n point.properties.clusterPoints = clusterIndex.getLeaves(superclusterProps.cluster_id as number, Infinity).map(d => d.properties)\n }\n }\n\n return points as (ClusterFeature<TopoJSONMapClusterDatum<D>> | PointFeature<D>)[]\n}\n\nexport function shouldClusterExpand<D extends GenericDataRecord> (\n cluster: TopoJSONMapPoint<D>,\n zoomLevel: number,\n midLevel = 4,\n maxLevel = 8,\n maxClusterZoomLevel = 23\n): boolean {\n if (!cluster || !cluster.isCluster) return false\n\n const clusterProps = cluster.properties as TopoJSONMapClusterDatum<D>\n if (!clusterProps.clusterId || !cluster.clusterIndex) return false\n\n const clusterExpansionZoomLevel = cluster.clusterIndex.getClusterExpansionZoom(clusterProps.clusterId as number)\n return zoomLevel >= maxLevel ||\n (zoomLevel >= midLevel && (clusterProps.pointCount < 20 || clusterExpansionZoomLevel >= maxClusterZoomLevel))\n}\n\nexport const getNextZoomLevelOnClusterClick = (level: number): number => clamp(1 + level * 1.5, level, 12)\n"],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CAAC,qBAAqB,GAAG,iBAAiB,CAAC,uBAAuB,CAAA;AAClF,YAAA,KAAK,CAAC,UAAU,CAAC,YAAY,GAAG,YAAY,CAAA;YAC5C,KAAK,CAAC,UAAU,CAAC,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC,UAAoB,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAA;AACjI,SAAA;AACF,KAAA;AAED,IAAA,OAAO,MAA0E,CAAA;AACnF,CAAC;SAEe,mBAAmB,CACjC,OAA4B,EAC5B,SAAiB,EACjB,QAAQ,GAAG,CAAC,EACZ,QAAQ,GAAG,CAAC,EACZ,mBAAmB,GAAG,EAAE,EAAA;AAExB,IAAA,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS;AAAE,QAAA,OAAO,KAAK,CAAA;AAEhD,IAAA,MAAM,YAAY,GAAG,OAAO,CAAC,UAAwC,CAAA;IACrE,IAAI,CAAC,YAAY,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,YAAY;AAAE,QAAA,OAAO,KAAK,CAAA;AAElE,IAAA,MAAM,yBAAyB,GAAG,OAAO,CAAC,YAAY,CAAC,uBAAuB,CAAC,YAAY,CAAC,SAAmB,CAAC,CAAA;IAChH,OAAO,SAAS,IAAI,QAAQ;AACtB,SAAC,SAAS,IAAI,QAAQ,KAAK,YAAY,CAAC,UAAU,GAAG,EAAE,IAAI,yBAAyB,IAAI,mBAAmB,CAAC,CAAC,CAAA;AACrH,CAAC;MAEY,8BAA8B,GAAG,CAAC,KAAa,KAAa,KAAK,CAAC,CAAC,GAAG,KAAK,GAAG,GAAG,EAAE,KAAK,EAAE,EAAE;;;;"}
package/components.d.ts CHANGED
@@ -47,6 +47,8 @@ export type { TimelineConfigInterface } from './components/timeline/config';
47
47
  export type { SankeyConfigInterface } from './components/sankey/config';
48
48
  export type { AreaConfigInterface } from './components/area/config';
49
49
  export type { TopoJSONMapConfigInterface } from './components/topojson-map/config';
50
+ export type { TopoJSONMapPieDatum, TopoJSONMapPointStyle, TopoJSONMapPointStyles, TopoJSONMapPoint, TopoJSONMapPointDatum, TopoJSONMapClusterDatum, MapPointLabelPosition, MapData, MapFeature, } from './components/topojson-map/types';
51
+ export { TopoJSONMapPointShape } from './components/topojson-map/types';
50
52
  export type { LeafletMapConfigInterface } from './components/leaflet-map/config';
51
53
  export type { LeafletFlowMapConfigInterface } from './components/leaflet-flow-map/config';
52
54
  export type { ChordDiagramConfigInterface } from './components/chord-diagram/config';
package/components.js CHANGED
@@ -30,6 +30,7 @@ export { Plotband } from './components/plotband/index.js';
30
30
  export { Plotline } from './components/plotline/index.js';
31
31
  export { Treemap } from './components/treemap/index.js';
32
32
  export { DONUT_HALF_ANGLE_RANGES, DONUT_HALF_ANGLE_RANGE_BOTTOM, DONUT_HALF_ANGLE_RANGE_LEFT, DONUT_HALF_ANGLE_RANGE_RIGHT, DONUT_HALF_ANGLE_RANGE_TOP } from './components/donut/constants.js';
33
+ export { TopoJSONMapPointShape } from './components/topojson-map/types.js';
33
34
 
34
35
  // Core
35
36
  //# sourceMappingURL=components.js.map
package/components.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../src/components.ts"],"sourcesContent":["// Core\nexport { ComponentCore } from 'core/component'\nexport type { ComponentConfigInterface } from 'core/component/config'\nexport { XYComponentCore } from 'core/xy-component'\nexport type { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Components\nexport { Tooltip } from './components/tooltip'\nexport { Line } from './components/line'\nexport { StackedBar } from './components/stacked-bar'\nexport { GroupedBar } from './components/grouped-bar'\nexport { Axis } from './components/axis'\nexport { Scatter } from './components/scatter'\nexport { Brush } from './components/brush'\nexport { BulletLegend } from './components/bullet-legend'\nexport { RollingPinLegend } from './components/rolling-pin-legend'\nexport { FlowLegend } from './components/flow-legend'\nexport { Crosshair } from './components/crosshair'\nexport { Timeline } from './components/timeline'\nexport { Sankey } from './components/sankey'\nexport { Area } from './components/area'\nexport { TopoJSONMap } from './components/topojson-map'\nexport { LeafletMap } from './components/leaflet-map'\nexport { MapLibreArcticDark, MapLibreArcticLight } from './components/leaflet-map/renderer/map-style'\nexport { LeafletFlowMap } from './components/leaflet-flow-map'\nexport { ChordDiagram } from './components/chord-diagram'\nexport { Graph } from './components/graph'\nexport { VisControls } from './components/vis-controls'\nexport { Donut } from './components/donut'\nexport { FreeBrush } from './components/free-brush'\nexport { XYLabels } from './components/xy-labels'\nexport { NestedDonut } from './components/nested-donut'\nexport { Annotations } from './components/annotations'\nexport { Plotband } from './components/plotband'\nexport { Plotline } from './components/plotline'\nexport { Treemap } from './components/treemap'\n\n// Constants\nexport * from './components/donut/constants'\n\n// Config Interfaces\nexport type { LineConfigInterface } from './components/line/config'\nexport type { StackedBarConfigInterface } from './components/stacked-bar/config'\nexport type { GroupedBarConfigInterface } from './components/grouped-bar/config'\nexport type { ScatterConfigInterface } from './components/scatter/config'\nexport type { TooltipConfigInterface } from './components/tooltip/config'\nexport type { BrushConfigInterface } from './components/brush/config'\nexport type { AxisConfigInterface } from './components/axis/config'\nexport type { BulletLegendConfigInterface } from './components/bullet-legend/config'\nexport type { RollingPinLegendConfigInterface } from './components/rolling-pin-legend/config'\nexport type { FlowLegendConfigInterface } from './components/flow-legend/config'\nexport type { CrosshairConfigInterface } from './components/crosshair/config'\nexport type { TimelineConfigInterface } from './components/timeline/config'\nexport type { SankeyConfigInterface } from './components/sankey/config'\nexport type { AreaConfigInterface } from './components/area/config'\nexport type { TopoJSONMapConfigInterface } from './components/topojson-map/config'\nexport type { LeafletMapConfigInterface } from './components/leaflet-map/config'\nexport type { LeafletFlowMapConfigInterface } from './components/leaflet-flow-map/config'\nexport type { ChordDiagramConfigInterface } from './components/chord-diagram/config'\nexport type { GraphConfigInterface } from './components/graph/config'\nexport type { VisControlsConfigInterface } from './components/vis-controls/config'\nexport type { DonutConfigInterface } from './components/donut/config'\nexport type { FreeBrushConfigInterface } from './components/free-brush/config'\nexport type { XYLabelsConfigInterface } from './components/xy-labels/config'\nexport type { NestedDonutConfigInterface } from './components/nested-donut/config'\nexport type { AnnotationsConfigInterface } from './components/annotations/config'\nexport type { PlotbandConfigInterface } from './components/plotband/config'\nexport type { PlotlineConfigInterface } from './components/plotline/config'\nexport type { TreemapConfigInterface } from './components/treemap/config'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
1
+ {"version":3,"file":"components.js","sources":["../src/components.ts"],"sourcesContent":["// Core\nexport { ComponentCore } from 'core/component'\nexport type { ComponentConfigInterface } from 'core/component/config'\nexport { XYComponentCore } from 'core/xy-component'\nexport type { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Components\nexport { Tooltip } from './components/tooltip'\nexport { Line } from './components/line'\nexport { StackedBar } from './components/stacked-bar'\nexport { GroupedBar } from './components/grouped-bar'\nexport { Axis } from './components/axis'\nexport { Scatter } from './components/scatter'\nexport { Brush } from './components/brush'\nexport { BulletLegend } from './components/bullet-legend'\nexport { RollingPinLegend } from './components/rolling-pin-legend'\nexport { FlowLegend } from './components/flow-legend'\nexport { Crosshair } from './components/crosshair'\nexport { Timeline } from './components/timeline'\nexport { Sankey } from './components/sankey'\nexport { Area } from './components/area'\nexport { TopoJSONMap } from './components/topojson-map'\nexport { LeafletMap } from './components/leaflet-map'\nexport { MapLibreArcticDark, MapLibreArcticLight } from './components/leaflet-map/renderer/map-style'\nexport { LeafletFlowMap } from './components/leaflet-flow-map'\nexport { ChordDiagram } from './components/chord-diagram'\nexport { Graph } from './components/graph'\nexport { VisControls } from './components/vis-controls'\nexport { Donut } from './components/donut'\nexport { FreeBrush } from './components/free-brush'\nexport { XYLabels } from './components/xy-labels'\nexport { NestedDonut } from './components/nested-donut'\nexport { Annotations } from './components/annotations'\nexport { Plotband } from './components/plotband'\nexport { Plotline } from './components/plotline'\nexport { Treemap } from './components/treemap'\n\n// Constants\nexport * from './components/donut/constants'\n\n// Config Interfaces\nexport type { LineConfigInterface } from './components/line/config'\nexport type { StackedBarConfigInterface } from './components/stacked-bar/config'\nexport type { GroupedBarConfigInterface } from './components/grouped-bar/config'\nexport type { ScatterConfigInterface } from './components/scatter/config'\nexport type { TooltipConfigInterface } from './components/tooltip/config'\nexport type { BrushConfigInterface } from './components/brush/config'\nexport type { AxisConfigInterface } from './components/axis/config'\nexport type { BulletLegendConfigInterface } from './components/bullet-legend/config'\nexport type { RollingPinLegendConfigInterface } from './components/rolling-pin-legend/config'\nexport type { FlowLegendConfigInterface } from './components/flow-legend/config'\nexport type { CrosshairConfigInterface } from './components/crosshair/config'\nexport type { TimelineConfigInterface } from './components/timeline/config'\nexport type { SankeyConfigInterface } from './components/sankey/config'\nexport type { AreaConfigInterface } from './components/area/config'\nexport type { TopoJSONMapConfigInterface } from './components/topojson-map/config'\n\n// Types\nexport type {\n TopoJSONMapPieDatum,\n TopoJSONMapPointStyle,\n TopoJSONMapPointStyles,\n TopoJSONMapPoint,\n TopoJSONMapPointDatum,\n TopoJSONMapClusterDatum,\n MapPointLabelPosition,\n MapData,\n MapFeature,\n} from './components/topojson-map/types'\nexport { TopoJSONMapPointShape } from './components/topojson-map/types'\nexport type { LeafletMapConfigInterface } from './components/leaflet-map/config'\nexport type { LeafletFlowMapConfigInterface } from './components/leaflet-flow-map/config'\nexport type { ChordDiagramConfigInterface } from './components/chord-diagram/config'\nexport type { GraphConfigInterface } from './components/graph/config'\nexport type { VisControlsConfigInterface } from './components/vis-controls/config'\nexport type { DonutConfigInterface } from './components/donut/config'\nexport type { FreeBrushConfigInterface } from './components/free-brush/config'\nexport type { XYLabelsConfigInterface } from './components/xy-labels/config'\nexport type { NestedDonutConfigInterface } from './components/nested-donut/config'\nexport type { AnnotationsConfigInterface } from './components/annotations/config'\nexport type { PlotbandConfigInterface } from './components/plotband/config'\nexport type { PlotlineConfigInterface } from './components/plotline/config'\nexport type { TreemapConfigInterface } from './components/treemap/config'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
@@ -2,6 +2,7 @@ import { ContainerConfigInterface } from "../../core/container/config";
2
2
  import { ComponentCore } from "../../core/component";
3
3
  import { Tooltip } from "../../components/tooltip";
4
4
  import { Annotations } from "../../components/annotations";
5
+ import { Spacing } from "../../types/spacing";
5
6
  export interface SingleContainerConfigInterface<Datum> extends ContainerConfigInterface {
6
7
  /** Visualization component. Default: `undefined` */
7
8
  component?: ComponentCore<Datum>;
@@ -9,5 +10,7 @@ export interface SingleContainerConfigInterface<Datum> extends ContainerConfigIn
9
10
  tooltip?: Tooltip;
10
11
  /** Annotations component. Default: `undefined` */
11
12
  annotations?: Annotations | undefined;
13
+ /** Callback function to be called when the chart rendering is complete. Default: `undefined` */
14
+ onRenderComplete?: (svgNode: SVGSVGElement, margin: Spacing, containerWidth: number, containerHeight: number, componentWidth: number, componentHeight: number) => void;
12
15
  }
13
16
  export declare const SingleContainerDefaultConfig: SingleContainerConfigInterface<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/containers/single-container/config.ts"],"sourcesContent":["// Core\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\nimport { ComponentCore } from 'core/component'\nimport { Tooltip } from 'components/tooltip'\nimport { Annotations } from 'components/annotations'\n\nexport interface SingleContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** Visualization component. Default: `undefined` */\n component?: ComponentCore<Datum>;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n}\n\nexport const SingleContainerDefaultConfig: SingleContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n tooltip: undefined,\n annotations: undefined,\n}\n"],"names":[],"mappings":";;AAAA;AAeO,MAAM,4BAA4B,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACpC,sBAAsB,CACzB,EAAA,EAAA,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,SAAS;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/containers/single-container/config.ts"],"sourcesContent":["// Core\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\nimport { ComponentCore } from 'core/component'\nimport { Tooltip } from 'components/tooltip'\nimport { Annotations } from 'components/annotations'\n\n// Types\nimport { Spacing } from 'types/spacing'\n\nexport interface SingleContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** Visualization component. Default: `undefined` */\n component?: ComponentCore<Datum>;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n /** Callback function to be called when the chart rendering is complete. Default: `undefined` */\n onRenderComplete?: (\n svgNode: SVGSVGElement,\n margin: Spacing,\n containerWidth: number,\n containerHeight: number,\n componentWidth: number,\n componentHeight: number,\n ) => void;\n}\n\nexport const SingleContainerDefaultConfig: SingleContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n tooltip: undefined,\n annotations: undefined,\n}\n"],"names":[],"mappings":";;AAAA;AA2BO,MAAM,4BAA4B,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACpC,sBAAsB,CACzB,EAAA,EAAA,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,SAAS;;;;"}
@@ -85,7 +85,7 @@ class SingleContainer extends ContainerCore {
85
85
  (_b = this.config.annotations) === null || _b === void 0 ? void 0 : _b.setContainerMargin(this.config.margin);
86
86
  }
87
87
  _render(duration) {
88
- var _a;
88
+ var _a, _b;
89
89
  const { config, component } = this;
90
90
  super._render(duration);
91
91
  component.g.attr('transform', `translate(${config.margin.left},${config.margin.top})`);
@@ -93,6 +93,7 @@ class SingleContainer extends ContainerCore {
93
93
  (_a = config.annotations) === null || _a === void 0 ? void 0 : _a.render(duration);
94
94
  if (config.tooltip)
95
95
  config.tooltip.update();
96
+ (_b = config.onRenderComplete) === null || _b === void 0 ? void 0 : _b.call(config, this.svg.node(), config.margin, this.containerWidth, this.containerHeight, this.width, this.height);
96
97
  }
97
98
  // Re-defining the `render()` function to handle different sizing techniques (`Sizing.Extend` and `Sizing.FitWidth`)
98
99
  // Not calling `super.render()` because we don't want it to interfere with setting the SVG size here.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/containers/single-container/index.ts"],"sourcesContent":["// Global CSS variables (side effects import)\nimport 'styles/index'\n\n// Core\nimport { ContainerCore } from 'core/container'\nimport { ComponentCore } from 'core/component'\nimport { ComponentConfigInterface } from 'core/component/config'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Sizing, ExtendedSizeComponent } from 'types/component'\n\n// Config\nimport { SingleContainerDefaultConfig, SingleContainerConfigInterface } from './config'\n\nexport class SingleContainer<Data> extends ContainerCore {\n protected _defaultConfig = SingleContainerDefaultConfig as SingleContainerConfigInterface<Data>\n public component: ComponentCore<Data>\n public config: SingleContainerConfigInterface<Data> = this._defaultConfig\n\n constructor (element: HTMLElement, config?: SingleContainerConfigInterface<Data>, data?: Data) {\n super(element)\n\n if (config) {\n this.updateContainer(config, true)\n this.component = config.component\n }\n\n if (data) {\n this.setData(data, true)\n }\n\n // Render if component exists and has data\n if (this.component?.datamodel.data) this.render()\n }\n\n public setData (data: Data, preventRender?: boolean): void {\n const { config } = this\n\n if (this.component) this.component.setData(data)\n if (!preventRender) this.render()\n config.tooltip?.hide()\n }\n\n public updateContainer (containerConfig: SingleContainerConfigInterface<Data>, preventRender?: boolean): void {\n super.updateContainer(containerConfig)\n this._removeAllChildren()\n\n this.component = containerConfig.component\n if (containerConfig.sizing) this.component.sizing = containerConfig.sizing\n this.element.appendChild(this.component.element)\n\n const tooltip = containerConfig.tooltip\n if (tooltip) {\n if (!tooltip.hasContainer()) tooltip.setContainer(this._container)\n tooltip.setComponents([this.component])\n }\n\n const annotations = containerConfig.annotations\n if (annotations) {\n this.element.appendChild(annotations.element)\n }\n\n // Defs\n this.element.appendChild(this._svgDefs.node())\n this.element.appendChild(this._svgDefsExternal.node())\n\n if (!preventRender) this.render()\n }\n\n public updateComponent (componentConfig: ComponentConfigInterface, preventRender?: boolean): void {\n this.component.setConfig(componentConfig)\n if (!preventRender) this.render()\n }\n\n public update (\n containerConfig: SingleContainerConfigInterface<Data>,\n componentConfig?: ComponentConfigInterface,\n data?: Data\n ): void {\n if (containerConfig) this.updateContainer(containerConfig, true)\n if (componentConfig) this.updateComponent(componentConfig, true)\n if (data) this.setData(data, true)\n this.render()\n }\n\n public getFitWidthScale (): number {\n const { config, component } = this\n\n const extendedSizeComponent = component as ExtendedSizeComponent\n if (!extendedSizeComponent.getWidth) return 1\n\n const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right\n return this.width / componentWidth\n }\n\n protected _preRender (): void {\n super._preRender()\n this.component.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n this.component.setContainerMargin(this.config.margin)\n this.config.annotations?.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n this.config.annotations?.setContainerMargin(this.config.margin)\n }\n\n protected _render (duration?: number): void {\n const { config, component } = this\n super._render(duration)\n\n component.g.attr('transform', `translate(${config.margin.left},${config.margin.top})`)\n component.render(duration)\n config.annotations?.render(duration)\n\n if (config.tooltip) config.tooltip.update()\n }\n\n // Re-defining the `render()` function to handle different sizing techniques (`Sizing.Extend` and `Sizing.FitWidth`)\n // Not calling `super.render()` because we don't want it to interfere with setting the SVG size here.\n public render (duration = this.config.duration): void {\n const { config, component } = this\n\n if (config.sizing === Sizing.Extend || config.sizing === Sizing.FitWidth) {\n const fitToWidth = config.sizing === Sizing.FitWidth\n const extendedSizeComponent = component as ExtendedSizeComponent\n\n const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right\n const componentHeight = extendedSizeComponent.getHeight() + config.margin.top + config.margin.bottom\n const scale = fitToWidth ? this.getFitWidthScale() : 1\n\n const currentWidth = this.svg.attr('width')\n const currentHeight = this.svg.attr('height')\n const scaledWidth = componentWidth * scale\n const scaledHeight = componentHeight * scale\n const animated = currentWidth || currentHeight\n\n smartTransition(this.svg, animated ? duration : 0)\n .attr('width', scaledWidth)\n .attr('height', scaledHeight)\n .attr('viewBox', `${0} ${0} ${componentWidth} ${fitToWidth ? scaledHeight : componentHeight}`)\n .attr('preserveAspectRatio', 'xMinYMin')\n } else {\n this.svg\n .attr('width', this.config.width || this.containerWidth)\n .attr('height', this.config.height || this.containerHeight)\n }\n\n // Set up Resize Observer\n if (!this._resizeObserver) this._setUpResizeObserver()\n\n // Schedule the actual rendering in the next frame\n cancelAnimationFrame(this._renderAnimationFrameId)\n this._renderAnimationFrameId = requestAnimationFrame(() => {\n this._preRender()\n this._render(duration)\n })\n }\n\n protected _onResize (): void {\n const { config } = this\n super._onResize()\n config.tooltip?.hide()\n }\n\n public destroy (): void {\n const { component, config } = this\n super.destroy()\n\n component?.destroy()\n config.tooltip?.destroy()\n config.annotations?.destroy()\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;AAiBM,MAAO,eAAsB,SAAQ,aAAa,CAAA;AAKtD,IAAA,WAAA,CAAa,OAAoB,EAAE,MAA6C,EAAE,IAAW,EAAA;;QAC3F,KAAK,CAAC,OAAO,CAAC,CAAA;QALN,IAAc,CAAA,cAAA,GAAG,4BAAoE,CAAA;AAExF,QAAA,IAAA,CAAA,MAAM,GAAyC,IAAI,CAAC,cAAc,CAAA;AAKvE,QAAA,IAAI,MAAM,EAAE;AACV,YAAA,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAClC,YAAA,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;AAClC,SAAA;AAED,QAAA,IAAI,IAAI,EAAE;AACR,YAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACzB,SAAA;;AAGD,QAAA,IAAI,MAAA,IAAI,CAAC,SAAS,MAAE,IAAA,IAAA,EAAA,KAAA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M,OAAO,GAAA;;AACZ,QAAA,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QAClC,KAAK,CAAC,OAAO,EAAE,CAAA;AAEf,QAAA,SAAS,aAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,EAAE,CAAA;AACpB,QAAA,CAAA,EAAA,GAAA,MAAM,CAAC,OAAO,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;AACzB,QAAA,CAAA,EAAA,GAAA,MAAM,CAAC,WAAW,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAO,EAAE,CAAA;KAC9B;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/containers/single-container/index.ts"],"sourcesContent":["// Global CSS variables (side effects import)\nimport 'styles/index'\n\n// Core\nimport { ContainerCore } from 'core/container'\nimport { ComponentCore } from 'core/component'\nimport { ComponentConfigInterface } from 'core/component/config'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Sizing, ExtendedSizeComponent } from 'types/component'\n\n// Config\nimport { SingleContainerDefaultConfig, SingleContainerConfigInterface } from './config'\n\nexport class SingleContainer<Data> extends ContainerCore {\n protected _defaultConfig = SingleContainerDefaultConfig as SingleContainerConfigInterface<Data>\n public component: ComponentCore<Data>\n public config: SingleContainerConfigInterface<Data> = this._defaultConfig\n\n constructor (element: HTMLElement, config?: SingleContainerConfigInterface<Data>, data?: Data) {\n super(element)\n\n if (config) {\n this.updateContainer(config, true)\n this.component = config.component\n }\n\n if (data) {\n this.setData(data, true)\n }\n\n // Render if component exists and has data\n if (this.component?.datamodel.data) this.render()\n }\n\n public setData (data: Data, preventRender?: boolean): void {\n const { config } = this\n\n if (this.component) this.component.setData(data)\n if (!preventRender) this.render()\n config.tooltip?.hide()\n }\n\n public updateContainer (containerConfig: SingleContainerConfigInterface<Data>, preventRender?: boolean): void {\n super.updateContainer(containerConfig)\n this._removeAllChildren()\n\n this.component = containerConfig.component\n if (containerConfig.sizing) this.component.sizing = containerConfig.sizing\n this.element.appendChild(this.component.element)\n\n const tooltip = containerConfig.tooltip\n if (tooltip) {\n if (!tooltip.hasContainer()) tooltip.setContainer(this._container)\n tooltip.setComponents([this.component])\n }\n\n const annotations = containerConfig.annotations\n if (annotations) {\n this.element.appendChild(annotations.element)\n }\n\n // Defs\n this.element.appendChild(this._svgDefs.node())\n this.element.appendChild(this._svgDefsExternal.node())\n\n if (!preventRender) this.render()\n }\n\n public updateComponent (componentConfig: ComponentConfigInterface, preventRender?: boolean): void {\n this.component.setConfig(componentConfig)\n if (!preventRender) this.render()\n }\n\n public update (\n containerConfig: SingleContainerConfigInterface<Data>,\n componentConfig?: ComponentConfigInterface,\n data?: Data\n ): void {\n if (containerConfig) this.updateContainer(containerConfig, true)\n if (componentConfig) this.updateComponent(componentConfig, true)\n if (data) this.setData(data, true)\n this.render()\n }\n\n public getFitWidthScale (): number {\n const { config, component } = this\n\n const extendedSizeComponent = component as ExtendedSizeComponent\n if (!extendedSizeComponent.getWidth) return 1\n\n const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right\n return this.width / componentWidth\n }\n\n protected _preRender (): void {\n super._preRender()\n this.component.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n this.component.setContainerMargin(this.config.margin)\n this.config.annotations?.setSize(this.width, this.height, this.containerWidth, this.containerHeight)\n this.config.annotations?.setContainerMargin(this.config.margin)\n }\n\n protected _render (duration?: number): void {\n const { config, component } = this\n super._render(duration)\n\n component.g.attr('transform', `translate(${config.margin.left},${config.margin.top})`)\n component.render(duration)\n config.annotations?.render(duration)\n\n if (config.tooltip) config.tooltip.update()\n config.onRenderComplete?.(this.svg.node(), config.margin, this.containerWidth, this.containerHeight, this.width, this.height)\n }\n\n // Re-defining the `render()` function to handle different sizing techniques (`Sizing.Extend` and `Sizing.FitWidth`)\n // Not calling `super.render()` because we don't want it to interfere with setting the SVG size here.\n public render (duration = this.config.duration): void {\n const { config, component } = this\n\n if (config.sizing === Sizing.Extend || config.sizing === Sizing.FitWidth) {\n const fitToWidth = config.sizing === Sizing.FitWidth\n const extendedSizeComponent = component as ExtendedSizeComponent\n\n const componentWidth = extendedSizeComponent.getWidth() + config.margin.left + config.margin.right\n const componentHeight = extendedSizeComponent.getHeight() + config.margin.top + config.margin.bottom\n const scale = fitToWidth ? this.getFitWidthScale() : 1\n\n const currentWidth = this.svg.attr('width')\n const currentHeight = this.svg.attr('height')\n const scaledWidth = componentWidth * scale\n const scaledHeight = componentHeight * scale\n const animated = currentWidth || currentHeight\n\n smartTransition(this.svg, animated ? duration : 0)\n .attr('width', scaledWidth)\n .attr('height', scaledHeight)\n .attr('viewBox', `${0} ${0} ${componentWidth} ${fitToWidth ? scaledHeight : componentHeight}`)\n .attr('preserveAspectRatio', 'xMinYMin')\n } else {\n this.svg\n .attr('width', this.config.width || this.containerWidth)\n .attr('height', this.config.height || this.containerHeight)\n }\n\n // Set up Resize Observer\n if (!this._resizeObserver) this._setUpResizeObserver()\n\n // Schedule the actual rendering in the next frame\n cancelAnimationFrame(this._renderAnimationFrameId)\n this._renderAnimationFrameId = requestAnimationFrame(() => {\n this._preRender()\n this._render(duration)\n })\n }\n\n protected _onResize (): void {\n const { config } = this\n super._onResize()\n config.tooltip?.hide()\n }\n\n public destroy (): void {\n const { component, config } = this\n super.destroy()\n\n component?.destroy()\n config.tooltip?.destroy()\n config.annotations?.destroy()\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;AAiBM,MAAO,eAAsB,SAAQ,aAAa,CAAA;AAKtD,IAAA,WAAA,CAAa,OAAoB,EAAE,MAA6C,EAAE,IAAW,EAAA;;QAC3F,KAAK,CAAC,OAAO,CAAC,CAAA;QALN,IAAc,CAAA,cAAA,GAAG,4BAAoE,CAAA;AAExF,QAAA,IAA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;AACF;;;;"}
@@ -6,6 +6,7 @@ import { Axis } from "../../components/axis";
6
6
  import { Crosshair } from "../../components/crosshair";
7
7
  import { ContinuousScale } from "../../types/scale";
8
8
  import { Direction } from "../../types/direction";
9
+ import { Spacing } from "../../types/spacing";
9
10
  export interface XYContainerConfigInterface<Datum> extends ContainerConfigInterface {
10
11
  /** An array of visualization components. Default: `[]` */
11
12
  components?: XYComponentCore<Datum>[];
@@ -82,5 +83,7 @@ export interface XYContainerConfigInterface<Datum> extends ContainerConfigInterf
82
83
  annotations?: Annotations | undefined;
83
84
  /** Extend the clip path by the specified number of pixels. Default: `2` */
84
85
  clipPathExtend?: number;
86
+ /** Callback function to be called when the chart rendering is complete. Default: `undefined` */
87
+ onRenderComplete?: (svgNode: SVGSVGElement, margin: Spacing, bleed: Spacing, containerWidth: number, containerHeight: number, componentWidth: number, componentHeight: number) => void;
85
88
  }
86
89
  export declare const XYContainerDefaultConfig: XYContainerConfigInterface<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/containers/xy-container/config.ts"],"sourcesContent":["// Core\nimport { XYComponentCore } from 'core/xy-component'\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\n\n// Components\nimport { Annotations } from 'components/annotations'\nimport { Tooltip } from 'components/tooltip'\nimport { Axis } from 'components/axis'\nimport { Crosshair } from 'components/crosshair'\n\n// Types\nimport { ContinuousScale } from 'types/scale'\nimport { Direction } from 'types/direction'\n\nexport interface XYContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** An array of visualization components. Default: `[]` */\n components?: XYComponentCore<Datum>[];\n\n /** Scale for X dimension, e.g. Scale.scaleLinear().\n * If set, this value will override the components' xScale and they will have a single shared xScale instance.\n * By default the components have their own scale instances but their `domain` and `range` values are synchronized.\n * Default: `undefined` */\n xScale?: ContinuousScale;\n /** Scale domain (data extent) for X dimension. By default this value is calculated automatically based on data. */\n xDomain?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.\n * For example, imagine that you have a chart with dynamic data that has negative values. When values are small\n * (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can\n * be achieved by setting `xDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the\n * values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`\n * Default: `undefined` */\n xDomainMinConstraint?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.\n * For example, imagine that you have a chart with dynamic data. When values are small\n * (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can\n * be achieved by setting `xDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the\n * values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`\n * Default: `undefined` */\n xDomainMaxConstraint?: [number | undefined, number | undefined];\n /** Force set the X scale range (in the screen space). By default the range is calculated automatically based on the\n * chart's set up */\n xRange?: [number, number];\n\n /** Scale for Y dimension, e.g. Scale.scaleLinear().\n * If set, this value will override the components' yScale and they will have a single shared yScale instance.\n * By default the components have their own scale instances but their `domain` and `range` values are synchronized.\n * Default: `undefined` */\n yScale?: ContinuousScale;\n /** Scale domain (data extent) for Y dimension. By default this value is calculated automatically based on data. */\n yDomain?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the Y scale domain.\n * For example, imagine that you have a chart with dynamic data that has negative values. When values are small\n * (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can\n * be achieved by setting `yDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the\n * values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`\n * Default: `undefined` */\n yDomainMinConstraint?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the Y scale domain.\n * For example, imagine that you have a chart with dynamic data. When values are small\n * (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can\n * be achieved by setting `yDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the\n * values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`\n * Default: `undefined` */\n yDomainMaxConstraint?: [number | undefined, number | undefined];\n /** Force set the Y scale range (in the screen space). By default the range is calculated automatically based on the\n * chart's set up */\n yRange?: [number, number];\n /** Y Axis direction. Default: `Direction.North` */\n yDirection?: Direction.South | Direction.North | string;\n\n /** X Axis component instance. Default: `undefined` */\n xAxis?: Axis<Datum>;\n /** Y Axis component instance. Default: `undefined` */\n yAxis?: Axis<Datum>;\n /** Enables automatic calculation of chart margins based on the size of the axes. Default: `true` */\n autoMargin?: boolean;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip | undefined;\n /** Crosshair component. Default: `undefined` */\n crosshair?: Crosshair<Datum> | undefined;\n /** Prevents the chart domain from being empty (when domain's min and max values are equal).\n * That usually happens when all the data values are equal or when there's no data.\n * Setting to `true` will automatically extend the domain by `+1` when the domain is empty (domain start equals domain end).\n * Setting to `null` will extend the empty X domain, but only when there's no data.\n * Setting to `false` will keep the domain as is.\n * Default: `null` */\n preventEmptyDomain?: boolean | null;\n /** Sets the Y scale domain based on the current X scale domain (not the whole dataset). Default: `false` */\n scaleByDomain?: boolean;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n /** Extend the clip path by the specified number of pixels. Default: `2` */\n clipPathExtend?: number;\n}\n\n\nexport const XYContainerDefaultConfig: XYContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n components: [],\n tooltip: undefined,\n crosshair: undefined,\n annotations: undefined,\n xAxis: undefined,\n yAxis: undefined,\n autoMargin: true,\n\n xScale: undefined,\n xDomain: undefined,\n xDomainMinConstraint: undefined,\n xDomainMaxConstraint: undefined,\n xRange: undefined,\n\n yScale: undefined,\n yDomain: undefined,\n yDomainMinConstraint: undefined,\n yDomainMaxConstraint: undefined,\n yRange: undefined,\n yDirection: Direction.North,\n\n preventEmptyDomain: null,\n scaleByDomain: false,\n\n clipPathExtend: 2,\n}\n\n"],"names":[],"mappings":";;;MAgGa,wBAAwB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAChC,sBAAsB,CACzB,EAAA,EAAA,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,SAAS,EACtB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,IAAI,EAEhB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,EAClB,oBAAoB,EAAE,SAAS,EAC/B,oBAAoB,EAAE,SAAS,EAC/B,MAAM,EAAE,SAAS,EAEjB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,EAClB,oBAAoB,EAAE,SAAS,EAC/B,oBAAoB,EAAE,SAAS,EAC/B,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,SAAS,CAAC,KAAK,EAE3B,kBAAkB,EAAE,IAAI,EACxB,aAAa,EAAE,KAAK,EAEpB,cAAc,EAAE,CAAC;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/containers/xy-container/config.ts"],"sourcesContent":["// Core\nimport { XYComponentCore } from 'core/xy-component'\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\n\n// Components\nimport { Annotations } from 'components/annotations'\nimport { Tooltip } from 'components/tooltip'\nimport { Axis } from 'components/axis'\nimport { Crosshair } from 'components/crosshair'\n\n// Types\nimport { ContinuousScale } from 'types/scale'\nimport { Direction } from 'types/direction'\nimport { Spacing } from 'types/spacing'\n\nexport interface XYContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** An array of visualization components. Default: `[]` */\n components?: XYComponentCore<Datum>[];\n\n /** Scale for X dimension, e.g. Scale.scaleLinear().\n * If set, this value will override the components' xScale and they will have a single shared xScale instance.\n * By default the components have their own scale instances but their `domain` and `range` values are synchronized.\n * Default: `undefined` */\n xScale?: ContinuousScale;\n /** Scale domain (data extent) for X dimension. By default this value is calculated automatically based on data. */\n xDomain?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.\n * For example, imagine that you have a chart with dynamic data that has negative values. When values are small\n * (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can\n * be achieved by setting `xDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the\n * values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`\n * Default: `undefined` */\n xDomainMinConstraint?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.\n * For example, imagine that you have a chart with dynamic data. When values are small\n * (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can\n * be achieved by setting `xDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the\n * values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`\n * Default: `undefined` */\n xDomainMaxConstraint?: [number | undefined, number | undefined];\n /** Force set the X scale range (in the screen space). By default the range is calculated automatically based on the\n * chart's set up */\n xRange?: [number, number];\n\n /** Scale for Y dimension, e.g. Scale.scaleLinear().\n * If set, this value will override the components' yScale and they will have a single shared yScale instance.\n * By default the components have their own scale instances but their `domain` and `range` values are synchronized.\n * Default: `undefined` */\n yScale?: ContinuousScale;\n /** Scale domain (data extent) for Y dimension. By default this value is calculated automatically based on data. */\n yDomain?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the Y scale domain.\n * For example, imagine that you have a chart with dynamic data that has negative values. When values are small\n * (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can\n * be achieved by setting `yDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the\n * values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`\n * Default: `undefined` */\n yDomainMinConstraint?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the Y scale domain.\n * For example, imagine that you have a chart with dynamic data. When values are small\n * (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can\n * be achieved by setting `yDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the\n * values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`\n * Default: `undefined` */\n yDomainMaxConstraint?: [number | undefined, number | undefined];\n /** Force set the Y scale range (in the screen space). By default the range is calculated automatically based on the\n * chart's set up */\n yRange?: [number, number];\n /** Y Axis direction. Default: `Direction.North` */\n yDirection?: Direction.South | Direction.North | string;\n\n /** X Axis component instance. Default: `undefined` */\n xAxis?: Axis<Datum>;\n /** Y Axis component instance. Default: `undefined` */\n yAxis?: Axis<Datum>;\n /** Enables automatic calculation of chart margins based on the size of the axes. Default: `true` */\n autoMargin?: boolean;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip | undefined;\n /** Crosshair component. Default: `undefined` */\n crosshair?: Crosshair<Datum> | undefined;\n /** Prevents the chart domain from being empty (when domain's min and max values are equal).\n * That usually happens when all the data values are equal or when there's no data.\n * Setting to `true` will automatically extend the domain by `+1` when the domain is empty (domain start equals domain end).\n * Setting to `null` will extend the empty X domain, but only when there's no data.\n * Setting to `false` will keep the domain as is.\n * Default: `null` */\n preventEmptyDomain?: boolean | null;\n /** Sets the Y scale domain based on the current X scale domain (not the whole dataset). Default: `false` */\n scaleByDomain?: boolean;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n /** Extend the clip path by the specified number of pixels. Default: `2` */\n clipPathExtend?: number;\n /** Callback function to be called when the chart rendering is complete. Default: `undefined` */\n onRenderComplete?: (\n svgNode: SVGSVGElement,\n margin: Spacing,\n bleed: Spacing,\n containerWidth: number,\n containerHeight: number,\n componentWidth: number,\n componentHeight: number,\n ) => void;\n}\n\n\nexport const XYContainerDefaultConfig: XYContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n components: [],\n tooltip: undefined,\n crosshair: undefined,\n annotations: undefined,\n xAxis: undefined,\n yAxis: undefined,\n autoMargin: true,\n\n xScale: undefined,\n xDomain: undefined,\n xDomainMinConstraint: undefined,\n xDomainMaxConstraint: undefined,\n xRange: undefined,\n\n yScale: undefined,\n yDomain: undefined,\n yDomainMinConstraint: undefined,\n yDomainMaxConstraint: undefined,\n yRange: undefined,\n yDirection: Direction.North,\n\n preventEmptyDomain: null,\n scaleByDomain: false,\n\n clipPathExtend: 2,\n}\n\n"],"names":[],"mappings":";;;MA2Ga,wBAAwB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAChC,sBAAsB,CACzB,EAAA,EAAA,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,SAAS,EACtB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,IAAI,EAEhB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,EAClB,oBAAoB,EAAE,SAAS,EAC/B,oBAAoB,EAAE,SAAS,EAC/B,MAAM,EAAE,SAAS,EAEjB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,EAClB,oBAAoB,EAAE,SAAS,EAC/B,oBAAoB,EAAE,SAAS,EAC/B,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,SAAS,CAAC,KAAK,EAE3B,kBAAkB,EAAE,IAAI,EACxB,aAAa,EAAE,KAAK,EAEpB,cAAc,EAAE,CAAC;;;;"}
@@ -33,5 +33,6 @@ export declare class XYContainer<Datum> extends ContainerCore {
33
33
  private _renderAxes;
34
34
  private _setAutoMargin;
35
35
  private _getMargin;
36
+ private _getBleed;
36
37
  destroy(): void;
37
38
  }
@@ -174,7 +174,7 @@ class XYContainer extends ContainerCore {
174
174
  this._updateScales(...this.components, config.xAxis, config.yAxis, config.crosshair);
175
175
  }
176
176
  _render(customDuration) {
177
- var _a, _b, _c, _d, _e;
177
+ var _a, _b, _c, _d, _e, _f;
178
178
  const { config } = this;
179
179
  super._render();
180
180
  // Get chart total margin after auto margin calculations
@@ -220,6 +220,7 @@ class XYContainer extends ContainerCore {
220
220
  (_d = config.annotations) === null || _d === void 0 ? void 0 : _d.g.attr('transform', `translate(${margin.left},${margin.top})`);
221
221
  (_e = config.annotations) === null || _e === void 0 ? void 0 : _e.render();
222
222
  this._firstRender = false;
223
+ (_f = config.onRenderComplete) === null || _f === void 0 ? void 0 : _f.call(config, this.svg.node(), margin, this._getBleed(this.components), this.containerWidth, this.containerHeight, this.width, this.height);
223
224
  }
224
225
  _updateScales(...components) {
225
226
  const c = clean(components || this.components);
@@ -283,14 +284,7 @@ class XYContainer extends ContainerCore {
283
284
  c.setScaleRange(ScaleDimension.Y, (_f = config.yRange) !== null && _f !== void 0 ? _f : yRange);
284
285
  }
285
286
  // Get and combine bleed
286
- const bleed = components.map(c => c.bleed).reduce((bleed, b) => {
287
- for (const key of Object.keys(bleed)) {
288
- const k = key;
289
- if (bleed[k] < b[k])
290
- bleed[k] = b[k];
291
- }
292
- return bleed;
293
- }, { top: 0, bottom: 0, left: 0, right: 0 });
287
+ const bleed = this._getBleed(components);
294
288
  // Update scale range
295
289
  for (const c of components) {
296
290
  c.setScaleRange(ScaleDimension.X, [xRange[0] + bleed.left, xRange[1] - bleed.right]);
@@ -349,6 +343,16 @@ class XYContainer extends ContainerCore {
349
343
  right: margin.right + this._axisMargin.right,
350
344
  };
351
345
  }
346
+ _getBleed(components) {
347
+ return components.map(c => c.bleed).reduce((bleed, b) => {
348
+ for (const key of Object.keys(bleed)) {
349
+ const k = key;
350
+ if (bleed[k] < b[k])
351
+ bleed[k] = b[k];
352
+ }
353
+ return bleed;
354
+ }, { top: 0, bottom: 0, left: 0, right: 0 });
355
+ }
352
356
  destroy() {
353
357
  const { components, config: { tooltip, crosshair, annotations, xAxis, yAxis } } = this;
354
358
  super.destroy();