#D3 Type Error

16 messages · Page 1 of 1 (latest)

meager lake
#

seems like you're just using the api incorrectly

#

sorry, was figuring out what the correct usage would be. think ive got it, give me a sec

#

for the line part, by default, it assumes a coordinate pair. you have to specify otherwise, like this

const line = d3
    .line<ClimateData>()
    .x(function (d) {
        return x(d.date);
    })
    .y(function (d) {
        return y(d.value);
    });
#

you need to bring ClimateData out of the function. you're nesting things a lot, and that can make it much harder to work with

#

as for the domain part, documentation suggests that it accepts the full data, not the min and max like you're providing

#

that's just any.

#

you should type that more strongly

#

you should be seeing it directly in your IDE

#

on hover

#

it's in jsdoc

#

you can also see the source of the documentation here

#

linked in the package's readme

#

anyways in general functions and types shouldn't be nested in other functions
exceptions for functions: closures, callbacks
exceptions for types: processed type that's used multiple times

#

also i think you're overusing functions a bit here? modularization is cool and all, but some stuff doesn't really need to be modularized. graph doesn't have much purpose to be there, you can just put the logic directly in the event callback (also consider using arrow functions, that can make callbacks less verbose)

meager lake
#

!resolved