Skip to main content
deleted 10 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[Legended[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /.
        {True -> Red, False -> Green}] ], 
      ChartStyle -> {Green, Red}] &@ 
      Tally@Sort@RandomChoice[Tally@RandomChoice[{True, False}, n], 
     SwatchLegend[{Green, Red}, {False, True}]]]}]]

Mathematica graphics

Mathematica graphics

Alternatively (thanks: Brett Champion):

DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /. 
                      {True -> Red, False -> Green}]], 
       ChartLegends -> SwatchLegend[{Green, Red}, {False, True}]] &@
     Tally@Sort@RandomChoice[Tally@RandomChoice[{True, False}, n]]}]]
DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[Legended[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /.
        {True -> Red, False -> Green}] ], 
      ChartStyle -> {Green, Red}] &@ 
      Tally@Sort@RandomChoice[{True, False}, n], 
     SwatchLegend[{Green, Red}, {False, True}]]]}]]

Mathematica graphics

Mathematica graphics

Alternatively (thanks: Brett Champion):

DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /. 
                      {True -> Red, False -> Green}]], 
       ChartLegends -> SwatchLegend[{Green, Red}, {False, True}]] &@
     Tally@Sort@RandomChoice[{True, False}, n]]}]]
DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[Legended[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /.
        {True -> Red, False -> Green}] ], 
      ChartStyle -> {Green, Red}] &@ 
      Tally@RandomChoice[{True, False}, n], 
     SwatchLegend[{Green, Red}, {False, True}]]]}]]

Mathematica graphics

Mathematica graphics

Alternatively (thanks: Brett Champion):

DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /. 
                      {True -> Red, False -> Green}]], 
       ChartLegends -> SwatchLegend[{Green, Red}, {False, True}]] &@
     Tally@RandomChoice[{True, False}, n]]}]]
added 98 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[Legended[PieChart[#[[AllDynamic[Legended[PieChart[Thread[Style[#[[All, 2]], ChartStyle#[[All, 1]] /.
        {True -> {GreenRed, Red}]False &@
-> Green}] ],  
      ChartStyle -> {Green, Red}] &@  
      Tally@Sort@RandomChoice[{True, False}, n], 
           SwatchLegend[{Green, Red}, {False, True}]]]}]]

Mathematica graphics

Mathematica graphics

Alternatively (thanks: Brett Champion):

DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /.  
 Dynamic[PieChart[#[[All, 2]], ChartStyle -> {Green, Red}, 
                {True -> Red, False -> Green}]],  
       ChartLegends -> SwatchLegend[{Green, Red}, {False, True}]] &@
                 Tally@Sort@RandomChoice[{True, False}, n]]}]]
DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[Legended[PieChart[#[[All, 2]], ChartStyle -> {Green, Red}] &@
                    Tally@Sort@RandomChoice[{True, False}, n], 
           SwatchLegend[{Green, Red}, {False, True}]]]}]]

Mathematica graphics

Mathematica graphics

Alternatively (thanks: Brett Champion):

DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
         Dynamic[PieChart[#[[All, 2]], ChartStyle -> {Green, Red}, 
                           ChartLegends -> SwatchLegend[{Green, Red}, {False, True}]] &@
                 Tally@Sort@RandomChoice[{True, False}, n]]}]]
DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[Legended[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /.
        {True -> Red, False -> Green}] ],  
      ChartStyle -> {Green, Red}] &@  
      Tally@Sort@RandomChoice[{True, False}, n], 
     SwatchLegend[{Green, Red}, {False, True}]]]}]]

Mathematica graphics

Mathematica graphics

Alternatively (thanks: Brett Champion):

DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[PieChart[Thread[Style[#[[All, 2]], #[[All, 1]] /.  
                      {True -> Red, False -> Green}]],  
       ChartLegends -> SwatchLegend[{Green, Red}, {False, True}]] &@
     Tally@Sort@RandomChoice[{True, False}, n]]}]]
added 376 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[Legended[PieChart[#[[All, 2]], ChartStyle -> {Green, Red}] &@
                    Tally@Sort@RandomChoice[{True, False}, n], 
           SwatchLegend[{Green, Red}, {False, True}]]]}]]

Mathematica graphics

Mathematica graphics

Alternatively (thanks: Brett Champion):

DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
         Dynamic[PieChart[#[[All, 2]], ChartStyle -> {Green, Red}, 
                          ChartLegends -> SwatchLegend[{Green, Red}, {False, True}]] &@
                 Tally@Sort@RandomChoice[{True, False}, n]]}]]
DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[Legended[PieChart[#[[All, 2]], ChartStyle -> {Green, Red}] &@
                    Tally@Sort@RandomChoice[{True, False}, n], 
           SwatchLegend[{Green, Red}, {False, True}]]]}]]

Mathematica graphics

Mathematica graphics

DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
   Dynamic[Legended[PieChart[#[[All, 2]], ChartStyle -> {Green, Red}] &@
                    Tally@Sort@RandomChoice[{True, False}, n], 
           SwatchLegend[{Green, Red}, {False, True}]]]}]]

Mathematica graphics

Mathematica graphics

Alternatively (thanks: Brett Champion):

DynamicModule[{n = 20}, 
 Column[{Row[{Slider[Dynamic[n], {1, 100, 1}], Dynamic[n]}], 
         Dynamic[PieChart[#[[All, 2]], ChartStyle -> {Green, Red}, 
                          ChartLegends -> SwatchLegend[{Green, Red}, {False, True}]] &@
                 Tally@Sort@RandomChoice[{True, False}, n]]}]]
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading