@@ -5,6 +5,7 @@ import type {
55 DownloadDataPoint ,
66 PackageDownloadsRecentVersion ,
77} from "../../../utils/api_types.ts" ;
8+ import type ApexCharts from "apexcharts" ;
89
910interface Props {
1011 downloads : PackageDownloadsRecentVersion [ ] ;
@@ -14,8 +15,7 @@ export type AggregationPeriod = "daily" | "weekly" | "monthly";
1415
1516export function DownloadChart ( props : Props ) {
1617 const chartDivRef = useRef < HTMLDivElement > ( null ) ;
17- // deno-lint-ignore no-explicit-any
18- const chartRef = useRef < any > ( null ) ;
18+ const chartRef = useRef < ApexCharts > ( null ) ;
1919 const [ graphRendered , setGraphRendered ] = useState ( false ) ;
2020
2121 useEffect ( ( ) => {
@@ -63,7 +63,7 @@ export function DownloadChart(props: Props) {
6363 setGraphRendered ( true ) ;
6464 } ) ( ) ;
6565 return ( ) => {
66- chartRef . current . destroy ( ) ;
66+ chartRef . current ? .destroy ( ) ;
6767 chartRef . current = null ;
6868 } ;
6969 } , [ ] ) ;
@@ -78,7 +78,7 @@ export function DownloadChart(props: Props) {
7878 < select
7979 id = "aggregationPeriod"
8080 onChange = { ( e ) =>
81- chartRef . current . updateSeries (
81+ chartRef . current ? .updateSeries (
8282 getSeries (
8383 props . downloads ,
8484 e . currentTarget . value as AggregationPeriod ,
@@ -158,7 +158,7 @@ export function normalize(
158158 dataPoints : DownloadDataPoint [ ] ,
159159 xValues : string [ ] ,
160160 aggregationPeriod : AggregationPeriod ,
161- ) : [ Date , number ] [ ] {
161+ ) : [ number , number ] [ ] {
162162 const normalized : { [ key : string ] : number } = { } ;
163163 for ( const date of xValues ) {
164164 normalized [ date ] = 0 ;
@@ -176,7 +176,7 @@ export function normalize(
176176
177177 return Object . entries ( normalized ) . map ( (
178178 [ key , value ] ,
179- ) => [ new Date ( key ) , value ] ) ;
179+ ) => [ new Date ( key ) . getTime ( ) , value ] ) ;
180180}
181181
182182function getSeries (
@@ -193,7 +193,7 @@ function getSeries(
193193 ) . flat ( ) ;
194194
195195 const xValues = collectX (
196- dataPointsToDisplay . map ( ( version ) => version . downloads ) . flat ( ) ,
196+ dataPointsWithDownloads . map ( ( version ) => version . downloads ) . flat ( ) ,
197197 aggregationPeriod ,
198198 ) ;
199199
0 commit comments