Bullet Chart Example

I refer to an example of a bullet chart in the g3.3 D3 v2.4.2 repository .

I have a few questions to help clarify what happens in this example.

1) The bulletChart function has 8 declarations in the form bullet.ranges = function (x) {}, bullet.markers = function (x) {}, etc. Where does this bullet object come from? Is it built into the library? I thought we already set the ranges of the variables in the bulletRanges function or are these two range range variables?

2) What happens inside these functions?

3) Last question. When the bulletChart function starts execution, does it start the bullet function when the execution arrives at it or does it wait for an explicit call? Because I never see clearly a bullet (g)?

This library can be very confusing. Any help was greatly appreciated.

+3
source share
1 answer

1) bulletat the beginning of the name refers to a function with the same name created on line 70. Calls add members to the object, which can also be called. This is basically a way to let you customize the returned object. In terms of OO bullet, this is an object, and functions are defined by accessors for its members. Functions bulletRanges, etc. Provide similar functionality to an external function bulletChart. In OO terms, think of nested objects.

2) . 1. , bullet . , OO , .

3) bullet . , bulletChart. , 19 36 ( d3), chart .call. chart 5 - , , .

Javascript, , .

+5

All Articles