@@ -207,115 +207,120 @@ Hello World, and Basic Usage
2072071. Import Highcharts Gantt for Python
208208==========================================
209209
210- .. code-block :: python
211-
212- # BEST PRACTICE!
213- # PRECISE LOCATION PATTERN
214- # This method of importing Highcharts Gantt for Python objects yields the fastest
215- # performance for the import statement. However, it is more verbose and requires
216- # you to navigate the extensive Highcharts Gantt for Python API.
217-
218- # Import classes using precise module indications. For example:
219- from highcharts_gantt.chart import Chart
220- from highcharts_gantt.global_options.shared_options import SharedGanttOptions
221- from highcharts_gantt.options import HighchartsGanttOptions
222- from highcharts_gantt.options.plot_options.gantt import GanttOptions
223- from highcharts_gantt.options.series.gantt import GanttSeries
224-
225- # CATCH-ALL PATTERN
226- # This method of importing Highcharts Gantt for Python classes has relatively slow
227- # performance because it imports hundreds of different classes from across the entire
228- # library. This is also a known anti-pattern, as it obscures the namespace within the
229- # library. Both may be acceptable to you in your use-case, but do use at your own risk.
230-
231- # Import objects from the catch-all ".highcharts" module.
232- from highcharts_gantt import highcharts
233-
234- # You can now access specific classes without individual import statements.
235- highcharts.Chart
236- highcharts.SharedGanttOptions
237- highcharts.HighchartsGanttOptions
238- highcharts.GanttOptions
239- highcharts.GanttSeries
210+ .. code-block :: python
211+
212+ # PRECISE-LOCATION PATTERN: BEST PRACTICE!
213+ # This method of importing Highcharts for Python objects yields the fastest
214+ # performance for the import statement. However, it is more verbose and requires
215+ # you to navigate the extensive Highcharts Core for Python API.
216+
217+ # Import classes using precise module indications. For example:
218+ from highcharts_core.chart import Chart
219+ from highcharts_core.global_options.shared_options import SharedOptions
220+ from highcharts_core.options import HighchartsOptions
221+ from highcharts_core.options.plot_options.bar import BarOptions
222+ from highcharts_core.options.series.bar import BarSeries
223+
224+ # CATCH-ALL PATTERN
225+ # This method of importing Highcharts for Python classes has relatively slow
226+ # performance because it imports hundreds of different classes from across the entire
227+ # library. This performance impact may be acceptable to you in your use-case, but
228+ # do use at your own risk.
229+
230+ # Import objects from the catch-all ".highcharts" module.
231+ from highcharts_core import highcharts
232+
233+ # You can now access specific classes without individual import statements.
234+ highcharts.Chart
235+ highcharts.SharedOptions
236+ highcharts.HighchartsOptions
237+ highcharts.BarOptions
238+ highcharts.BarSeries
240239
241240
242241 2. Create Your Chart
243242================================
244243
245244 .. code-block :: python
246245
246+ # from a primitive array, using keyword arguments
247+ my_chart = Chart(data = [[1 , 23 ], [2 , 34 ], [3 , 45 ]],
248+ series_type = ' line' )
249+
250+ # from a primitive array, using the .from_array() method
251+ my_chart = Chart.from_array([[1 , 23 ], [2 , 34 ], [3 , 45 ]],
252+ series_type = ' line' )
253+
254+ # from a Numpy ndarray, using keyword arguments
255+ my_chart = Chart(data = numpy_array, series_type = ' line' )
256+
257+ # from a Numpy ndarray, using the .from_array() method
258+ my_chart = Chart.from_array(data = numpy_array, series_type = ' line' )
259+
247260 # from a JavaScript file
248- my_chart = highcharts. Chart.from_js_literal(' my_js_literal.js' )
261+ my_chart = Chart.from_js_literal(' my_js_literal.js' )
249262
250263 # from a JSON file
251- my_chart = highcharts. Chart.from_json(' my_json.json' )
264+ my_chart = Chart.from_json(' my_json.json' )
252265
253266 # from a Python dict
254- my_chart = highcharts. Chart.from_dict(my_dict_obj)
267+ my_chart = Chart.from_dict(my_dict_obj)
255268
256269 # from a Pandas dataframe
257- my_chart = highcharts.Chart.from_pandas(df,
258- property_map = {
259- ' x' : ' transactionDate' ,
260- ' y' : ' invoiceAmt' ,
261- ' id' : ' id'
262- },
263- series_type = ' line' )
270+ my_chart = Chart.from_pandas(df)
264271
265272 # from a PySpark dataframe
266- my_chart = highcharts. Chart.from_pyspark(df,
267- property_map = {
268- ' x' : ' transactionDate' ,
269- ' y' : ' invoiceAmt' ,
270- ' id' : ' id'
271- },
272- series_type = ' line' )
273+ my_chart = Chart.from_pyspark(df,
274+ property_map = {
275+ ' x' : ' transactionDate' ,
276+ ' y' : ' invoiceAmt' ,
277+ ' id' : ' id'
278+ },
279+ series_type = ' line' )
273280
274281 # from a CSV
275- my_chart = highcharts.Chart.from_csv(' /some_file_location/filename.csv'
276- column_property_map = {
277- ' x' : 0 ,
278- ' y' : 4 ,
279- ' id' : 14
280- },
281- series_type = ' line' )
282+ my_chart = Chart.from_csv(' /some_file_location/filename.csv' )
282283
283284 # from a HighchartsOptions configuration object
284- my_chart = highcharts.Chart.from_options(my_options)
285+ my_chart = Chart.from_options(my_options)
286+
287+ # from a Series configuration, using keyword arguments
288+ my_chart = Chart(series = my_series)
285289
286- # from a Series configuration
287- my_chart = highcharts. Chart.from_series(my_series)
290+ # from a Series configuration, using .from_series()
291+ my_chart = Chart.from_series(my_series)
288292
289293
290294 3. Configure Global Settings (optional)
291295=============================================
292296
293297 .. code-block :: python
294298
295- # Import SharedGanttOptions
296- from highcharts_gantt .global_options.shared_options import SharedGanttOptions
299+ # Import SharedOptions
300+ from highcharts_core .global_options.shared_options import SharedOptions
297301
298302 # from a JavaScript file
299- my_global_settings = SharedGanttOptions .from_js_literal(' my_js_literal.js' )
303+ my_global_settings = SharedOptions .from_js_literal(' my_js_literal.js' )
300304
301305 # from a JSON file
302- my_global_settings = SharedGanttOptions .from_json(' my_json.json' )
306+ my_global_settings = SharedOptions .from_json(' my_json.json' )
303307
304308 # from a Python dict
305- my_global_settings = SharedGanttOptions .from_dict(my_dict_obj)
309+ my_global_settings = SharedOptions .from_dict(my_dict_obj)
306310
307311 # from a HighchartsOptions configuration object
308- my_global_settings = SharedGanttOptions .from_options(my_options)
312+ my_global_settings = SharedOptions .from_options(my_options)
309313
310314
311315 4. Configure Your Chart / Global Settings
312316================================================
313317
314318 .. code-block :: python
315319
316- from highcharts_gantt .options.title import Title
317- from highcharts_gantt .options.credits import Credits
320+ from highcharts_core .options.title import Title
321+ from highcharts_core .options.credits import Credits
318322
323+ # EXAMPLE 1.
319324 # Using dicts
320325 my_chart.title = {
321326 ' align' : ' center'
@@ -326,7 +331,7 @@ Hello World, and Basic Usage
326331
327332 my_chart.credits = {
328333 ' enabled' : True ,
329- ' href' : ' https://www.highcharts .com/' ,
334+ ' href' : ' https://www.highchartspython .com/' ,
330335 ' position' : {
331336 ' align' : ' center' ,
332337 ' vertical_align' : ' bottom' ,
@@ -341,17 +346,21 @@ Hello World, and Basic Usage
341346 ' text' : ' Chris Modzelewski'
342347 }
343348
349+ # EXAMPLE 2.
344350 # Using direct objects
345- from highcharts_gantt .options.title import Title
346- from highcharts_gantt .options.credits import Credits
351+ from highcharts_core .options.title import Title
352+ from highcharts_core .options.credits import Credits
347353
348- my_title = Title(text = ' The Title for My Chart' , floating = True , align = ' center' )
354+ my_title = Title(text = ' The Title for My Chart' ,
355+ floating = True ,
356+ align = ' center' )
349357 my_chart.options.title = my_title
350358
351- my_credits = Credits(text = ' Chris Modzelewski' , enabled = True , href = ' https://www.highcharts.com' )
359+ my_credits = Credits(text = ' Chris Modzelewski' ,
360+ enabled = True ,
361+ href = ' https://www.highchartspython.com' )
352362 my_chart.options.credits = my_credits
353363
354-
355364 5. Generate the JavaScript Code for Your Chart
356365=================================================
357366
@@ -360,9 +369,11 @@ that will render the chart wherever it is you want it to go:
360369
361370 .. code-block :: python
362371
372+ # EXAMPLE 1.
363373 # as a string
364374 js_as_str = my_chart.to_js_literal()
365375
376+ # EXAMPLE 2.
366377 # to a file (and as a string)
367378 js_as_str = my_chart.to_js_literal(filename = ' my_target_file.js' )
368379
@@ -391,6 +402,13 @@ that will render the chart wherever it is you want it to go:
391402 my_image_bytes = my_chart.download_chart(filename = ' my_target_file.png' ,
392403 format = ' png' )
393404
405+ 8. Render Your Chart in a Jupyter Notebook
406+ ===============================================
407+
408+ .. code-block :: python
409+
410+ my_chart.display()
411+
394412--------------
395413
396414***********************
0 commit comments