@@ -4086,20 +4086,23 @@ def begin_presentation(
4086
4086
4087
4087
def create_pie_chart (
4088
4088
self , chart_name = None , title = None , subtitle = None ,
4089
- data_name = None , unit = None , libs = True ):
4089
+ data_name = None , unit = None , libs = True , labels = True , legend = True ):
4090
4090
""" Creates a JavaScript pie chart using "HighCharts".
4091
4091
@Params
4092
4092
chart_name - If creating multiple charts,
4093
4093
use this to select which one.
4094
4094
title - The title displayed for the chart.
4095
4095
subtitle - The subtitle displayed for the chart.
4096
- data_name - Set the series name. Useful for multi-series charts.
4096
+ data_name - The series name. Useful for multi-series charts.
4097
+ If no data_name, will default to using "Series 1".
4097
4098
unit - The description label given to the chart's y-axis values.
4098
4099
libs - The option to include Chart libraries (JS and CSS files).
4099
4100
Should be set to True (default) for the first time creating
4100
4101
a chart on a web page. If creating multiple charts on the
4101
4102
same web page, you won't need to re-import the libraries
4102
4103
when creating additional charts.
4104
+ labels - If True, displays labels on the chart for data points.
4105
+ legend - If True, displays the data point legend on the chart.
4103
4106
"""
4104
4107
if not chart_name :
4105
4108
chart_name = "default"
@@ -4108,24 +4111,28 @@ def create_pie_chart(
4108
4111
style = "pie"
4109
4112
self .__create_highchart (
4110
4113
chart_name = chart_name , title = title , subtitle = subtitle ,
4111
- style = style , data_name = data_name , unit = unit , libs = libs )
4114
+ style = style , data_name = data_name , unit = unit , libs = libs ,
4115
+ labels = labels , legend = legend )
4112
4116
4113
4117
def create_bar_chart (
4114
4118
self , chart_name = None , title = None , subtitle = None ,
4115
- data_name = None , unit = None , libs = True ):
4119
+ data_name = None , unit = None , libs = True , labels = True , legend = True ):
4116
4120
""" Creates a JavaScript bar chart using "HighCharts".
4117
4121
@Params
4118
4122
chart_name - If creating multiple charts,
4119
4123
use this to select which one.
4120
4124
title - The title displayed for the chart.
4121
4125
subtitle - The subtitle displayed for the chart.
4122
- data_name - Set the series name. Useful for multi-series charts.
4126
+ data_name - The series name. Useful for multi-series charts.
4127
+ If no data_name, will default to using "Series 1".
4123
4128
unit - The description label given to the chart's y-axis values.
4124
4129
libs - The option to include Chart libraries (JS and CSS files).
4125
4130
Should be set to True (default) for the first time creating
4126
4131
a chart on a web page. If creating multiple charts on the
4127
4132
same web page, you won't need to re-import the libraries
4128
4133
when creating additional charts.
4134
+ labels - If True, displays labels on the chart for data points.
4135
+ legend - If True, displays the data point legend on the chart.
4129
4136
"""
4130
4137
if not chart_name :
4131
4138
chart_name = "default"
@@ -4134,24 +4141,28 @@ def create_bar_chart(
4134
4141
style = "bar"
4135
4142
self .__create_highchart (
4136
4143
chart_name = chart_name , title = title , subtitle = subtitle ,
4137
- style = style , data_name = data_name , unit = unit , libs = libs )
4144
+ style = style , data_name = data_name , unit = unit , libs = libs ,
4145
+ labels = labels , legend = legend )
4138
4146
4139
4147
def create_column_chart (
4140
4148
self , chart_name = None , title = None , subtitle = None ,
4141
- data_name = None , unit = None , libs = True ):
4149
+ data_name = None , unit = None , libs = True , labels = True , legend = True ):
4142
4150
""" Creates a JavaScript column chart using "HighCharts".
4143
4151
@Params
4144
4152
chart_name - If creating multiple charts,
4145
4153
use this to select which one.
4146
4154
title - The title displayed for the chart.
4147
4155
subtitle - The subtitle displayed for the chart.
4148
- data_name - Set the series name. Useful for multi-series charts.
4156
+ data_name - The series name. Useful for multi-series charts.
4157
+ If no data_name, will default to using "Series 1".
4149
4158
unit - The description label given to the chart's y-axis values.
4150
4159
libs - The option to include Chart libraries (JS and CSS files).
4151
4160
Should be set to True (default) for the first time creating
4152
4161
a chart on a web page. If creating multiple charts on the
4153
4162
same web page, you won't need to re-import the libraries
4154
4163
when creating additional charts.
4164
+ labels - If True, displays labels on the chart for data points.
4165
+ legend - If True, displays the data point legend on the chart.
4155
4166
"""
4156
4167
if not chart_name :
4157
4168
chart_name = "default"
@@ -4160,25 +4171,30 @@ def create_column_chart(
4160
4171
style = "column"
4161
4172
self .__create_highchart (
4162
4173
chart_name = chart_name , title = title , subtitle = subtitle ,
4163
- style = style , data_name = data_name , unit = unit , libs = libs )
4174
+ style = style , data_name = data_name , unit = unit , libs = libs ,
4175
+ labels = labels , legend = legend )
4164
4176
4165
4177
def create_line_chart (
4166
4178
self , chart_name = None , title = None , subtitle = None ,
4167
- data_name = None , unit = None , zero = False , libs = True ):
4179
+ data_name = None , unit = None , zero = False , libs = True ,
4180
+ labels = True , legend = True ):
4168
4181
""" Creates a JavaScript line chart using "HighCharts".
4169
4182
@Params
4170
4183
chart_name - If creating multiple charts,
4171
4184
use this to select which one.
4172
4185
title - The title displayed for the chart.
4173
4186
subtitle - The subtitle displayed for the chart.
4174
- data_name - Set the series name. Useful for multi-series charts.
4187
+ data_name - The series name. Useful for multi-series charts.
4188
+ If no data_name, will default to using "Series 1".
4175
4189
unit - The description label given to the chart's y-axis values.
4176
4190
zero - If True, the y-axis always starts at 0. (Default: False).
4177
4191
libs - The option to include Chart libraries (JS and CSS files).
4178
4192
Should be set to True (default) for the first time creating
4179
4193
a chart on a web page. If creating multiple charts on the
4180
4194
same web page, you won't need to re-import the libraries
4181
4195
when creating additional charts.
4196
+ labels - If True, displays labels on the chart for data points.
4197
+ legend - If True, displays the data point legend on the chart.
4182
4198
"""
4183
4199
if not chart_name :
4184
4200
chart_name = "default"
@@ -4187,25 +4203,30 @@ def create_line_chart(
4187
4203
style = "line"
4188
4204
self .__create_highchart (
4189
4205
chart_name = chart_name , title = title , subtitle = subtitle ,
4190
- style = style , data_name = data_name , unit = unit , zero = zero , libs = libs )
4206
+ style = style , data_name = data_name , unit = unit , zero = zero , libs = libs ,
4207
+ labels = labels , legend = legend )
4191
4208
4192
4209
def create_area_chart (
4193
4210
self , chart_name = None , title = None , subtitle = None ,
4194
- data_name = None , unit = None , zero = False , libs = True ):
4211
+ data_name = None , unit = None , zero = False , libs = True ,
4212
+ labels = True , legend = True ):
4195
4213
""" Creates a JavaScript area chart using "HighCharts".
4196
4214
@Params
4197
4215
chart_name - If creating multiple charts,
4198
4216
use this to select which one.
4199
4217
title - The title displayed for the chart.
4200
4218
subtitle - The subtitle displayed for the chart.
4201
- data_name - Set the series name. Useful for multi-series charts.
4219
+ data_name - The series name. Useful for multi-series charts.
4220
+ If no data_name, will default to using "Series 1".
4202
4221
unit - The description label given to the chart's y-axis values.
4203
4222
zero - If True, the y-axis always starts at 0. (Default: False).
4204
4223
libs - The option to include Chart libraries (JS and CSS files).
4205
4224
Should be set to True (default) for the first time creating
4206
4225
a chart on a web page. If creating multiple charts on the
4207
4226
same web page, you won't need to re-import the libraries
4208
4227
when creating additional charts.
4228
+ labels - If True, displays labels on the chart for data points.
4229
+ legend - If True, displays the data point legend on the chart.
4209
4230
"""
4210
4231
if not chart_name :
4211
4232
chart_name = "default"
@@ -4214,11 +4235,13 @@ def create_area_chart(
4214
4235
style = "area"
4215
4236
self .__create_highchart (
4216
4237
chart_name = chart_name , title = title , subtitle = subtitle ,
4217
- style = style , data_name = data_name , unit = unit , zero = zero , libs = libs )
4238
+ style = style , data_name = data_name , unit = unit , zero = zero , libs = libs ,
4239
+ labels = labels , legend = legend )
4218
4240
4219
4241
def __create_highchart (
4220
4242
self , chart_name = None , title = None , subtitle = None ,
4221
- style = None , data_name = None , unit = None , zero = False , libs = True ):
4243
+ style = None , data_name = None , unit = None , zero = False , libs = True ,
4244
+ labels = True , legend = True ):
4222
4245
""" Creates a JavaScript chart using the "HighCharts" library. """
4223
4246
if not chart_name :
4224
4247
chart_name = "default"
@@ -4232,6 +4255,14 @@ def __create_highchart(
4232
4255
data_name = "Series 1"
4233
4256
if not unit :
4234
4257
unit = "Values"
4258
+ if labels :
4259
+ labels = "true"
4260
+ else :
4261
+ labels = "false"
4262
+ if legend :
4263
+ legend = "true"
4264
+ else :
4265
+ legend = "false"
4235
4266
title = title .replace ("'" , "\\ '" )
4236
4267
subtitle = subtitle .replace ("'" , "\\ '" )
4237
4268
unit = unit .replace ("'" , "\\ '" )
@@ -4355,25 +4386,45 @@ def __create_highchart(
4355
4386
padding: '6px',
4356
4387
fontSize: '14px'
4357
4388
},
4389
+ backgroundColor: {
4390
+ linearGradient: {
4391
+ x1: 0,
4392
+ y1: 0,
4393
+ x2: 0,
4394
+ y2: 1
4395
+ },
4396
+ stops: [
4397
+ [0, 'rgba(255, 255, 255, 0.78)'],
4398
+ [0.5, 'rgba(235, 235, 235, 0.76)'],
4399
+ [1, 'rgba(244, 252, 255, 0.74)']
4400
+ ]
4401
+ },
4402
+ hideDelay: 40,
4358
4403
pointFormat: '%s'
4359
4404
},
4360
4405
""" % point_format )
4361
4406
chart_init_3 = (
4362
- r """
4407
+ """
4363
4408
accessibility: {
4364
4409
point: {
4365
- valueSuffix: '%'
4410
+ valueSuffix: '%% '
4366
4411
}
4367
4412
},
4368
4413
plotOptions: {
4414
+ series: {
4415
+ states: {
4416
+ inactive: {
4417
+ opacity: 0.85
4418
+ }
4419
+ }
4420
+ },
4369
4421
pie: {
4370
- size: "95%",
4422
+ size: "95%% ",
4371
4423
allowPointSelect: true,
4372
4424
animation: false,
4373
4425
cursor: 'pointer',
4374
4426
dataLabels: {
4375
- // enabled: false,
4376
- // format: '{point.name}: {point.y:.0f}',
4427
+ enabled: %s,
4377
4428
formatter: function() {
4378
4429
if (this.y > 0) {
4379
4430
return this.point.name + ': ' + this.point.y
@@ -4385,10 +4436,10 @@ def __create_highchart(
4385
4436
enabled: true
4386
4437
}
4387
4438
},
4388
- showInLegend: true
4439
+ showInLegend: %s
4389
4440
}
4390
4441
},
4391
- """ )
4442
+ """ % ( labels , legend ) )
4392
4443
if style != "pie" :
4393
4444
chart_init_3 = (
4394
4445
"""
@@ -4406,11 +4457,11 @@ def __create_highchart(
4406
4457
},
4407
4458
plotOptions: {
4408
4459
series: {
4409
- showInLegend: true,
4410
- animation: false,
4411
4460
dataLabels: {
4412
- enabled: true
4461
+ enabled: %s
4413
4462
},
4463
+ showInLegend: %s,
4464
+ animation: false,
4414
4465
shadow: false,
4415
4466
lineWidth: 3,
4416
4467
fillOpacity: 0.5,
@@ -4419,7 +4470,7 @@ def __create_highchart(
4419
4470
}
4420
4471
}
4421
4472
},
4422
- """ )
4473
+ """ % ( labels , legend ) )
4423
4474
chart_init = chart_init_1 + chart_init_2 + chart_init_3
4424
4475
color_by_point = "true"
4425
4476
if style != "pie" :
0 commit comments