@@ -212,7 +212,8 @@ function chart(
212212 view_port_table_controls_visible : true ,
213213 misc_controls_table_controls_visible : true ,
214214 custom_domain : false ,
215- reset : false
215+ reset : false ,
216+ legend_columns : 5
216217 } ;
217218
218219 this . functions = { area : null , stack : null , line : null } ;
@@ -226,7 +227,7 @@ function chart(
226227
227228 this . dimensions = {
228229 margin : { top : 70 , right : 87 , bottom : 66 , left : 65 } ,
229- legend_properties : { columns : 5 , row_height : 30 , margin : { top : 37 } } ,
230+ legend_properties : { row_height : 30 , margin : { top : 37 } } ,
230231 total_width : 1000 ,
231232 total_height : 510 ,
232233 pixels_per_letter : 7.2
@@ -1557,8 +1558,8 @@ function navigate_to_chart(target) {
15571558function create_chart_dataset_objects ( chart ) {
15581559 update_domains ( chart ) ;
15591560
1560- if ( chart . datasets . all . length < chart . dimensions . legend_properties . columns ) {
1561- chart . dimensions . legend_properties . columns = chart . datasets . all . length ;
1561+ if ( chart . datasets . all . length < chart . state . legend_columns ) {
1562+ chart . state . legend_columns = chart . datasets . all . length ;
15621563 }
15631564
15641565 chart . chart . legend = chart . chart . container
@@ -1572,13 +1573,13 @@ function create_chart_dataset_objects(chart) {
15721573 "translate(" +
15731574 ( - chart . dimensions . margin . left +
15741575 5 +
1575- ( i % chart . dimensions . legend_properties . columns ) *
1576+ ( i % chart . state . legend_columns ) *
15761577 ( chart . dimensions . total_width /
1577- chart . dimensions . legend_properties . columns ) ) +
1578+ chart . state . legend_columns ) ) +
15781579 "," +
15791580 ( chart . dimensions . viewport_height +
15801581 chart . dimensions . legend_properties . margin . top +
1581- Math . floor ( i / chart . dimensions . legend_properties . columns ) *
1582+ Math . floor ( i / chart . state . legend_columns ) *
15821583 chart . dimensions . legend_properties . row_height ) +
15831584 ")"
15841585 ) ;
@@ -1640,7 +1641,7 @@ function create_chart_dataset_objects(chart) {
16401641 if (
16411642 label_width >=
16421643 chart . dimensions . total_width /
1643- chart . dimensions . legend_properties . columns -
1644+ chart . state . legend_columns -
16441645 legend_label_offset
16451646 ) {
16461647 var label = d3 . select ( this ) ;
@@ -1668,7 +1669,7 @@ function create_chart_dataset_objects(chart) {
16681669 chart . dimensions . legend_properties . margin . top +
16691670 ( Math . floor (
16701671 chart . datasets . all . length /
1671- chart . dimensions . legend_properties . columns
1672+ chart . state . legend_columns
16721673 ) +
16731674 i ) *
16741675 chart . dimensions . legend_properties . row_height ) +
@@ -5238,6 +5239,9 @@ function reset_chart(chart) {
52385239 chart . datasets . all . pop ( ) ;
52395240 }
52405241
5242+ chart . state . visible_datasets = 0 ;
5243+ chart . state . legend_columns = 5 ;
5244+
52415245 chart . dataset_count = 0 ;
52425246
52435247 reset_axes_domains ( chart ) ;
@@ -5251,7 +5255,7 @@ function get_svg_height(chart) {
52515255 return chart . dimensions . viewport_height +
52525256 chart . dimensions . margin . top +
52535257 chart . dimensions . margin . bottom +
5254- ( Math . ceil ( chart . datasets . all . length / chart . dimensions . legend_properties . columns ) -
5258+ ( Math . ceil ( chart . datasets . all . length / chart . state . legend_columns ) -
52555259 1 + chart . options . legend_entries . length
52565260 ) * chart . dimensions . legend_properties . row_height ;
52575261}
0 commit comments