{"id":24150898,"url":"https://github.com/hongfaqiu/geo-timeline","last_synced_at":"2025-09-19T18:30:59.461Z","repository":{"id":58540113,"uuid":"528294376","full_name":"hongfaqiu/geo-timeline","owner":"hongfaqiu","description":"A D3.js-based geologic timeline，古地理时间轴","archived":false,"fork":false,"pushed_at":"2024-05-22T08:58:13.000Z","size":4463,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T00:47:11.534Z","etag":null,"topics":["d3","geologic","timeline","timescale"],"latest_commit_sha":null,"homepage":"https://geo-timeline.opendde.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hongfaqiu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-24T06:28:06.000Z","updated_at":"2025-02-14T03:48:48.000Z","dependencies_parsed_at":"2024-05-22T10:02:21.491Z","dependency_job_id":null,"html_url":"https://github.com/hongfaqiu/geo-timeline","commit_stats":{"total_commits":54,"total_committers":3,"mean_commits":18.0,"dds":"0.38888888888888884","last_synced_commit":"911c37543bb0f06b5c8a03362e5b8a17a270c0a1"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/hongfaqiu/geo-timeline","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongfaqiu%2Fgeo-timeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongfaqiu%2Fgeo-timeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongfaqiu%2Fgeo-timeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongfaqiu%2Fgeo-timeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hongfaqiu","download_url":"https://codeload.github.com/hongfaqiu/geo-timeline/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongfaqiu%2Fgeo-timeline/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275706015,"owners_count":25513174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["d3","geologic","timeline","timescale"],"created_at":"2025-01-12T09:13:01.589Z","updated_at":"2025-09-19T18:30:59.028Z","avatar_url":"https://github.com/hongfaqiu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# geo-timeline\r\n\r\nA D3.js(v7) based geologic timeline\u0026timeScale\u0026timeSlider\r\n\r\n\r\n[![gzip size](http://img.badgesize.io/https://unpkg.com/@zjugis/geo-timeline?compression=gzip\u0026label=gzip)](https://unpkg.com/@zjugis/geo-timeline) ![npm latest version](https://img.shields.io/npm/v/@zjugis/geo-timeline.svg) ![license](https://img.shields.io/npm/l/@zjugis/geo-timeline)\r\n\r\n**timeLine:**\r\n![geo-timeline](img/geo-timeline.png)\r\n\r\n- ``Zoom:`` Use the mouse wheel to control zoom, double-click to zoom in.\r\n- ``Adjustment:`` Hold down the left button to drag the timeline.\r\n- ``Location:`` Left click the timeline to move the handler quickly, or drag to move the handler.\r\n\r\n**timeScale:**\r\n![geo-timescale-simple](img/geoTimeScale-simple.gif)\r\n\r\n- ``Location:`` Left click the geo stage to quick location.\r\n- ``Zoom:`` Use the mouse wheel to control zoom in or zoom out.\r\n\r\n**timeSlider:**\r\n![geo-timeslider](img/geoTimeSlider.gif)\r\n\r\n- ``Drag``: Drag the slider to change the time.\r\n- ``Click``: Click on the square to change the time range.\r\n\r\n## Install\r\n\r\nFor node.js\r\n\r\n```bash\r\n#npm\r\nnpm install --save @zjugis/geo-timeline\r\n#yarn\r\nyarn add @zjugis/geo-timeline\r\n```\r\n\r\nFor legacy environments, you can load @zjugis/geo-timeline’s UMD bundle from an npm-based CDN such as jsDelivr; a `timeLine` global is exported:\r\n\r\n```html\r\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/d3@7\"\u003e\u003c/script\u003e\r\n\u003cscript src=\"//unpkg.com/@zjugis/geo-timeline@latest\"\u003e\u003c/script\u003e\r\n\r\n\u003cscript\u003e\r\n  fetch('./test/GTS_2020.json').then(async res =\u003e {\r\n    const intervals = await res.json()\r\n\r\n    new timeLine.GeoTimeLine(\"#geoTimeLineContainer\", intervals)\r\n    new timeLine.GeoTimeScale(\"#geoTimeScaleContainer\", intervals)\r\n    new timeLine.GeoTimeSlider(\"#geoTimeSliderContainer\", intervals)\r\n  })\r\n\u003c/script\u003e\r\n```\r\n\r\n### Usage\r\n\r\nFor node.js\r\n\r\n```ts\r\nimport { GeoTimeLine, GeoTimeScale } from \"@zjugis/geo-timeline\";\r\n\r\nfetch('./test/GTS_2020.json').then(async res =\u003e {\r\n  const intervals = await res.json()\r\n\r\n  // create geotimeline obj\r\n  const geoTimeLine = new GeoTimeLine(\"#geoTimeContainer\", intervals, {\r\n    onChange: function(time, level) {\r\n      // do something\r\n    },\r\n    // determin interval by time\r\n    intervalSum: d =\u003e d.leaf ? d.start - d.end : 0\r\n  });\r\n\r\n  // It is recommended to set the time after changing the level\r\n  geoTimeLine.level = 2\r\n  geoTimeLine.time = 2000\r\n\r\n  // create geotimescale obj\r\n  const geoTimeScale = new GeoTimeScale(\"#geoTimeScale-simple\", intervals, {\r\n    onChange: val =\u003e console.log(val),\r\n    // only show 2 levels once\r\n    simplify: true,\r\n    height: 70,\r\n  })\r\n  // set stage\r\n  geoTimeScale.stage = 'Cambrian'\r\n\r\n  // create geotimeslider obj\r\n  const geoTimeSlider = new GeoTimeSlider(\"#geoTimeSlider\", intervals, {\r\n    // do something when time range is changed\r\n    onChange: val =\u003e console.log(val),\r\n  })\r\n\r\n  // set time range \r\n  geoTimeSlider.timeRange = [300, 100]\r\n})\r\n\r\n```\r\n\r\n### API\r\n\r\n#### GeoTimeLine\r\n\r\n```ts\r\nclass GeoTimeLine {\r\n    /** text font */\r\n    readonly font: string;\r\n    /** interval data's max level */\r\n    readonly maxLevel: number;\r\n    /** svg object */\r\n    readonly svg: Selection\u003cSVGSVGElement, unknown, HTMLElement, any\u003e;\r\n    /** interval data */\r\n    readonly intervals: IntervalItem[];\r\n    /** hierarchical data generated by intervals */\r\n    readonly hierarchicalData: HierarchyNode\u003cIntervalItem\u003e;\r\n    /** the root hierarchical data */\r\n    readonly root: NodeItem;\r\n    /** user input options */\r\n    readonly options: GeoTimeLineOptions\r\n    \r\n    /** \r\n     * Create a GeoTimeLine\r\n     * @param selector CSS selector string\r\n     * @param intervals geo time intervals array\r\n     * @param options GeoTimeLine options\r\n    */\r\n    constructor(selector: string | BaseType, intervals: IntervalItem[], options?: GeoTimeLineOptions);\r\n\r\n    /** get or set time */\r\n    get time(): number;\r\n    set time(val: number);\r\n    /** get or set level */\r\n    get level(): number;\r\n    set level(val: number);\r\n    get ready(): boolean;\r\n}\r\n\r\n/**\r\n * BaseType serves as an alias for the 'minimal' data type which can be selected\r\n * without 'd3-selection' trying to use properties internally which would otherwise not\r\n * be supported.\r\n */\r\ntype BaseType = Element | EnterElement | Document | Window | null;\r\n\r\ninterface GeoTimeLineOptions {\r\n    /** geo time intervals array */\r\n    intervals: IntervalItem[];\r\n    /** svg width, defaults to container's width */\r\n    width?: number;\r\n    /** svg height, defaults to 70 */\r\n    height?: number;\r\n    /** font size, defaults to 16px */\r\n    fontSize?: number;\r\n    /** font family, defaults to 'sans-serif' */\r\n    fontFamily?: string;\r\n    /** callback when handle's position or scale level changed */\r\n    onChange?: (time: number, level: number) =\u003e void;\r\n    /** dispatch when mouseup or zoom  */\r\n    onAfterChange?: (time: number, level: number) =\u003e void;\r\n    /** defaults to {\r\n      top: 0, right: 0, bottom: 0, left: 0,\r\n    } */\r\n    margin?: {\r\n        top?: number;\r\n        bottom?: number;\r\n        left?: number;\r\n        right?: number;\r\n    }\r\n    /** defaults to {\r\n      top: 0, right: 0, bottom: 0, left: 0,\r\n    } */\r\n    padding?: {\r\n        top?: number;\r\n        bottom?: number;\r\n        left?: number;\r\n        right?: number;\r\n    }\r\n    /** initial time, defaults to 0 */\r\n    time?: number;\r\n    /** animation time, defaults to 450ms */\r\n    transition?: number;\r\n    /** interval transform setting, defaults to (d) =\u003e d.leaf ? 1 : 0 */\r\n    intervalSum?: (d: IntervalItem) =\u003e number;\r\n    /** min zoom level */\r\n    minZoom?: number;\r\n    /** max zoom level, defaults to 10 */\r\n    maxZoom?: number;\r\n}\r\n\r\n/** geo time data intervals schema **/\r\ntype IntervalItem = {\r\n    id: number;\r\n    name: string;\r\n    abbr?: string;\r\n    color: string;\r\n    textColor?: string;\r\n    end: number;\r\n    start: number;\r\n    level?: number;\r\n    parentId?: number;\r\n    leaf?: boolean;\r\n}\r\n\r\n```\r\n\r\n#### GeoTimeScale\r\n\r\n```ts\r\nclass GeoTimeLine {\r\n    /** text font */\r\n    readonly font: string;\r\n    /** svg object */\r\n    readonly svg: Selection\u003cSVGSVGElement, unknown, HTMLElement, any\u003e;\r\n    /** interval data */\r\n    readonly intervals: IntervalItem[];\r\n    /** hierarchical data generated by intervals */\r\n    readonly hierarchicalData: HierarchyNode\u003cIntervalItem\u003e;\r\n    /** the root hierarchical data */\r\n    readonly root: NodeItem;\r\n    /** user input options */\r\n    readonly options: GeoTimeScaleOptions;\r\n    \r\n    /**\r\n     * Create a GeoTimeScale\r\n     * @param selector CSS selector string\r\n     * @param intervals geo time intervals array\r\n     * @param options GeoTimeScale options\r\n     */\r\n    constructor(selector: string | BaseType, intervals: IntervalItem[], options?: GeoTimeScaleOptions);\r\n    /** get or set animation transition time */\r\n    transition: number;\r\n    /** get or set focused stage\r\n     * @example\r\n     * geoTimeScale.stage = 'Cambrian'\r\n     */\r\n    get stage(): string;\r\n    set stage(val: string);\r\n    get sequence(): NodeItem[];\r\n    get ready(): boolean;\r\n}\r\n\r\ninterface GeoTimeScaleOptions {\r\n    /** geo time intervals array */\r\n    intervals: IntervalItem[];\r\n    /** svg width, defaults to container's width */\r\n    width?: number;\r\n    /** svg height, defaults to 400px */\r\n    height?: number;\r\n    /** font size, defaults to 12px */\r\n    fontSize?: number;\r\n    /** font family, defaults to 'sans-serif' */\r\n    fontFamily?: string;\r\n    /** callback when handle's position or scale level changed */\r\n    onChange?: (node: NodeItem) =\u003e void;\r\n    /** defaults to {\r\n      top: 0, right: 0, bottom: 0, left: 0,\r\n    } */\r\n    margin?: MarginOpts;\r\n    /** defaults to {\r\n      top: 0, right: 0, bottom: 0, left: 0,\r\n    } */\r\n    padding?: MarginOpts;\r\n    /** animation time, defaults to 450ms */\r\n    transition?: number;\r\n    /** interval transform setting, defaults to d =\u003e d.leaf ? d.start - d.end : 0 */\r\n    intervalSum?: (d: IntervalItem) =\u003e number;\r\n    /** simplify show 2 levels or not, defaults to false */\r\n    simplify?: boolean;\r\n    /** focused node's neighbor node width, defaults to 100px */\r\n    neighborWidth?: number;\r\n    /** tick length, defaults to 15px */\r\n    tickLength?: number;\r\n}\r\n```\r\n\r\n### GeoTimeSlider\r\n\r\n```ts\r\nclass GeoTimeSlider {\r\n    /** text font */\r\n    readonly font: string;\r\n    /** svg object */\r\n    readonly svg: any;\r\n    /** interval data */\r\n    readonly intervals: IntervalItem[];\r\n    /** hierarchical data generated by intervals */\r\n    readonly hierarchicalData: HierarchyNode\u003cIntervalItem\u003e;\r\n    /** the root hierarchical data */\r\n    readonly root: SliderNodeItem;\r\n    /** user input options */\r\n    readonly options: Required\u003cGeoTimeSliderOptions\u003e;\r\n    /** get or set animation transition time */\r\n    transition: number;\r\n    readonly startEnd: number[];\r\n    /**\r\n     * Create a GeoTimeSlider\r\n     * @param {string | BaseType} selector CSS selector string\r\n     * @param {IntervalItem[]} intervals geo time intervals array\r\n     * @param {number} [options.width] svg width, defaults to container's width\r\n     * @param {number} [options.height = 400] svg height, defaults to 400px\r\n     * @param {number} [options.fontSize = 12] font size, defaults to 12px\r\n     * @param {string} [options.fontFamily = 'sans-serif'] font family, defaults to 'sans-serif'\r\n     * @param {Function} [options.onChange] callback when focused node change\r\n     * @param {Object} [options.margin] svg margin, defaults to { top: 0, right: 0, bottom: 0, left: 0 }\r\n     * @param {Object} [options.padding] svg padding, defaults to { top: 0, right: 0, bottom: 0, left: 0 }\r\n     * @param {number} [options.transition = 300] animation time, defaults to 300ms\r\n     * @param {Function} [options.intervalSum] interval transform setting, defaults to d =\u003e d.leaf ? d.start - d.end : 0\r\n     * @param {boolean} [options.simplify = true] simplify show 2 levels or not\r\n     * @param {number} [options.neighborWidth = 100] focused node's neighbor node width, defaults to 100px\r\n     * @param {number} [options.tickLength = 15] tick length, defaults to 15px\r\n     * @param {number} [options.tickHeight = 30] tick height, defaults to 30px\r\n     * @param {string} [options.unit = ''] tick value unit\r\n     */\r\n    constructor(selector: string | BaseType, intervals: IntervalItem[], options?: GeoTimeSliderOptions);\r\n    /** get or set focused stage\r\n     * @example\r\n     * geoTimeScale.stage = 'Cambrian'\r\n     */\r\n    get stage(): string | undefined;\r\n    set stage(val: string);\r\n    get sliderPosition(): number[];\r\n    get timeRange(): number[];\r\n    set timeRange(range: number[]);\r\n    get ready(): boolean;\r\n}\r\n\r\ninterface GeoTimeSliderOptions {\r\n    /** svg width, defaults to container's width */\r\n    width?: number;\r\n    /** svg height, defaults to 400px */\r\n    height?: number;\r\n    /** font size, defaults to 12px */\r\n    fontSize?: number;\r\n    /** font family, defaults to 'sans-serif' */\r\n    fontFamily?: string;\r\n    /** callback when handle's position or scale level changed */\r\n    onChange?: (timeRange: number[]) =\u003e void;\r\n    /** defaults to {\r\n      top: 0, right: 0, bottom: 0, left: 0,\r\n    } */\r\n    margin?: MarginOpts;\r\n    /** defaults to {\r\n      top: 0, right: 0, bottom: 0, left: 0,\r\n    } */\r\n    padding?: MarginOpts;\r\n    /** animation time, defaults to 300ms */\r\n    transition?: number;\r\n    /** interval transform setting, defaults to d =\u003e d.leaf ? d.start - d.end : 0 */\r\n    intervalSum?: (d: IntervalItem) =\u003e number;\r\n    /** focused node's neighbor node width, defaults to 100px */\r\n    neighborWidth?: number;\r\n    /** tick length, defaults to 15px */\r\n    tickLength?: number;\r\n    /** tick height, defaults to 30px */\r\n    tickHeight?: number;\r\n    /** tick value unit */\r\n    unit?: string;\r\n}\r\n```\r\n\r\n## Custom data\r\n\r\nThe [interval](./test/GTS_2020.json) item's schema like follow:\r\n\r\n```json\r\n{\r\n  \"id\": 753,\r\n  \"name\": \"Archean\",\r\n  \"level\": 1,\r\n  \"parentId\": 0,\r\n  \"color\": \"#F0047F\",\r\n  \"end\": 2500,\r\n  \"start\": 4000\r\n}\r\n```\r\n\r\n## Demo\r\n\r\n[Online demo](https://geo-timeline.vercel.app/)\r\n\r\n**geoTimeLine**\r\n![geo-timeLine](img/geoTimeLine.gif)\r\n\r\n**geoTimeScale**\r\n![geo-timescale-simple](img/geoTimeScale.gif)\r\n\r\n**geoTimeSlider**\r\n![geo-timeslider](img/geoTimeSlider.gif)\r\n\r\n## Develop\r\n\r\nRun the command:\r\n\r\n```bash\r\npnpm dev\r\n```\r\n\r\nAnd then Launch [index.html](index.html) with node server, if use VS Code, suggest the ``Live Server`` extension.\r\n\r\nRun test:\r\n\r\n```bash\r\npnpm test\r\n```\r\n\r\n## Credit\r\n\r\n\u003chttps://github.com/UW-Macrostrat/geo-timescale\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongfaqiu%2Fgeo-timeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhongfaqiu%2Fgeo-timeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongfaqiu%2Fgeo-timeline/lists"}