{"version":3,"file":"ChartConfig-DuPjHg6t.js","sources":["../../../app/javascript/entrypoints/pages/StockPage/StockPriceChart/ChartConfig.ts"],"sourcesContent":["import { AxisLabelsFormatterContextObject, Options } from 'highcharts';\nimport dayjs from 'dayjs';\nimport merge from 'lodash/fp/merge';\n\nexport interface ConfigFn {\n (points: Point[], labels: string[]): Options;\n}\n\nexport const currentConfigFn = (points: Point[], labels: string[]): Options => {\n const config = {\n xAxis: {\n tickInterval: 60,\n labels: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n formatter: function (this: AxisLabelsFormatterContextObject): string {\n return `${labels[this.value]}`;\n },\n },\n },\n };\n\n return merge(defaultConfig(points, labels), config);\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Point = number | any; //SeriesLineOptions;\n\nexport interface PointFun {\n (point: number, i: number): Point;\n}\n\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nexport const entirePointFn: (labels: string[]) => PointFun =\n (labels: string[]) =>\n (point: number, i: number): Point => {\n return {\n x: dayjs(`${labels[i]}T00:00Z`).toDate().getTime(),\n y: point,\n key: i,\n };\n };\n/* eslint-enable @typescript-eslint/explicit-function-return-type */\n\nexport const entireConfigFn = (points: Point[], labels: string[]): Options => {\n const config = {\n chart: {\n zoomType: 'x',\n },\n xAxis: {\n type: 'datetime',\n dateTimeLabelFormats: {\n day: '%Y-%m-%d',\n week: '%Y-%m-%d',\n month: '%Y-%m-%d',\n },\n },\n };\n\n return merge(defaultConfig(points, labels), config);\n};\n\nfunction defaultConfig(points: Point[], labels: string[]): Options {\n return {\n title: {\n text: '',\n },\n legend: {\n enabled: false,\n },\n xAxis: {\n gridLineWidth: 1,\n },\n yAxis: {\n title: {\n text: null,\n },\n },\n plotOptions: {\n line: {\n animation: false,\n marker: {\n fillColor: 'transparent',\n lineColor: '#7cb5ec',\n lineWidth: 2.5,\n radius: 3.5,\n },\n lineWidth: 2,\n shadow: {\n offsetY: 1.5,\n width: 1.5,\n },\n states: {\n hover: {\n halo: {\n size: 0,\n },\n lineWidthPlus: 0,\n },\n normal: {\n animation: false,\n },\n },\n },\n series: {\n label: {\n connectorAllowed: false,\n },\n color: '#edc240',\n turboThreshold: 100000,\n },\n },\n series: [\n {\n type: 'line',\n data: points,\n },\n ],\n tooltip: {\n headerFormat: '',\n pointFormatter: function (): string {\n return `${this.y} 倍 (${\n labels[this.index]\n })`;\n },\n },\n responsive: {\n rules: [\n {\n condition: {\n maxWidth: 500,\n },\n chartOptions: {\n legend: {\n layout: 'horizontal',\n align: 'center',\n verticalAlign: 'bottom',\n },\n },\n },\n ],\n },\n };\n}\n"],"names":["currentConfigFn","points","labels","config","merge","defaultConfig","entirePointFn","point","i","dayjs","entireConfigFn"],"mappings":"2HAQa,MAAAA,EAAkB,CAACC,EAAiBC,IAA8B,CAC7E,MAAMC,EAAS,CACb,MAAO,CACL,aAAc,GACd,OAAQ,CAEN,UAAW,UAA+D,CACxE,MAAO,GAAGD,EAAO,KAAK,KAAK,CAAC,EAC9B,CACF,CACF,CAAA,EAGF,OAAOE,EAAMC,EAAcJ,EAAQC,CAAM,EAAGC,CAAM,CACpD,EAUaG,EACVJ,GACD,CAACK,EAAeC,KACP,CACL,EAAGC,EAAM,GAAGP,EAAOM,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EACjD,EAAGD,EACH,IAAKC,CAAA,GAKEE,EAAiB,CAACT,EAAiBC,IAA8B,CAC5E,MAAMC,EAAS,CACb,MAAO,CACL,SAAU,GACZ,EACA,MAAO,CACL,KAAM,WACN,qBAAsB,CACpB,IAAK,WACL,KAAM,WACN,MAAO,UACT,CACF,CAAA,EAGF,OAAOC,EAAMC,EAAcJ,EAAQC,CAAM,EAAGC,CAAM,CACpD,EAEA,SAASE,EAAcJ,EAAiBC,EAA2B,CAC1D,MAAA,CACL,MAAO,CACL,KAAM,EACR,EACA,OAAQ,CACN,QAAS,EACX,EACA,MAAO,CACL,cAAe,CACjB,EACA,MAAO,CACL,MAAO,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