Closed timhall closed 10 years ago
@john-clarke I think this is ready to merge to kickoff the iteration process on a smaller level
Recommendation: Can we rename the repo to d3.chart.csnw.configurable
? I think it fits better with the larger goal of creating a chart from configuration and line-bar is a little limiting.
Key points:
mixin()
extension to allow for multiple prototypal inheritanceseriesLayer
extensionUpdated Hierarchy:
Base (width, height, data)
|_ Container (rawData, chartBase, chartMargins, attachChart, attachComponent)
|_ ConfigurableChart (attaches components and charts by options)
|_ Component (positioning)
|_ Axis
|_ Legend
|_ Chart (x, y, scales)
|_ Labels (labels)
|_ ChartWithLabels (chart with labels attached)
|_ Bars
|_ Line
|_ LineValues
Example Usage:
var chart1 = d3.select('#chart_1')
.append('svg')
.chart('Configurable', {
charts: [
{
type: 'Bars',
dataKey: 'peopleParticipating',
yScale: {domain: [0, 20000]},
labelFontSize: 14,
labelOffset: 10,
labelPosition: 'top|bottom' // (top if positive or 0, bottom if negative)
},
{
type: 'LineValues',
dataKey: 'deathsPrevented',
yScale: {domain: [0, 70]},
labelPosition: 'top'
}
],
axes: [
{
type: 'AxisValues',
dataKey: 'peopleParticipating',
axisPosition: 'bottom'
},
{
type: 'AxisValues',
dataKey: 'peopleParticipating',
axisPosition: 'left'
},
{
type: 'AxisValues',
dataKey: 'deathsPrevented',
axisPosition: 'right'
}
],
legend: {
type: 'InsetLegend',
legendPosition: {x: 10, y: 0}
}
})
.width(600)
.height(400)
.chartMargins({top: 10});
Looks great, Tim. I've made the name change as requested.
Key points:
Container
is used to place charts (withchartBase
) so that individual charts don't have to worry about padding/margins and can instead be full-width and full-height and placed byContainer
Container
stores raw data and handles redraws when any dimensions changeXYBase
andCenteredValueBase
so that each chart gets a common data format and scales. Additionally, this data is first transformed in theContainer
so that a common transformation can be applied.property
helper is used to define chainable getters/setters for chartsdimensions
helper is used to robustly determine width and height of given chartHierarchy: