Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
High-end Data Visualization for the Python Ecosystem. Official wrapper for Highcharts Core (JS).
################################################### Highcharts Core for Python ###################################################
High-end data visualization for the Python ecosystem
Highcharts Core for Python is a Python library that provides a Python wrapper
for the Highcharts Core <https://www.highcharts.com/products/highcharts/>
__ JavaScript data
visualization library, with full integration into the robust Python ecosystem, including:
The library supports Highcharts (JS) v.10.2 and higher, including Highcharts (JS) v.11.4.0.
COMPLETE DOCUMENTATION: https://core-docs.highchartspython.com/en/latest/index.html
The Highcharts for Python Toolkit
The Highcharts Core for Python library is - as the name suggests - the core library in
the broader Highcharts for Python Toolkit <https://www.highcharts.com/integrations/python>
,
which together provides comprehensive support across the entire
Highcharts <https://www.highcharts.com>
suite of data visualization libraries:
.. list-table:: :widths: 30 30 40 :header-rows: 1
Highcharts Core (JS) <https://www.highcharts.com/products/highcharts/>
__Highcharts Stock for Python <https://stock-docs.highchartspython.com/>
__Highcharts Stock (JS) <https://www.highcharts.com/products/stock/>
__Highcharts Maps for Python <https://maps-docs.highchartspython.com/>
__Highcharts Maps (JS) <https://www.highcharts.com/products/maps/>
__Highcharts Gantt for Python <https://gantt-docs.highchartspython.com/>
__Highcharts Gantt (JS) <https://www.highcharts.com/products/gantt/>
__Installation
To install Highcharts Core for Python, just execute:
.. code:: bash
$ pip install highcharts-core
Before you install, please be aware of the following "hard" dependencies:
esprima-python <https://github.com/Kronuz/esprima-python>
__ v.4.0 or higherrequests <https://requests.readthedocs.io/en/latest/>
__ v.2.31 or highervalidator-collection <https://validator-collection.readthedocs.io/en/latest/>
__
v.1.5 or higherYou can find more information about soft and development dependencies in the
complete documentation <https://core-docs.highchartspython.com/en/latest/#dependencies>
__.
Why Highcharts for Python?
Highcharts <https://www.highcharts.com>
__ is the world's most popular, most powerful,
category-defining JavaScript data visualization library. If you are building a web or
mobile app/dashboard that will be visualizing data in some fashion, you should
absolutely take a look at the Highcharts suite of solutions. Take a peak at some
fantastic demo visualizations <https://www.highcharts.com/demo>
__.
As a suite of JavaScript libraries, Highcharts <https://www.highcharts.com>
__ is
written in JavaScript, and is used to configure and render data visualizations in a
web browser (or other JavaScript-executing) environment. As a set of JavaScript
libraries, its audience is JavaScript developers. But what about the broader ecosystem of
Python developers and data scientists?
Given Python's increasing adoption as the technology of choice for data science and for the backends of leading enterprise-grade applications, Python is often the backend that delivers data and content to the front-end...which then renders it using JavaScript and HTML.
There are numerous Python frameworks (Django, Flask, Tornado, etc.) with specific capabilities to simplify integration with Javascript frontend frameworks (React, Angular, VueJS, etc.). But facilitating that with Highcharts has historically been very difficult. Part of this difficulty is because the Highcharts JavaScript suite - while supporting JSON as a serialization/deserialization format - leverages JavaScript object literals to expose the full power and interactivity of its data visualizations. And while it's easy to serialize JSON from Python, serializing and deserializing to/from JavaScript object literal notation is much more complicated.
This means that Python developers looking to integrate with Highcharts typically had to either invest a lot of effort, or were only able to leverage a small portion of Highcharts' rich functionality.
So we wrote the Highcharts for Python toolkit to bridge that gap.
Highcharts for Python provides Python object representation for all of the
JavaScript objects defined in the
Highcharts (JavaScript) API <https://api.highcharts.com/highcharts/>
__. It provides automatic
data validation, and exposes simple and standardized methods for serializing those Python
objects back-and-forth to JavaScript object literal notation.
Clean and consistent API. No reliance on "hacky" code, dict
and JSON serialization, or impossible to maintain / copy-pasted "spaghetti code".
Comprehensive Highcharts Support. Every single Highcharts chart type and every
single configuration option is supported in the Highcharts for Python toolkit.
Highcharts Core for Python includes support for the over 70 data visualization types
supported by Highcharts Core <https://www.highcharts.com/product/highcharts/>
__ and
while other libraries in the toolkit support the 50+ technical indicator visualizations
available in Highcharts Stock <https://www.highcharts.com/product/stock/>
__.
Every Highcharts for Python library provides full support for the rich JavaScript formatter (JS callback functions) capabilities that are often needed to get the most out of Highcharts' visualization and interaction capabilities.
.. note::
See Also
Supported Visualizations <https://core-docs.highchartspython.com/en/latest/visualizations.html>
__Simple JavaScript Code Generation. With one method call, produce production-ready JavaScript code to render your interactive visualizations using Highcharts' rich capabilities.
Easy and Robust Chart Download. With one method call, produce high-end static visualizations that can be downloaded or shared as files with your audience. Produce static charts using the Highsoft-provided Highcharts Export Server, or using your own private export server as needed.
Integration with Pandas and PySpark. With two lines of code, produce a high-end interactive visualization of your Pandas or PySpark dataframe.
Consistent code style. For Python developers, switching between Pythonic code
conventions and JavaScript code conventions can be...annoying. So
the Highcharts for Python toolkit applies Pythonic syntax with automatic conversion between
Pythonic snake_case
notation and JavaScript camelCase
styles.
|
For a discussion of Highcharts for Python in comparison to alternatives, please see the COMPLETE DOCUMENTATION: https://core-docs.highchartspython.com/en/latest/index.html
Hello World, and Basic Usage
.. code-block:: python
from highcharts_core.chart import Chart from highcharts_core.global_options.shared_options import SharedOptions from highcharts_core.options import HighchartsOptions from highcharts_core.options.plot_options.bar import BarOptions from highcharts_core.options.series.bar import BarSeries
from highcharts_core import highcharts
highcharts.Chart highcharts.SharedOptions highcharts.HighchartsOptions highcharts.BarOptions highcharts.BarSeries
.. code-block:: python
# from a primitive array, using keyword arguments
my_chart = Chart(data = [[1, 23], [2, 34], [3, 45]],
series_type = 'line')
# from a primitive array, using the .from_array() method
my_chart = Chart.from_array([[1, 23], [2, 34], [3, 45]],
series_type = 'line')
# from a Numpy ndarray, using keyword arguments
my_chart = Chart(data = numpy_array, series_type = 'line')
# from a Numpy ndarray, using the .from_array() method
my_chart = Chart.from_array(data = numpy_array, series_type = 'line')
# from a JavaScript file
my_chart = Chart.from_js_literal('my_js_literal.js')
# from a JSON file
my_chart = Chart.from_json('my_json.json')
# from a Python dict
my_chart = Chart.from_dict(my_dict_obj)
# from a Pandas dataframe
my_chart = Chart.from_pandas(df)
# from a PySpark dataframe
my_chart = Chart.from_pyspark(df,
property_map = {
'x': 'transactionDate',
'y': 'invoiceAmt',
'id': 'id'
},
series_type = 'line')
# from a CSV
my_chart = Chart.from_csv('/some_file_location/filename.csv')
# from a HighchartsOptions configuration object
my_chart = Chart.from_options(my_options)
# from a Series configuration, using keyword arguments
my_chart = Chart(series = my_series)
# from a Series configuration, using .from_series()
my_chart = Chart.from_series(my_series)
.. code-block:: python
# Import SharedOptions
from highcharts_core.global_options.shared_options import SharedOptions
# from a JavaScript file
my_global_settings = SharedOptions.from_js_literal('my_js_literal.js')
# from a JSON file
my_global_settings = SharedOptions.from_json('my_json.json')
# from a Python dict
my_global_settings = SharedOptions.from_dict(my_dict_obj)
# from a HighchartsOptions configuration object
my_global_settings = SharedOptions.from_options(my_options)
.. code-block:: python
from highcharts_core.options.title import Title
from highcharts_core.options.credits import Credits
# EXAMPLE 1.
# Using dicts
my_chart.title = {
'align': 'center',
'floating': True,
'text': 'The Title for My Chart',
'use_html': False,
}
my_chart.credits = {
'enabled': True,
'href': 'https://www.highchartspython.com/',
'position': {
'align': 'center',
'vertical_align': 'bottom',
'x': 123,
'y': 456
},
'style': {
'color': '#cccccc',
'cursor': 'pointer',
'font_size': '9px'
},
'text': 'Chris Modzelewski'
}
# EXAMPLE 2.
# Using direct objects
from highcharts_core.options.title import Title
from highcharts_core.options.credits import Credits
my_title = Title(text = 'The Title for My Chart',
floating = True,
align = 'center')
my_chart.options.title = my_title
my_credits = Credits(text = 'Chris Modzelewski',
enabled = True,
href = 'https://www.highchartspython.com')
my_chart.options.credits = my_credits
# EXAMPLE 3.
# Pandas with time series
import pandas as pd
import datetime as dt
import numpy as np
df = pd.DataFrame([
{"ref_date": dt.date(2024, 1, 1), "data": 1},
{"ref_date": dt.date(2024, 1, 2), "data": 5},
{"ref_date": dt.date(2024, 1, 3), "data": None},
{"ref_date": dt.date(2024, 1, 4), "data": 4},
{"ref_date": dt.date(2024, 1, 5), "data": None},
])
df['ref_date'] = pd.to_datetime(df['ref_date'])
df.set_index('ref_date', inplace=True)
df.index = (df.index.astype(np.int64) / 10**6).astype(np.int64)
# Correcting nanoseconds to epoch, which is crucial for javascript rendering,
# See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now
# for more information on this behaviour
from highcharts_core.chart import Chart
chart = Chart.from_pandas(
df=df.reset_index(),
series_type='line',
property_map={
'x': df.index.name,
'y': df.columns.to_list()
}
)
chart.options.x_axis = {
'type': 'datetime'
}
chart.display()
Now having configured your chart in full, you can easily generate the JavaScript code that will render the chart wherever it is you want it to go:
.. code-block:: python
# EXAMPLE 1.
# as a string
js_as_str = my_chart.to_js_literal()
# EXAMPLE 2.
# to a file (and as a string)
js_as_str = my_chart.to_js_literal(filename = 'my_target_file.js')
.. code-block:: python
# as a string
global_settings_js = my_global_settings.to_js_literal()
# to a file (and as a string)
global_settings_js = my_global_settings.to_js_literal('my_target_file.js')
.. code-block:: python
# as in-memory bytes
my_image_bytes = my_chart.download_chart(format = 'png')
# to an image file (and as in-memory bytes)
my_image_bytes = my_chart.download_chart(filename = 'my_target_file.png',
format = 'png')
.. code-block:: python
my_chart.display()
Getting Help/Support
The Highcharts for Python toolkit comes with all of the great support that you are used to from working with the Highcharts JavaScript libraries. When you license the toolkit, you are welcome to use any of the following tools to get help using the toolkit. In particular, you can:
Highcharts Forums <https://highcharts.com/forum>
__Stack Overflow <https://stackoverflow.com/questions/tagged/highcharts-for-python>
__ with the
highcharts-for-python
tagReport bugs or request features <https://github.com/highcharts-for-python/highcharts-core/issues>
__ in the
library's Github repositoryFile a support ticket <https://www.highchartspython.com/get-help>
__ with usSchedule a live chat or video call <https://www.highchartspython.com/get-help>
__ with usFOR MORE INFORMATION: https://www.highchartspython.com/get-help
Contributing
We welcome contributions and pull requests! For more information, please see the
Contributor Guide <https://core-docs.highchartspython.com/en/latest/contributing.html>
__.
And thanks to all those who've already contributed!
Testing
We use TravisCI <https://travisci.com>
_ for our build automation and
ReadTheDocs <https://readthedocs.com>
_ for our documentation.
Detailed information about our test suite and how to run tests locally can be found in our Testing Reference.
FAQs
High-end Data Visualization for the Python Ecosystem. Official wrapper for Highcharts Core (JS).
We found that highcharts-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.