Skip to content

Commit 9a24b3c

Browse files
authored
Merge pull request #41 from highcharts-for-python/v.1.4-rc-branch
PR for v.1.4.0
2 parents cafc0c8 + c2c79d1 commit 9a24b3c

File tree

111 files changed

+6859
-823
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+6859
-823
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ venv/
109109
ENV/
110110
env.bak/
111111
venv.bak/
112-
.py310/
112+
.py31*/
113113

114114
# Spyder project settings
115115
.spyderproject

CHANGES.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
2+
Release 1.4.0
3+
=========================================
4+
5+
* **MAJOR** performance gains in the ``.to_js_literal()`` method. Implementation seems to
6+
improve performance by 50 - 90%.
7+
* *SIGNIFICANT* performance gains in the ``.to_json()`` method. Implementation seems to
8+
improve performance by 30 - 90%.
9+
* **ENHANCEMENT:** Significantly simplified use of the ``.from_pandas()`` method to support:
10+
11+
* creation of multiple series from one DataFrame in one method call
12+
* creation of series without needing to specify a full property map
13+
* support for creating series by DataFrame row, rather than just by DataFrame column
14+
15+
* **ENHANCEMENT:** Added the ``.from_pandas_in_rows()`` method to support creation of
16+
charts and series from simple two-dimensional DataFrames laid out in rows.
17+
* **ENHANCEMENT:** Added one-shot chart creation and rendering from Series objects.
18+
* **ENHANCEMENT:** Added one-shot chart creation using ``series`` and ``data``/``series_type`` keywords.
19+
* **ENHANCEMENT:** Added ``.convert_to()`` convenience method to Series objects.
20+
* **ENHANCEMENT:** Added ``CallbackFunction.from_python()`` method which converts a Python function
21+
to its JavaScript equivalent using generative AI, with support for both OpenAI and Anthropic.
22+
* **BUGFIX:** Fixed instability issues in Jupyter Notebooks, both when operating as a Notebook (outside of
23+
Jupyter Lab) and when saved to a static HTML file.
24+
25+
---------------------
26+
127
Release 1.3.0
228
=========================================
329

README.rst

Lines changed: 89 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -207,115 +207,120 @@ Hello World, and Basic Usage
207207
1. 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
***********************
53.7 KB
Loading
24.2 KB
Loading
22.2 KB
Loading
30.8 KB
Loading
19.5 KB
Loading
Loading
13.8 KB
Loading

0 commit comments

Comments
 (0)