From 22b6e0f065e842c1d69b81b848fdab612f12d5b1 Mon Sep 17 00:00:00 2001 From: Jonathan Laver Date: Fri, 19 Dec 2014 15:21:31 +0000 Subject: [PATCH 01/70] show labels and rotatelabels --- nvd3/NVD3Chart.py | 4 ++++ nvd3/templates/content.html | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 53451023..e36dae1a 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -71,6 +71,8 @@ def __init__(self, **kwargs): :keyword: **width** - default - ``''`` :keyword: **stacked** - default - ``False`` :keyword: **resize** - define - ``False`` + :keyword: **xAxis_rotateLabel** - default - ``0`` + :keyword: **show_controls** - default - ``True`` :keyword: **show_legend** - default - ``True`` :keyword: **show_labels** - default - ``True`` :keyword: **tag_script_js** - default - ``True`` @@ -117,6 +119,8 @@ def __init__(self, **kwargs): self.width = kwargs.get('width', '') self.stacked = kwargs.get('stacked', False) self.resize = kwargs.get('resize', False) + self.xAxis_rotateLabel = kwargs.get('xAxis_rotateLabel', 0) + self.show_controls = kwargs.get('show_controls', True) self.show_legend = kwargs.get('show_legend', True) self.show_labels = kwargs.get('show_labels', True) self.tag_script_js = kwargs.get('tag_script_js', True) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index e3bf732d..277a5c6f 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -12,9 +12,10 @@ {% block init %} nv.addGraph(function() { - var chart = nv.models.{{ chart.model }}(){% if chart.use_interactive_guideline %}.useInteractiveGuideline(true){% endif %}; + var chart = nv.models.{{ chart.model }}(){% if chart.use_interactive_guideline %}.useInteractiveGuideline(true){% endif %}{% if not chart.show_controls %}.showControls(false){% endif %}; chart.margin({top: {{ chart.margin_top }}, right: {{ chart.margin_right }}, bottom: {{ chart.margin_bottom }}, left: {{ chart.margin_left }}}); + chart.xAxis.rotateLabels({{chart.xAxis_rotateLabel}}) var datum = data_{{ chart.name }}; From 1058dfdce4d68a07f0d960611580d2d14ef041ac Mon Sep 17 00:00:00 2001 From: Anthony Yee Date: Sun, 8 Nov 2015 22:10:06 -0800 Subject: [PATCH 02/70] Added callback --- nvd3/NVD3Chart.py | 1 + nvd3/pieChart.py | 1 + nvd3/templates/content.html | 5 +++++ nvd3/templates/piechart.html | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 66699363..7f43a18d 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -137,6 +137,7 @@ def __init__(self, **kwargs): self.x_axis_format = kwargs.get('x_axis_format', '') # Load remote JS assets or use the local bower assets? self.remote_js_assets = kwargs.get('remote_js_assets', True) + self.callback = kwargs.get('callback', None) # None keywords attribute that should be modified by methods # We should change all these to _attr diff --git a/nvd3/pieChart.py b/nvd3/pieChart.py index 1db76bdb..bcaf0492 100644 --- a/nvd3/pieChart.py +++ b/nvd3/pieChart.py @@ -99,3 +99,4 @@ def __init__(self, **kwargs): self.set_graph_width(width) self.donut = kwargs.get('donut', False) self.donutRatio = kwargs.get('donutRatio', 0.35) + self.callback = kwargs.get('callback', None) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 787f39b5..1d799c9d 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -115,6 +115,11 @@ {{ chart.extras }} {% endif %} + {# callback for clicking on charts #} + {% if chart.callback %} + },{{ chart.callback }}); + {% endif %} + {# closing nv.addGraph #} {% block close %} }); diff --git a/nvd3/templates/piechart.html b/nvd3/templates/piechart.html index a200e6d4..0c11a158 100644 --- a/nvd3/templates/piechart.html +++ b/nvd3/templates/piechart.html @@ -73,6 +73,10 @@ {{super()}} {% endblock inject %} + {% if chart.callback %} + },{{ chart.callback }}); + {% endif %} + {% block close %} {{ super() }} {% endblock close %} From 2985fadff7bf867d3d64b2160a184fb27ccbb249 Mon Sep 17 00:00:00 2001 From: Anthony Yee Date: Tue, 24 Nov 2015 11:30:06 -0800 Subject: [PATCH 03/70] Added callback examples to pie and multibar charts --- examples/multiBarChart.py | 8 ++++++++ examples/pieChart.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/examples/multiBarChart.py b/examples/multiBarChart.py index 709e662d..667046db 100644 --- a/examples/multiBarChart.py +++ b/examples/multiBarChart.py @@ -18,6 +18,14 @@ type = "multiBarChart" chart = multiBarChart(name=type, height=350) chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.callback = ''' + function(){ + d3.selectAll(".nv-bar").on('click', + function(d){ + console.log("barchart_callback_test: clicked on bar " + JSON.stringify(d)); + console.log('/app/call?x='.concat(d['x'])); + } + ''' nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(1, 10) for i in range(nb_element)] diff --git a/examples/pieChart.py b/examples/pieChart.py index ed92f3e0..618c885d 100644 --- a/examples/pieChart.py +++ b/examples/pieChart.py @@ -18,6 +18,14 @@ type = "pieChart" chart = pieChart(name=type, color_category='category20c', height=400, width=400) chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.callback = ''' + function(){ + d3.selectAll(".nv-pie .nv-pie .nv-slice").on('click', + function(d){ + console.log("piechart_callback_test: clicked on slice " + JSON.stringify(d['data'])); + console.log('/app/fruit?type='.concat(d['data']['label'])); + } + ''' extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] From 6feb42c38390eb7fb708dbb0e75507685bcd838b Mon Sep 17 00:00:00 2001 From: areski Date: Wed, 9 Dec 2015 18:59:34 +0100 Subject: [PATCH 04/70] fix changelog --- CHANGELOG.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8cfba303..6a85e3fe 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -50,7 +50,7 @@ History ------------------- * allow chart_attr to be set as follow 'xAxis': '.rotateLabels(-25)' - This will turn into calling chart.xAxis.rotateLabels(-25) + this will turn into calling chart.xAxis.rotateLabels(-25) 0.11.0 (2013-10-09) @@ -61,19 +61,19 @@ History 0.10.2 (2013-10-04) ------------------- +------------------- * discreteBarChart support date on xAxis 0.10.1 (2013-10-03) ------------------- +------------------- * Remove $ sign in linePlusBarWithFocusChart 0.10.0 (2013-10-02) ------------------- +------------------- * Support new chart linePlusBarWithFocusChart From a29db130143a6169f4cbd705469fa574daf3ad8f Mon Sep 17 00:00:00 2001 From: areski Date: Wed, 9 Dec 2015 18:59:50 +0100 Subject: [PATCH 05/70] Update to version v0.14.1 --- nvd3/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nvd3/__init__.py b/nvd3/__init__.py index cf6bdb84..86b799b9 100755 --- a/nvd3/__init__.py +++ b/nvd3/__init__.py @@ -9,7 +9,7 @@ Project location : https://github.com/areski/python-nvd3 """ -__version__ = '0.13.10' +__version__ = '0.14.1' __all__ = ['lineChart', 'pieChart', 'lineWithFocusChart', 'stackedAreaChart', 'multiBarHorizontalChart', 'linePlusBarChart', 'cumulativeLineChart', diff --git a/setup.py b/setup.py index 86299d0b..fbbac6b2 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( name='python-nvd3', - version='0.13.10', + version='0.14.1', description="Python NVD3 - Chart Library for d3.js", long_description=readme + '\n\n' + history, keywords='plot, graph, nvd3, d3', From 69d82842edc379a7d418d68590096a94bbf1e9a9 Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 10 Dec 2015 12:23:33 +0100 Subject: [PATCH 06/70] fix changelog to manifest --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index f3c2a648..7697f68b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include CONTRIBUTING.rst -include HISTORY.rst +include CHANGELOG.rst include LICENSE include README.rst From 172de21531f382720268ccbb8f5df70eda540f8d Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 10 Dec 2015 12:23:57 +0100 Subject: [PATCH 07/70] Update to version v0.14.2 --- nvd3/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nvd3/__init__.py b/nvd3/__init__.py index 86b799b9..9b82bf58 100755 --- a/nvd3/__init__.py +++ b/nvd3/__init__.py @@ -9,7 +9,7 @@ Project location : https://github.com/areski/python-nvd3 """ -__version__ = '0.14.1' +__version__ = '0.14.2' __all__ = ['lineChart', 'pieChart', 'lineWithFocusChart', 'stackedAreaChart', 'multiBarHorizontalChart', 'linePlusBarChart', 'cumulativeLineChart', diff --git a/setup.py b/setup.py index fbbac6b2..ccda2b5e 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( name='python-nvd3', - version='0.14.1', + version='0.14.2', description="Python NVD3 - Chart Library for d3.js", long_description=readme + '\n\n' + history, keywords='plot, graph, nvd3, d3', From c5c386da5401dc9b0eaae30eb293b1a557125737 Mon Sep 17 00:00:00 2001 From: areski Date: Sun, 20 Dec 2015 14:51:41 +0100 Subject: [PATCH 08/70] bump dependencies of nvd3 to v1.7.1 --- README.rst | 4 ++-- docs/source/_templates/page.html | 4 ++-- examples/demo_all.py | 4 ++-- nvd3/NVD3Chart.py | 4 ++-- nvd3/ipynb.py | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 9e428c08..ba5e1271 100644 --- a/README.rst +++ b/README.rst @@ -132,8 +132,8 @@ Note : you might prefer to save your npm dependencies locally in a ``package.jso Then in the directory where you will use python-nvd3, just execute the following commands:: - $ bower install d3#3.3.8 - $ bower install nvd3#1.1.12-beta + $ bower install d3#3.5.5 + $ bower install nvd3#1.7.1 This will create a directory "bower_components" where d3 & nvd3 will be saved. diff --git a/docs/source/_templates/page.html b/docs/source/_templates/page.html index a58781ee..df16a8a9 100644 --- a/docs/source/_templates/page.html +++ b/docs/source/_templates/page.html @@ -5,9 +5,9 @@ {% endblock %} {% block extrahead %} - + - + {% endblock %} {%- block body %} diff --git a/examples/demo_all.py b/examples/demo_all.py index c8753584..354485b6 100644 --- a/examples/demo_all.py +++ b/examples/demo_all.py @@ -36,9 +36,9 @@ - + - + """ diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 66699363..0a296c23 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -153,7 +153,7 @@ def __init__(self, **kwargs): self.header_css = [ '' % h for h in ( - 'https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.css' if self.remote_js_assets else self.assets_directory + 'nvd3/src/nv.d3.css', + 'https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.css' if self.remote_js_assets else self.assets_directory + 'nvd3/src/nv.d3.css', ) ] @@ -161,7 +161,7 @@ def __init__(self, **kwargs): '' % h for h in ( 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js' if self.remote_js_assets else self.assets_directory + 'd3/d3.min.js', - 'https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.js' if self.remote_js_assets else self.assets_directory + 'nvd3/nv.d3.min.js' + 'https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.js' if self.remote_js_assets else self.assets_directory + 'nvd3/nv.d3.min.js' ) ] diff --git a/nvd3/ipynb.py b/nvd3/ipynb.py index f421afc0..5a177377 100644 --- a/nvd3/ipynb.py +++ b/nvd3/ipynb.py @@ -40,8 +40,8 @@ def _setup_ipython_formatter(ip): html_formatter.for_type_by_name('nvd3.' + chart_type, chart_type, _print_html) def initialize_javascript(d3_js_url='https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js', - nvd3_js_url='https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.js', - nvd3_css_url='https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.css', + nvd3_js_url='https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.js', + nvd3_css_url='https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.css', use_remote=False): '''Initialize the ipython notebook to be able to display nvd3 results. by instructing IPython to load the nvd3 JS and css files, and the d3 JS file. @@ -52,8 +52,8 @@ def initialize_javascript(d3_js_url='https://cdnjs.cloudflare.com/ajax/libs/d3/3 use_remote: use remote hosts for d3.js, nvd3.js, and nv.d3.css (default False) * Note: the following options are ignored if use_remote is False: - nvd3_css_url: location of nvd3 css file (default https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.css) - nvd3_js_url: location of nvd3 javascript file (default https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.css) + nvd3_css_url: location of nvd3 css file (default https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.css) + nvd3_js_url: location of nvd3 javascript file (default https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.css) d3_js_url: location of d3 javascript file (default https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js) ''' from IPython.display import display, Javascript, HTML From 2929c548eefcfa108d9c3f38d530c9161e2fa940 Mon Sep 17 00:00:00 2001 From: areski Date: Mon, 21 Dec 2015 23:32:57 +0100 Subject: [PATCH 09/70] add note related to #104 --- examples/multiBarChart.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/multiBarChart.py b/examples/multiBarChart.py index 709e662d..af1bd175 100644 --- a/examples/multiBarChart.py +++ b/examples/multiBarChart.py @@ -19,6 +19,9 @@ chart = multiBarChart(name=type, height=350) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 10 + +# On multiBarChart the xdata needs to be numeric, +# if you want to use 'string' you should use discreteBarChart xdata = list(range(nb_element)) ydata = [random.randint(1, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] From 1c71935ad06c70463bcea0172fa217a7a9de81c3 Mon Sep 17 00:00:00 2001 From: Wolfram Kerl Date: Mon, 28 Dec 2015 19:17:57 +0100 Subject: [PATCH 10/70] possibility to adjust the y-axis range --- nvd3/NVD3Chart.py | 4 ++++ nvd3/templates/content.html | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 0a296c23..7ffe21b8 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -87,6 +87,8 @@ def __init__(self, **kwargs): Signal that x axis is a date axis :keyword: **date_format** - default - ``%x`` see https://github.com/mbostock/d3/wiki/Time-Formatting + :keyword: **y_axis_scale_min** - default - ``''``. + :keyword: **y_axis_scale_max** - default - ``''``. :keyword: **x_axis_format** - default - ``''``. :keyword: **y_axis_format** - default - ``''``. :keyword: **style** - default - ``''`` @@ -131,6 +133,8 @@ def __init__(self, **kwargs): self.style = kwargs.get('style', '') self.date_format = kwargs.get('date_format', '%x') self.x_axis_date = kwargs.get('x_axis_date', False) + self.y_axis_scale_min = kwargs.get('y_axis_scale_min', '') + self.y_axis_scale_max = kwargs.get('y_axis_scale_max', '') #: x-axis contain date format or not # possible duplicate of x_axis_date self.date_flag = kwargs.get('date_flag', False) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 787f39b5..ff278cc2 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -96,6 +96,12 @@ {% endblock custoattr %} + {% block y_axis_scale %} + {% if chart.y_axis_scale_min or chart.y_axis_scale_max %} + chart.forceY([{{ chart.y_axis_scale_min }},{{ chart.y_axis_scale_max }}]); + {% endif %} + {% endblock y_axis_scale %} + {% block inject %} {# Inject data to D3 #} d3.select('#{{ chart.name }} svg') From 0f3fc07e811b413d498e453d05737c3a982cb682 Mon Sep 17 00:00:00 2001 From: areski Date: Wed, 30 Dec 2015 13:48:02 +0100 Subject: [PATCH 11/70] fix tests & update changelog --- CHANGELOG.rst | 7 +++++++ tests.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6a85e3fe..f0f16d1c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,13 @@ History ------- +0.15.0 - current +--------------------- + +* new settings show_controls & xAxis_rotateLabel +* add setting to add callback + + 0.14.0 - (2015-12-09) --------------------- diff --git a/tests.py b/tests.py index 861268ab..1a6a0690 100644 --- a/tests.py +++ b/tests.py @@ -172,7 +172,7 @@ def test_discreteBarChart(self): chart.buildhtml() # We don't modify the xAxis, so make sure that it's not invoked. - assert("chart.xAxis" not in chart.htmlcontent) + assert("chart.xAxis" in chart.htmlcontent) def test_pieChart(self): """Test Pie Chart""" From 7a36a37305f6082b861426e0c07380a4774bd5b7 Mon Sep 17 00:00:00 2001 From: Halfdan Rump Date: Sun, 24 Jan 2016 21:14:13 +0900 Subject: [PATCH 12/70] Surrounds width arg with quotes in order to be able to specify width in percentage --- nvd3/templates/content.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 06da508b..10abcc01 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -109,7 +109,7 @@ .datum(datum) .transition().duration(500) {% if chart.width %} - .attr('width', {{ chart.width}}) + .attr('width', '{{ chart.width}}') {% endif %} {% if chart.height %} .attr('height', {{ chart.height}}) From d165163d2158dbbbab992bc09b15517a3cd20cf6 Mon Sep 17 00:00:00 2001 From: rowanv Date: Tue, 9 Feb 2016 14:28:41 +0100 Subject: [PATCH 13/70] Added ability to create bullet charts --- nvd3/__init__.py | 1 + nvd3/bulletChart.py | 125 ++++++++++++++++++++++++++++++++ nvd3/templates/bulletchart.html | 30 ++++++++ tests.py | 54 ++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 nvd3/bulletChart.py create mode 100644 nvd3/templates/bulletchart.html diff --git a/nvd3/__init__.py b/nvd3/__init__.py index 9b82bf58..477c31d1 100755 --- a/nvd3/__init__.py +++ b/nvd3/__init__.py @@ -26,4 +26,5 @@ from .scatterChart import scatterChart from .discreteBarChart import discreteBarChart from .multiBarChart import multiBarChart +from .bulletChart import bulletChart from . import ipynb diff --git a/nvd3/bulletChart.py b/nvd3/bulletChart.py new file mode 100644 index 00000000..fa8368bb --- /dev/null +++ b/nvd3/bulletChart.py @@ -0,0 +1,125 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" +Python-nvd3 is a Python wrapper for NVD3 graph library. +NVD3 is an attempt to build re-usable charts and chart components +for d3.js without taking away the power that d3.js gives you. + +Project location : https://github.com/areski/python-nvd3 +""" + +from .NVD3Chart import NVD3Chart, TemplateMixin + + +class bulletChart(TemplateMixin, NVD3Chart): + ''' + A bullet chart is a variation of a bar graph + used to indicate the value of a single variable + in relation to a set of qualitative ranges. It is + inspired by a dashboard guage or thermometer chart. + + Python example: + + from nvd3.bulletChart import bulletChart + chart = bulletChart.bulletChart(name=type, height=100, width=500) + title = 'Revenue', + subtitle = 'US$, in thousands' + ranges = [150, 225, 300] + measures = [220, 270] + markers = [250] + chart.add_serie( + title=title, + subtitle=subtitle, + ranges=ranges, + measures=measures, + markers=markers) + chart.buildhtml() + + JavaScript generated: + + .. raw:: html + + + + + + + + + + + +
+ + + + + + + + ''' + CHART_FILENAME = './bulletchart.html' + template_chart_nvd3 = NVD3Chart.template_environment.get_template( + CHART_FILENAME) + + def __init__(self, **kwargs): + super(bulletChart, self).__init__(**kwargs) + self.model = 'bulletChart' + + height = kwargs.get('height', None) + width = kwargs.get('width', 200) + + if height: + self.set_graph_height(height) + if width: + self.set_graph_width(width) + + def add_serie(self, ranges, measures, title, subtitle, markers=None, + name=None, **kwargs): + if not name: + name = "Serie %d" % (self.serie_no) + if markers: + serie = [{ + 'title': title, + 'subtitle': subtitle, + 'ranges': ranges, + 'measures': measures, + 'markers': markers + }] + else: + serie = [{ + 'title': title, + 'subtitle': subtitle, + 'ranges': ranges, + 'measures': measures, + }] + data_keyvalue = {'values': serie, 'key': name} + + self.serie_no += 1 + self.series.append(data_keyvalue) diff --git a/nvd3/templates/bulletchart.html b/nvd3/templates/bulletchart.html new file mode 100644 index 00000000..081dba96 --- /dev/null +++ b/nvd3/templates/bulletchart.html @@ -0,0 +1,30 @@ +{# This template adds attributes unique + to bulletChart #} + +{% extends 'content.html' %} +{% block body %} + + {% block data %} + {{ super () }} + {% endblock data %} + + function transformedData(){ + return data_bulletchart[0]['values'][0] + } + + + + nv.addGraph(function() { + var chart = nv.models.bulletChart(); + + d3.select('svg') + .datum(transformedData()) + .transition().duration(1000) + .call(chart) + ; + + return chart; + }); +{% endblock body %} + + diff --git a/tests.py b/tests.py index 1a6a0690..bce0f966 100644 --- a/tests.py +++ b/tests.py @@ -11,6 +11,7 @@ from nvd3 import discreteBarChart from nvd3 import pieChart from nvd3 import multiBarChart +from nvd3 import bulletChart from nvd3.NVD3Chart import stab from nvd3.translator import Function, AnonymousFunction, Assignment import random @@ -194,6 +195,59 @@ def test_donutPieChart(self): chart.add_serie(y=ydata, x=xdata) chart.buildhtml() + def test_can_create_bulletChart(self): + type = 'bulletChart' + chart = bulletChart(name=type, height=100, width=500) + title = 'Revenue', + subtitle = 'US$, in thousands' + ranges = [150, 225, 300] + measures = [220, 270] + markers = [250] + chart.add_serie( + title=title, + subtitle=subtitle, + ranges=ranges, + measures=measures, + markers=markers) + chart.buildhtml() + + def test_bulletChart_htmlcontent_correct(self): + type = 'bulletChart' + chart = bulletChart(name=type, height=100, width=500) + title = 'Revenue', + subtitle = 'USD, in mill' + ranges = [100, 250, 300] + measures = [220, 280] + markers = [260] + chart.add_serie( + title=title, + subtitle=subtitle, + ranges=ranges, + measures=measures, + markers=markers) + chart.buildhtml() + assert 'data_bulletchart' in chart.htmlcontent + assert '"title": ["Revenue"]' in chart.htmlcontent + assert '"ranges": [100, 250, 300]' in chart.htmlcontent + assert 'nv.models.bulletChart();' in chart.htmlcontent + + def test_bulletChart_marker_optional(self): + type = 'bulletChart' + chart = bulletChart(name=type, height=100, width=500) + title = 'Revenue', + subtitle = 'USD, in mill' + ranges = [100, 250, 300] + measures = [220, 280] + chart.add_serie( + title=title, + subtitle=subtitle, + ranges=ranges, + measures=measures + ) + chart.buildhtml() + assert 'data_bulletchart' in chart.htmlcontent + assert 'marker' not in chart.htmlcontent + class FuncTest(unittest.TestCase): From dc42a0c69651779095494638dacbf763eecba811 Mon Sep 17 00:00:00 2001 From: Ignacio Rossi Date: Wed, 10 Feb 2016 10:00:46 -0300 Subject: [PATCH 14/70] Remove spurious colon --- nvd3/templates/content.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index e3bf732d..9585cff5 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -76,7 +76,7 @@ {% block custoattr %} {# add custom chart attributes #} {% for attr, value in chart.chart_attr.items() %} - {% if value is string and value.startswith(".") %}: + {% if value is string and value.startswith(".") %} chart.{{ attr }}{{ value }}; {% else %} chart.{{ attr }}({{ value }}); From 04a328abc333bf734ba4a76b8d6cea608c5f38ca Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Thu, 11 Feb 2016 20:44:37 +0100 Subject: [PATCH 15/70] optionally disable tooltips fix #112 --- examples/discreteBarChart.py | 19 +++++++++++ nvd3/discreteBarChart.py | 47 ++++++++++++++++++++++++++++ nvd3/templates/discretebarchart.html | 4 +-- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/examples/discreteBarChart.py b/examples/discreteBarChart.py index 533d61e0..0fb6375f 100644 --- a/examples/discreteBarChart.py +++ b/examples/discreteBarChart.py @@ -30,3 +30,22 @@ # close Html file output_file.close() + +output_file = open('test_discreteBarChart2.html', 'w') + +type = "discreteBarChart" +chart = discreteBarChart(name='mygraphname', height=400, width=600, + tooltips=False) +chart.set_containerheader("\n\n

" + type + "

\n\n") +xdata = ["A", "B", "C", "D", "E", "F", "G"] +ydata = [3, 12, -10, 5, 25, -7, 2] + +extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} +chart.add_serie(y=ydata, x=xdata, extra=extra_serie) + +chart.buildhtml() +output_file.write(chart.htmlcontent) +# --------------------------------------- + +# close Html file +output_file.close() diff --git a/nvd3/discreteBarChart.py b/nvd3/discreteBarChart.py index cf6c8a4a..30bb345f 100644 --- a/nvd3/discreteBarChart.py +++ b/nvd3/discreteBarChart.py @@ -17,6 +17,7 @@ class discreteBarChart(TemplateMixin, NVD3Chart): A discrete bar chart or bar graph is a chart with rectangular bars with lengths proportional to the values that they represent. + Python example:: from nvd3 import discreteBarChart @@ -63,6 +64,46 @@ class discreteBarChart(TemplateMixin, NVD3Chart): + You can also disable the tooltips by passing ``tooltips=False`` when + creating the bar chart. + + Python example:: + + chart = discreteBarChart(name='discreteBarChart', height=400, width=400, + tooltips=False) + + .. raw:: html + +
+ + """ CHART_FILENAME = "./discretebarchart.html" template_chart_nvd3 = NVD3Chart.template_environment.get_template(CHART_FILENAME) @@ -89,3 +130,9 @@ def __init__(self, **kwargs): self.set_graph_height(height) if width: self.set_graph_width(width) + + tooltips = kwargs.get('tooltips', True) + + if not tooltips: + self.chart_attr = {'tooltips': 'false'} + diff --git a/nvd3/templates/discretebarchart.html b/nvd3/templates/discretebarchart.html index 2e31ae48..3a52b3ab 100644 --- a/nvd3/templates/discretebarchart.html +++ b/nvd3/templates/discretebarchart.html @@ -15,7 +15,7 @@ {% block axes %} {{super()}} {% endblock axes %} - + {% block custoattr %} {{super()}} {% endblock custoattr %} @@ -23,7 +23,7 @@ {% block inject %} {{ super() }} {% endblock inject %} - + {% block close %} {{ super() }} {% endblock close %} From cc749a9188178516a3c1f7530973c8b05b650599 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Thu, 11 Feb 2016 21:02:56 +0100 Subject: [PATCH 16/70] fix documentation --- nvd3/discreteBarChart.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvd3/discreteBarChart.py b/nvd3/discreteBarChart.py index 30bb345f..1560e749 100644 --- a/nvd3/discreteBarChart.py +++ b/nvd3/discreteBarChart.py @@ -69,12 +69,12 @@ class discreteBarChart(TemplateMixin, NVD3Chart): Python example:: - chart = discreteBarChart(name='discreteBarChart', height=400, width=400, + chart = discreteBarChart(name='discreteBarChart-notooltip', height=400, width=400, tooltips=False) .. raw:: html -
+
G"] ydata = [3, 12, -10, 5, 25, -7, 2] extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index dd2d0c3b..580075e9 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -7,7 +7,7 @@ {% block body %} {% block data %} - data_{{ chart.name }}={{ chart.series_js }}; + data_{{ chart.name }}={{ chart.series_js|striptags }}; {% endblock data %} {% block init %} diff --git a/nvd3/templates/linebarwfocuschart.html b/nvd3/templates/linebarwfocuschart.html index ad4866c8..3622888c 100644 --- a/nvd3/templates/linebarwfocuschart.html +++ b/nvd3/templates/linebarwfocuschart.html @@ -4,7 +4,7 @@ {% extends "content.html" %} {% block body %} {% block data %} - data_{{ chart.name }}={{ chart.series_js }}; + data_{{ chart.name }}={{ chart.series_js|striptags }}; {% endblock data %} diff --git a/nvd3/templates/piechart.html b/nvd3/templates/piechart.html index 0c11a158..71d67fb6 100644 --- a/nvd3/templates/piechart.html +++ b/nvd3/templates/piechart.html @@ -4,7 +4,7 @@ {% extends "content.html" %} {% block body %} - data_{{ chart.name }}={{ chart.series_js }}; + data_{{ chart.name }}={{ chart.series_js|striptags }}; nv.addGraph(function() { var chart = nv.models.{{ chart.model }}(){% if chart.use_interactive_guideline %}.useInteractiveGuideline(true){% endif %}; From e90c8021e56338796452d26c079f901d2d8f8f93 Mon Sep 17 00:00:00 2001 From: Rick van de Loo Date: Tue, 13 Dec 2016 21:12:10 +0100 Subject: [PATCH 22/70] make tooltip separator configurable so the 'at' is not hardcoded in the tooltip --- nvd3/NVD3Chart.py | 1 + nvd3/templates/content.html | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index cd1f130d..95ac1c8b 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -129,6 +129,7 @@ def __init__(self, **kwargs): self.show_controls = kwargs.get('show_controls', True) self.show_legend = kwargs.get('show_legend', True) self.show_labels = kwargs.get('show_labels', True) + self.tooltip_separator = kwargs.get('tooltip_separator') self.tag_script_js = kwargs.get('tag_script_js', True) self.use_interactive_guideline = kwargs.get("use_interactive_guideline", False) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 580075e9..6c789d57 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -56,7 +56,7 @@ var x = String(graph.point.x); var y = String(graph.point.y); {{ chart.tooltip_condition_string }} - tooltip_str = '
'+key+'
' + y + ' at ' + x; + tooltip_str = '
'+key+'
' + y + ' {{ chart.tooltip_separator|default('at', True) }} ' + x; return tooltip_str; }); {% endif %} @@ -65,7 +65,7 @@ var x = d3.time.format("{{ chart.charttooltip_dateformat }}")(new Date(parseInt(graph.point.x))); var y = String(graph.point.y); {{ chart.tooltip_condition_string }} - tooltip_str = '
'+key+'
' + y + ' on ' + x; + tooltip_str = '
'+key+'
' + y + ' {{ chart.tooltip_separator|default('on', True) }} ' + x; return tooltip_str; }); {% endif %} From 97b5e8b59d9eafa3299e66268ac0a7af39acacd1 Mon Sep 17 00:00:00 2001 From: dotpmrcunha Date: Thu, 16 Mar 2017 10:39:35 +0000 Subject: [PATCH 23/70] Add tiooltip block to lineplusbarchart Without this block we cannot customize the lineplusbar chart tooltips --- nvd3/templates/lineplusbarchart.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nvd3/templates/lineplusbarchart.html b/nvd3/templates/lineplusbarchart.html index 73aeceac..bfcb9069 100644 --- a/nvd3/templates/lineplusbarchart.html +++ b/nvd3/templates/lineplusbarchart.html @@ -24,6 +24,10 @@ {{super()}} {% endblock axes %} + {% block tooltip %} + {{super()}} + {% endblock tooltip %} + {% block legend %} {{super()}} {% endblock legend %} From 7262deb1b3dd4d634e595218806f9de89b097dd8 Mon Sep 17 00:00:00 2001 From: Renato Candido Date: Sat, 1 Jul 2017 01:00:18 -0300 Subject: [PATCH 24/70] Added keyword show_controls to allow to disable to show stacked and grouped controls --- nvd3/NVD3Chart.py | 2 ++ nvd3/templates/content.html | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 95ac1c8b..a282e01c 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -72,6 +72,7 @@ def __init__(self, **kwargs): :keyword: **height** - default - ``''`` :keyword: **width** - default - ``''`` :keyword: **stacked** - default - ``False`` + :keyword: **show_controls** - default - ``None`` :keyword: **focus_enable** - default - ``False`` :keyword: **resize** - define - ``False`` :keyword: **xAxis_rotateLabel** - default - ``0`` @@ -123,6 +124,7 @@ def __init__(self, **kwargs): self.height = kwargs.get('height', '') self.width = kwargs.get('width', '') self.stacked = kwargs.get('stacked', False) + self.show_controls = kwargs.get('show_controls', None) self.focus_enable = kwargs.get('focus_enable', False) self.resize = kwargs.get('resize', False) self.xAxis_rotateLabel = kwargs.get('xAxis_rotateLabel', 0) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 6c789d57..2d56f0b1 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -28,6 +28,10 @@ chart.stacked(true); {% endif %} + {% if chart.show_controls == False %} + chart.showControls(false); + {% endif %} + {% block focus %} {% endblock focus %} From 7902003301d391d5a26b1f44a5d419a1509ff4f3 Mon Sep 17 00:00:00 2001 From: virtustate Date: Tue, 26 Sep 2017 16:23:27 -0500 Subject: [PATCH 25/70] added multiChart --- nvd3/__init__.py | 5 +- nvd3/multiChart.py | 125 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 nvd3/multiChart.py diff --git a/nvd3/__init__.py b/nvd3/__init__.py index 477c31d1..14e12c77 100755 --- a/nvd3/__init__.py +++ b/nvd3/__init__.py @@ -13,7 +13,8 @@ __all__ = ['lineChart', 'pieChart', 'lineWithFocusChart', 'stackedAreaChart', 'multiBarHorizontalChart', 'linePlusBarChart', 'cumulativeLineChart', - 'scatterChart', 'discreteBarChart', 'multiBarChart'] + 'scatterChart', 'discreteBarChart', 'multiBarChart', + 'multiChart'] from .lineChart import lineChart @@ -26,5 +27,5 @@ from .scatterChart import scatterChart from .discreteBarChart import discreteBarChart from .multiBarChart import multiBarChart -from .bulletChart import bulletChart +from .multiChart import multiChart from . import ipynb diff --git a/nvd3/multiChart.py b/nvd3/multiChart.py new file mode 100644 index 00000000..137f5f1a --- /dev/null +++ b/nvd3/multiChart.py @@ -0,0 +1,125 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" +Python-nvd3 is a Python wrapper for NVD3 graph library. +NVD3 is an attempt to build re-usable charts and chart components +for d3.js without taking away the power that d3.js gives you. + +Project location : https://github.com/areski/python-nvd3 +""" + +from .NVD3Chart import NVD3Chart, TemplateMixin + + +class multiChart(TemplateMixin, NVD3Chart): + + """ + A line chart or line graph is a type of chart which displays information + as a series of data points connected by straight line segments. + + Python example:: + + from nvd3 import lineChart + chart = lineChart(name="lineChart", x_is_date=False, x_axis_format="AM_PM") + + xdata = range(24) + ydata = [0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 4, 3, 3, 5, 7, 5, 3, 16, 6, 9, 15, 4, 12] + ydata2 = [9, 8, 11, 8, 3, 7, 10, 8, 6, 6, 9, 6, 5, 4, 3, 10, 0, 6, 3, 1, 0, 0, 0, 1] + + extra_serie = {"tooltip": {"y_start": "There are ", "y_end": " calls"}} + chart.add_serie(y=ydata, x=xdata, name='sine', extra=extra_serie, **kwargs1) + extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}} + chart.add_serie(y=ydata2, x=xdata, name='cose', extra=extra_serie, **kwargs2) + chart.buildhtml() + + Javascript renderd to: + + .. raw:: html + +
+ + + See the source code of this page, to see the underlying javascript. + """ + CHART_FILENAME = "./multichart.html" + template_chart_nvd3 = NVD3Chart.template_environment.get_template(CHART_FILENAME) + + def __init__(self, **kwargs): + super(multiChart, self).__init__(**kwargs) + self.model = 'multiChart' + + height = kwargs.get('height', 450) + width = kwargs.get('width', None) + + if kwargs.get('x_is_date', False): + self.set_date_flag(True) + self.create_x_axis('xAxis', + format=kwargs.get('x_axis_format', '%d %b %Y'), + date=True) + self.set_custom_tooltip_flag(True) + else: + if kwargs.get('x_axis_format') == 'AM_PM': + self.x_axis_format = format = 'AM_PM' + else: + format = kwargs.get('x_axis_format', 'r') + self.create_x_axis('xAxis', format=format, + custom_format=kwargs.get('x_custom_format', + False)) + self.create_y_axis( + 'yAxis1', + format=kwargs.get('y1_axis_format', '.02f'), + custom_format=kwargs.get('y1_custom_format', False)) + + self.create_y_axis( + 'yAxis2', + format=kwargs.get('y2_axis_format', '.02f'), + custom_format=kwargs.get('y2_custom_format', False)) + + # must have a specified height, otherwise it superimposes both chars + self.set_graph_height(height) + if width: + self.set_graph_width(width) From b9ce85d534a25ba968137255ba497ca232abad93 Mon Sep 17 00:00:00 2001 From: virtustate Date: Tue, 26 Sep 2017 16:25:33 -0500 Subject: [PATCH 26/70] added multiChart --- nvd3/templates/multichart.html | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 nvd3/templates/multichart.html diff --git a/nvd3/templates/multichart.html b/nvd3/templates/multichart.html new file mode 100644 index 00000000..515d1903 --- /dev/null +++ b/nvd3/templates/multichart.html @@ -0,0 +1,47 @@ +{# This template adds attributes unique + to multiChart #} + +{% extends "content.html" %} +{% block body %} + + {% block data %} + {{super()}} + {% endblock data %} + + {% block init %} + {{super()}} + {% endblock init %} + + {% block axes %} + {{super()}} + {% endblock axes %} + + {% if chart.x_axis_format == 'AM_PM' %} + function get_am_pm(d){ + if (d > 12) { + d = d - 12; return (String(d) + 'PM'); + } + else { + return (String(d) + 'AM'); + } + }; + {% endif %} + + {% block legend %} + {{super()}} + {% endblock legend %} + + {% block custoattr %} + {{super()}} + {% endblock custoattr %} + + {% block inject %} + {{ super() }} + {% endblock inject %} + + {% block close %} + {{ super() }} + {% endblock close %} + +{% endblock body %} + From c529339dfce42924223cd38cccdb0532443c92d4 Mon Sep 17 00:00:00 2001 From: Sumeet Bansal Date: Fri, 13 Oct 2017 11:13:37 -0700 Subject: [PATCH 27/70] updated lineChart.py typo fix for JavaScript rendering --- nvd3/lineChart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvd3/lineChart.py b/nvd3/lineChart.py index c237d069..d832d8ec 100644 --- a/nvd3/lineChart.py +++ b/nvd3/lineChart.py @@ -33,7 +33,7 @@ class lineChart(TemplateMixin, NVD3Chart): chart.add_serie(y=ydata2, x=xdata, name='cose', extra=extra_serie, **kwargs2) chart.buildhtml() - Javascript renderd to: + Javascript rendered to: .. raw:: html From c9369c9ac0c8611e4e4e9019c0f17eadfc22e8e8 Mon Sep 17 00:00:00 2001 From: Julian Tu Date: Sun, 22 Oct 2017 16:11:00 +1100 Subject: [PATCH 28/70] Fix typo in NVD3Chart.py (#146) --- nvd3/NVD3Chart.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index a282e01c..488218bb 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -361,7 +361,7 @@ def __str__(self): def buildcontent(self): """Build HTML content only, no header or body tags. To be useful this - will usually require the attribute `juqery_on_ready` to be set which + will usually require the attribute `jquery_on_ready` to be set which will wrap the js in $(function(){};) """ self.buildcontainer() @@ -485,7 +485,7 @@ class TemplateMixin(object): """ def buildcontent(self): """Build HTML content only, no header or body tags. To be useful this - will usually require the attribute `juqery_on_ready` to be set which + will usually require the attribute `jquery_on_ready` to be set which will wrap the js in $(function(){};) """ self.buildcontainer() From ada8fa3669f9c594d1512e1ec5ed8ed4ab419b25 Mon Sep 17 00:00:00 2001 From: virtustate Date: Thu, 7 Dec 2017 15:25:22 -0600 Subject: [PATCH 29/70] Create multiChart.py --- examples/multiChart.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 examples/multiChart.py diff --git a/examples/multiChart.py b/examples/multiChart.py new file mode 100644 index 00000000..501c2044 --- /dev/null +++ b/examples/multiChart.py @@ -0,0 +1,36 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" +Examples for Python-nvd3 is a Python wrapper for NVD3 graph library. +NVD3 is an attempt to build re-usable charts and chart components +for d3.js without taking away the power that d3.js gives you. + +Project location : https://github.com/areski/python-nvd3 +""" + +from nvd3 import multiChart + +# Open File for test +output_file = open('test_multiChart.html', 'w') +# --------------------------------------- +type = "multiChart" +chart = multiChart(name=type, x_is_date=False, x_axis_format="AM_PM") + +xdata = [1,2,3,4,5,6] +ydata = [115.5,160.5,108,145.5,84,70.5] +ydata2 = [48624,42944,43439,24194,38440,31651] + +kwargs1 = {'color': 'black'} +kwargs2 = {'color': 'red'} +extra_serie = {"tooltip": {"y_start": "There is ", "y_end": " calls"}} +chart.add_serie(y=ydata, x=xdata, type='line', yaxis=1, name='visits', extra=extra_serie, **kwargs1) +extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}} +chart.add_serie(y=ydata2, x=xdata, type='bar', yaxis=2,name='spend', extra=extra_serie, **kwargs2) + +chart.buildhtml() + +output_file.write(chart.htmlcontent) + +# close Html file +output_file.close() From 4623f11e5f9c0c495dc730aae55cc598a5887a42 Mon Sep 17 00:00:00 2001 From: virtustate Date: Thu, 7 Dec 2017 15:39:20 -0600 Subject: [PATCH 30/70] Update multiChart.py --- nvd3/multiChart.py | 106 ++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 54 deletions(-) diff --git a/nvd3/multiChart.py b/nvd3/multiChart.py index 137f5f1a..1ef4cfaf 100644 --- a/nvd3/multiChart.py +++ b/nvd3/multiChart.py @@ -15,73 +15,71 @@ class multiChart(TemplateMixin, NVD3Chart): """ - A line chart or line graph is a type of chart which displays information - as a series of data points connected by straight line segments. + A multiChart is a type of chart which combines several plots of the same or different types. Python example:: - from nvd3 import lineChart - chart = lineChart(name="lineChart", x_is_date=False, x_axis_format="AM_PM") + from nvd3 import multiChart + type = "multiChart" + chart = multiChart(name=type, x_is_date=False, x_axis_format="AM_PM") - xdata = range(24) - ydata = [0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 4, 3, 3, 5, 7, 5, 3, 16, 6, 9, 15, 4, 12] - ydata2 = [9, 8, 11, 8, 3, 7, 10, 8, 6, 6, 9, 6, 5, 4, 3, 10, 0, 6, 3, 1, 0, 0, 0, 1] + xdata = [1,2,3,4,5,6] + ydata = [115.5,160.5,108,145.5,84,70.5] + ydata2 = [48624,42944,43439,24194,38440,31651] - extra_serie = {"tooltip": {"y_start": "There are ", "y_end": " calls"}} - chart.add_serie(y=ydata, x=xdata, name='sine', extra=extra_serie, **kwargs1) + kwargs1 = {'color': 'black'} + kwargs2 = {'color': 'red'} + extra_serie = {"tooltip": {"y_start": "There is ", "y_end": " calls"}} + chart.add_serie(y=ydata, x=xdata, type='line', yaxis=1, name='visits', extra=extra_serie, **kwargs1) extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}} - chart.add_serie(y=ydata2, x=xdata, name='cose', extra=extra_serie, **kwargs2) + chart.add_serie(y=ydata2, x=xdata, type='bar', yaxis=2,name='spend', extra=extra_serie, **kwargs2) chart.buildhtml() + Javascript renderd to: .. raw:: html -
- + See the source code of this page, to see the underlying javascript. """ From 1f3d00df3a86c490fae35b30da9c7b612face81f Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Fri, 8 Dec 2017 10:25:24 -0800 Subject: [PATCH 31/70] Add xAxis_staggerLabel option implmented similarly to xAxis_rotateLabel --- nvd3/NVD3Chart.py | 2 ++ nvd3/templates/content.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 488218bb..3c682b08 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -76,6 +76,7 @@ def __init__(self, **kwargs): :keyword: **focus_enable** - default - ``False`` :keyword: **resize** - define - ``False`` :keyword: **xAxis_rotateLabel** - default - ``0`` + :keyword: **xAxis_staggerLabel** - default - ``False`` :keyword: **show_controls** - default - ``True`` :keyword: **show_legend** - default - ``True`` :keyword: **show_labels** - default - ``True`` @@ -128,6 +129,7 @@ def __init__(self, **kwargs): self.focus_enable = kwargs.get('focus_enable', False) self.resize = kwargs.get('resize', False) self.xAxis_rotateLabel = kwargs.get('xAxis_rotateLabel', 0) + self.xAxis_staggerLabel = kwargs.get('xAxis_staggerLabel', False) self.show_controls = kwargs.get('show_controls', True) self.show_legend = kwargs.get('show_legend', True) self.show_labels = kwargs.get('show_labels', True) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 2d56f0b1..6fdfbc30 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -16,7 +16,7 @@ chart.margin({top: {{ chart.margin_top }}, right: {{ chart.margin_right }}, bottom: {{ chart.margin_bottom }}, left: {{ chart.margin_left }}}); chart.xAxis.rotateLabels({{chart.xAxis_rotateLabel}}) - + chart.xAxis.staggerLabels({{chart.xAxis_staggerLabel|lower}}) var datum = data_{{ chart.name }}; {% if not chart.color_list and chart.color_category %} From b6ba18ffa34f70a7fda22e734a1275c68a5a8bcd Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Fri, 8 Dec 2017 17:05:07 -0800 Subject: [PATCH 32/70] Do not initialize show_controls twice; keeps second initialization since it is one applied --- nvd3/NVD3Chart.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 3c682b08..51047410 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -72,7 +72,6 @@ def __init__(self, **kwargs): :keyword: **height** - default - ``''`` :keyword: **width** - default - ``''`` :keyword: **stacked** - default - ``False`` - :keyword: **show_controls** - default - ``None`` :keyword: **focus_enable** - default - ``False`` :keyword: **resize** - define - ``False`` :keyword: **xAxis_rotateLabel** - default - ``0`` @@ -125,7 +124,6 @@ def __init__(self, **kwargs): self.height = kwargs.get('height', '') self.width = kwargs.get('width', '') self.stacked = kwargs.get('stacked', False) - self.show_controls = kwargs.get('show_controls', None) self.focus_enable = kwargs.get('focus_enable', False) self.resize = kwargs.get('resize', False) self.xAxis_rotateLabel = kwargs.get('xAxis_rotateLabel', 0) From fd5d82481500dc72a45e254b74977edcfdacf845 Mon Sep 17 00:00:00 2001 From: virtustate Date: Mon, 11 Dec 2017 14:29:52 -0600 Subject: [PATCH 33/70] Update __init__.py --- nvd3/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nvd3/__init__.py b/nvd3/__init__.py index 14e12c77..cf223eae 100755 --- a/nvd3/__init__.py +++ b/nvd3/__init__.py @@ -27,5 +27,6 @@ from .scatterChart import scatterChart from .discreteBarChart import discreteBarChart from .multiBarChart import multiBarChart +from .bulletChart import bulletChart from .multiChart import multiChart from . import ipynb From e873992ee99c1314d291d4fd1a852dbfd2b28fdb Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Wed, 13 Dec 2017 15:36:14 -0800 Subject: [PATCH 34/70] Enable xAxis showMaxMin option -- defaults to true --- nvd3/NVD3Chart.py | 2 ++ nvd3/templates/content.html | 1 + 2 files changed, 3 insertions(+) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 51047410..0c47da5d 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -76,6 +76,7 @@ def __init__(self, **kwargs): :keyword: **resize** - define - ``False`` :keyword: **xAxis_rotateLabel** - default - ``0`` :keyword: **xAxis_staggerLabel** - default - ``False`` + :keyword: **xAxis_showMaxMin** - default - ``True`` :keyword: **show_controls** - default - ``True`` :keyword: **show_legend** - default - ``True`` :keyword: **show_labels** - default - ``True`` @@ -128,6 +129,7 @@ def __init__(self, **kwargs): self.resize = kwargs.get('resize', False) self.xAxis_rotateLabel = kwargs.get('xAxis_rotateLabel', 0) self.xAxis_staggerLabel = kwargs.get('xAxis_staggerLabel', False) + self.xAxis_showMaxMin = kwargs.get('xAxis_showMaxMin', True) self.show_controls = kwargs.get('show_controls', True) self.show_legend = kwargs.get('show_legend', True) self.show_labels = kwargs.get('show_labels', True) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 6fdfbc30..913f9038 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -17,6 +17,7 @@ chart.margin({top: {{ chart.margin_top }}, right: {{ chart.margin_right }}, bottom: {{ chart.margin_bottom }}, left: {{ chart.margin_left }}}); chart.xAxis.rotateLabels({{chart.xAxis_rotateLabel}}) chart.xAxis.staggerLabels({{chart.xAxis_staggerLabel|lower}}) + chart.xAxis.showMaxMin({{chart.xAxis_showMaxMin|lower}}) var datum = data_{{ chart.name }}; {% if not chart.color_list and chart.color_category %} From dbb1b59e1af8a08fed9a6ed36423a30d8dbf7f72 Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Fri, 15 Dec 2017 08:56:43 -0800 Subject: [PATCH 35/70] Fix error in multiBarChart_date example by casting map to list --- examples/multiBarChart_date.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/multiBarChart_date.py b/examples/multiBarChart_date.py index 21a3da14..afd5ff02 100644 --- a/examples/multiBarChart_date.py +++ b/examples/multiBarChart_date.py @@ -25,7 +25,7 @@ nb_element = 100 start_time = int(time.mktime(datetime.datetime(2013, 6, 1).timetuple()) * 1000) xdata = range(nb_element) -xdata = map(lambda x: start_time + x * 100000000, xdata) +xdata = list(map(lambda x: start_time + x * 100000000, xdata)) ydata = [i + random.randint(1, 10) for i in range(nb_element)] ydata2 = map(lambda x: x * 2, ydata) From b01af5b28359848cd21ccfa498578d22be6accfd Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Thu, 21 Dec 2017 12:52:13 -0800 Subject: [PATCH 36/70] Fix data provided to discreteBarChart example such that chart renders --- examples/discreteBarChart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/discreteBarChart.py b/examples/discreteBarChart.py index 5133d21c..0fb6375f 100644 --- a/examples/discreteBarChart.py +++ b/examples/discreteBarChart.py @@ -18,7 +18,7 @@ type = "discreteBarChart" chart = discreteBarChart(name='mygraphname', height=400, width=600) chart.set_containerheader("\n\n

" + type + "

\n\n") -xdata = ["A", "B", "C", "D", "E", "F", "G"] +xdata = ["A", "B", "C", "D", "E", "F", "G"] ydata = [3, 12, -10, 5, 25, -7, 2] extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} From 34709e5a999d55501b7e933f2ff7318dec54eaa4 Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Fri, 22 Dec 2017 05:43:45 -0800 Subject: [PATCH 37/70] Allows for customization of noData message. --- nvd3/NVD3Chart.py | 2 ++ nvd3/templates/content.html | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 0c47da5d..49df8b12 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -74,6 +74,7 @@ def __init__(self, **kwargs): :keyword: **stacked** - default - ``False`` :keyword: **focus_enable** - default - ``False`` :keyword: **resize** - define - ``False`` + :keyword: **no_data_message** - default - ``None`` or nvd3 default :keyword: **xAxis_rotateLabel** - default - ``0`` :keyword: **xAxis_staggerLabel** - default - ``False`` :keyword: **xAxis_showMaxMin** - default - ``True`` @@ -127,6 +128,7 @@ def __init__(self, **kwargs): self.stacked = kwargs.get('stacked', False) self.focus_enable = kwargs.get('focus_enable', False) self.resize = kwargs.get('resize', False) + self.no_data_message = kwargs.get('no_data_message', None) self.xAxis_rotateLabel = kwargs.get('xAxis_rotateLabel', 0) self.xAxis_staggerLabel = kwargs.get('xAxis_staggerLabel', False) self.xAxis_showMaxMin = kwargs.get('xAxis_showMaxMin', True) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 913f9038..889dd39c 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -29,6 +29,11 @@ chart.stacked(true); {% endif %} + {% if chart.no_data_message %} + chart.noData('{{chart.no_data_message}}') + {% endif %} + + {% if chart.show_controls == False %} chart.showControls(false); {% endif %} From fa0e7cf0d1138540aa77d50f8a40507df436c0f5 Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Fri, 22 Dec 2017 06:03:27 -0800 Subject: [PATCH 38/70] Fix for data generation in example within demo_all.py --- examples/demo_all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/demo_all.py b/examples/demo_all.py index 354485b6..26baacf1 100644 --- a/examples/demo_all.py +++ b/examples/demo_all.py @@ -281,7 +281,7 @@ nb_element = 100 start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) xdata = range(nb_element) -xdata = map(lambda x: start_time + x * 1000000000, xdata) +xdata = list(map(lambda x: start_time + x * 1000000000, xdata)) ydata = [i + random.randint(1, 10) for i in range(nb_element)] ydata2 = map(lambda x: x * 2, ydata) From d095eaf9bcf5656d7df1043090fc23abe2c7f9c6 Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Fri, 5 Jan 2018 05:34:34 -0800 Subject: [PATCH 39/70] Adds rightAlignYAxis initialization opt for charts --- nvd3/NVD3Chart.py | 2 ++ nvd3/templates/content.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 49df8b12..fddb8db5 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -78,6 +78,7 @@ def __init__(self, **kwargs): :keyword: **xAxis_rotateLabel** - default - ``0`` :keyword: **xAxis_staggerLabel** - default - ``False`` :keyword: **xAxis_showMaxMin** - default - ``True`` + :keyword: **right_align_y_axis** - default - ``False`` :keyword: **show_controls** - default - ``True`` :keyword: **show_legend** - default - ``True`` :keyword: **show_labels** - default - ``True`` @@ -132,6 +133,7 @@ def __init__(self, **kwargs): self.xAxis_rotateLabel = kwargs.get('xAxis_rotateLabel', 0) self.xAxis_staggerLabel = kwargs.get('xAxis_staggerLabel', False) self.xAxis_showMaxMin = kwargs.get('xAxis_showMaxMin', True) + self.right_align_y_axis = kwargs.get('right_align_y_axis', False) self.show_controls = kwargs.get('show_controls', True) self.show_legend = kwargs.get('show_legend', True) self.show_labels = kwargs.get('show_labels', True) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 889dd39c..2e2436c2 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -12,7 +12,7 @@ {% block init %} nv.addGraph(function() { - var chart = nv.models.{{ chart.model }}(){% if chart.use_interactive_guideline %}.useInteractiveGuideline(true){% endif %}{% if not chart.show_controls %}.showControls(false){% endif %}; + var chart = nv.models.{{ chart.model }}(){% if chart.use_interactive_guideline %}.useInteractiveGuideline(true){% endif %}{% if not chart.show_controls %}.showControls(false){% endif %}{% if chart.right_align_y_axis %}.rightAlignYAxis(true){% endif %}; chart.margin({top: {{ chart.margin_top }}, right: {{ chart.margin_right }}, bottom: {{ chart.margin_bottom }}, left: {{ chart.margin_left }}}); chart.xAxis.rotateLabels({{chart.xAxis_rotateLabel}}) From 258c3bac39d542f3d9bd0be8c49558c088ce9bff Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Fri, 5 Jan 2018 06:09:56 -0800 Subject: [PATCH 40/70] Add test coverage for multiChart; ensure more chart types can inherit rendering options like show_controls and no_data_message --- nvd3/templates/content.html | 4 ++-- nvd3/templates/discretebarchart.html | 4 ++++ nvd3/templates/linebarwfocuschart.html | 3 +++ nvd3/templates/linechart.html | 4 ++++ nvd3/templates/multichart.html | 4 ++++ nvd3/templates/scatterchart.html | 4 ++++ tests.py | 25 +++++++++++++++++++++++++ 7 files changed, 46 insertions(+), 2 deletions(-) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 2e2436c2..a8d1edf6 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -25,6 +25,7 @@ {% endif %} {% endblock init %} + {% block rendering_opts %} {% if chart.stacked %} chart.stacked(true); {% endif %} @@ -32,11 +33,10 @@ {% if chart.no_data_message %} chart.noData('{{chart.no_data_message}}') {% endif %} - - {% if chart.show_controls == False %} chart.showControls(false); {% endif %} + {% endblock rendering_opts %} {% block focus %} {% endblock focus %} diff --git a/nvd3/templates/discretebarchart.html b/nvd3/templates/discretebarchart.html index a6d62d72..221b280d 100644 --- a/nvd3/templates/discretebarchart.html +++ b/nvd3/templates/discretebarchart.html @@ -12,6 +12,10 @@ {{super()}} {% endblock init %} + {% block rendering_opts %} + {{super()}} + {% endblock rendering_opts %} + {% block axes %} {{super()}} {% endblock axes %} diff --git a/nvd3/templates/linebarwfocuschart.html b/nvd3/templates/linebarwfocuschart.html index 3622888c..d12c796f 100644 --- a/nvd3/templates/linebarwfocuschart.html +++ b/nvd3/templates/linebarwfocuschart.html @@ -11,6 +11,9 @@ {% block init %} {{super()}} {% endblock init %} + {% block rendering_opts %} + {{super()}} + {% endblock rendering_opts %} {% block axes %} {{super()}} {% endblock axes %} diff --git a/nvd3/templates/linechart.html b/nvd3/templates/linechart.html index 0db70a8f..a1b19adf 100644 --- a/nvd3/templates/linechart.html +++ b/nvd3/templates/linechart.html @@ -12,6 +12,10 @@ {{super()}} {% endblock init %} + {% block rendering_opts %} + {{super()}} + {% endblock rendering_opts %} + {% block axes %} {{super()}} {% endblock axes %} diff --git a/nvd3/templates/multichart.html b/nvd3/templates/multichart.html index 515d1903..db1100ff 100644 --- a/nvd3/templates/multichart.html +++ b/nvd3/templates/multichart.html @@ -12,6 +12,10 @@ {{super()}} {% endblock init %} + {% block rendering_opts %} + {{super()}} + {% endblock rendering_opts %} + {% block axes %} {{super()}} {% endblock axes %} diff --git a/nvd3/templates/scatterchart.html b/nvd3/templates/scatterchart.html index 8c2adaae..35bbebd5 100644 --- a/nvd3/templates/scatterchart.html +++ b/nvd3/templates/scatterchart.html @@ -12,6 +12,10 @@ {{super()}} {% endblock init %} + {% block rendering_opts %} + {{super()}} + {% endblock rendering_opts %} + {% block axes %} {{super()}} {% endblock axes %} diff --git a/tests.py b/tests.py index 043f066e..4de8b360 100644 --- a/tests.py +++ b/tests.py @@ -11,6 +11,7 @@ from nvd3 import discreteBarChart from nvd3 import pieChart from nvd3 import multiBarChart +from nvd3 import multiChart from nvd3 import bulletChart from nvd3.NVD3Chart import stab from nvd3.translator import Function, AnonymousFunction, Assignment @@ -120,6 +121,30 @@ def test_MultiBarChart(self): chart.add_serie(y=ydata, x=xdata, extra=extra) chart.buildhtml() + def test_multiChart(self): + """Test Multi (line plus bar) Chart""" + type = "multiChart" + chart = multiChart( + name=type, x_is_date=False, x_axis_format="AM_PM", + no_data_message='custom message shows when there is no data', + xAxis_staggerLabel=True + ) + + xdata = [1,2,3,4,5,6] + ydata = [115.5,160.5,108,145.5,84,70.5] + ydata2 = [48624,42944,43439,24194,38440,31651] + kwargs1 = {'color': 'brown'} + kwargs2 = {'color': '#bada55'} + extra_serie = {"tooltip": {"y_start": "There is ", "y_end": " calls"}} + chart.add_serie(y=ydata, x=xdata, type='line', yaxis=1, name='visits', extra=extra_serie, **kwargs1) + extra_serie = {"tooltip": {"y_start": "", "y_end": " at this point"}} + chart.add_serie(y=ydata2, x=xdata, type='bar', yaxis=2,name='spend', extra=extra_serie, **kwargs2) + chart.buildhtml() + + assert("chart.noData('custom message shows when there is no data')" in chart.htmlcontent) + assert("function get_am_pm" in chart.htmlcontent) + + def test_multiBarHorizontalChart(self): """Test multi Bar Horizontal Chart""" type = "multiBarHorizontalChart" From 554261f85796d1ba9823419941d0eb6d128d7c42 Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Mon, 8 Jan 2018 05:36:23 -0800 Subject: [PATCH 41/70] Add rendering options template block to pie chart --- nvd3/templates/piechart.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nvd3/templates/piechart.html b/nvd3/templates/piechart.html index 71d67fb6..e818509e 100644 --- a/nvd3/templates/piechart.html +++ b/nvd3/templates/piechart.html @@ -69,6 +69,15 @@ chart.color(mycolor); {% endif %} + {% block rendering_opts %} + {% if chart.no_data_message %} + chart.noData('{{chart.no_data_message}}') + {% endif %} + {% if chart.show_controls == False %} + chart.showControls(false); + {% endif %} + {% endblock rendering_opts %} + {% block inject %} {{super()}} {% endblock inject %} From 27c34ffdbf6eae66a7643ce6dd95d4b1c46a229e Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Tue, 9 Jan 2018 06:26:09 -0800 Subject: [PATCH 42/70] Adds rendering option for bar charts show_values (issue #144) - defined near `stacked` which is also a bar chart specific option --- nvd3/NVD3Chart.py | 2 ++ nvd3/templates/content.html | 3 +++ 2 files changed, 5 insertions(+) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index fddb8db5..621043f3 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -71,6 +71,7 @@ def __init__(self, **kwargs): :keyword: **margin_top** - default - ``30`` :keyword: **height** - default - ``''`` :keyword: **width** - default - ``''`` + :keyword: **show_values** - default - ``False`` :keyword: **stacked** - default - ``False`` :keyword: **focus_enable** - default - ``False`` :keyword: **resize** - define - ``False`` @@ -126,6 +127,7 @@ def __init__(self, **kwargs): self.margin_top = kwargs.get('margin_top', 30) self.height = kwargs.get('height', '') self.width = kwargs.get('width', '') + self.show_values = kwargs.get('show_values', False) self.stacked = kwargs.get('stacked', False) self.focus_enable = kwargs.get('focus_enable', False) self.resize = kwargs.get('resize', False) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index a8d1edf6..f4d2125a 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -36,6 +36,9 @@ {% if chart.show_controls == False %} chart.showControls(false); {% endif %} + {% if chart.show_values %} + chart.showValues(true); + {% endif %} {% endblock rendering_opts %} {% block focus %} From d600ad2da17bc1160e08b457fecd1757b5dca1be Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Wed, 14 Mar 2018 15:55:02 -0700 Subject: [PATCH 43/70] Move call to render chart.extras to inheritable template block #135 --- nvd3/templates/content.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index f4d2125a..8690a230 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -39,6 +39,11 @@ {% if chart.show_values %} chart.showValues(true); {% endif %} + + {# extra chart attributes #} + {% if chart.extras %} + {{ chart.extras }} + {% endif %} {% endblock rendering_opts %} {% block focus %} @@ -130,11 +135,6 @@ .call(chart); {% endblock inject %} - {# extra chart attributes #} - {% if chart.extras %} - {{ chart.extras }} - {% endif %} - {# callback for clicking on charts #} {% if chart.callback %} },{{ chart.callback }}); From 7ef403569155d2632c92467b81fad8af61dd27b6 Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Wed, 14 Mar 2018 15:58:29 -0700 Subject: [PATCH 44/70] Remove now redundant template rendering for chart.extras now that it is inherited from content.html --- nvd3/templates/linebarwfocuschart.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nvd3/templates/linebarwfocuschart.html b/nvd3/templates/linebarwfocuschart.html index d12c796f..b65ae034 100644 --- a/nvd3/templates/linebarwfocuschart.html +++ b/nvd3/templates/linebarwfocuschart.html @@ -52,10 +52,6 @@ {{super()}} {% endblock inject %} - {% if chart.extras %} - {{ chart.extras }} - {% endif %} - {% block close %} }); {% endblock close %} From 77ec6fe9f666ac172ba506bfe79e938e9db76036 Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Wed, 14 Mar 2018 16:07:51 -0700 Subject: [PATCH 45/70] Add extras rendering block to piechart as well. --- nvd3/templates/piechart.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nvd3/templates/piechart.html b/nvd3/templates/piechart.html index e818509e..f5eb0623 100644 --- a/nvd3/templates/piechart.html +++ b/nvd3/templates/piechart.html @@ -76,6 +76,10 @@ {% if chart.show_controls == False %} chart.showControls(false); {% endif %} + {# extra chart attributes #} + {% if chart.extras %} + {{ chart.extras }} + {% endif %} {% endblock rendering_opts %} {% block inject %} From 82e90fee1085c821dda8e8005425c56ecbcc7e37 Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Wed, 14 Mar 2018 16:27:37 -0700 Subject: [PATCH 46/70] render extras after inject to better honor original implementation / documented example --- nvd3/templates/content.html | 11 +++++++---- nvd3/templates/discretebarchart.html | 4 ++++ nvd3/templates/linebarwfocuschart.html | 4 ++++ nvd3/templates/linechart.html | 4 ++++ nvd3/templates/multichart.html | 4 ++++ nvd3/templates/piechart.html | 11 +++++++---- nvd3/templates/scatterchart.html | 4 ++++ 7 files changed, 34 insertions(+), 8 deletions(-) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index 8690a230..a3831940 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -40,10 +40,6 @@ chart.showValues(true); {% endif %} - {# extra chart attributes #} - {% if chart.extras %} - {{ chart.extras }} - {% endif %} {% endblock rendering_opts %} {% block focus %} @@ -135,6 +131,13 @@ .call(chart); {% endblock inject %} + {% block extras %} + {# extra chart attributes #} + {% if chart.extras %} + {{ chart.extras }} + {% endif %} + {% endblock extras %} + {# callback for clicking on charts #} {% if chart.callback %} },{{ chart.callback }}); diff --git a/nvd3/templates/discretebarchart.html b/nvd3/templates/discretebarchart.html index 221b280d..adcc38d4 100644 --- a/nvd3/templates/discretebarchart.html +++ b/nvd3/templates/discretebarchart.html @@ -32,6 +32,10 @@ {{ super() }} {% endblock inject %} + {% block extras %} + {{ super () }} + {% endblock extras %} + {% block close %} {{ super() }} {% endblock close %} diff --git a/nvd3/templates/linebarwfocuschart.html b/nvd3/templates/linebarwfocuschart.html index b65ae034..7e4b9211 100644 --- a/nvd3/templates/linebarwfocuschart.html +++ b/nvd3/templates/linebarwfocuschart.html @@ -52,6 +52,10 @@ {{super()}} {% endblock inject %} + {% block extras %} + {{ super () }} + {% endblock extras %} + {% block close %} }); {% endblock close %} diff --git a/nvd3/templates/linechart.html b/nvd3/templates/linechart.html index a1b19adf..d22aaa44 100644 --- a/nvd3/templates/linechart.html +++ b/nvd3/templates/linechart.html @@ -47,6 +47,10 @@ {{ super() }} {% endblock inject %} + {% block extras %} + {{ super () }} + {% endblock extras %} + {% block close %} {{ super() }} {% endblock close %} diff --git a/nvd3/templates/multichart.html b/nvd3/templates/multichart.html index db1100ff..8264b00e 100644 --- a/nvd3/templates/multichart.html +++ b/nvd3/templates/multichart.html @@ -43,6 +43,10 @@ {{ super() }} {% endblock inject %} + {% block extras %} + {{ super () }} + {% endblock extras %} + {% block close %} {{ super() }} {% endblock close %} diff --git a/nvd3/templates/piechart.html b/nvd3/templates/piechart.html index f5eb0623..1cc45ea7 100644 --- a/nvd3/templates/piechart.html +++ b/nvd3/templates/piechart.html @@ -76,16 +76,19 @@ {% if chart.show_controls == False %} chart.showControls(false); {% endif %} - {# extra chart attributes #} - {% if chart.extras %} - {{ chart.extras }} - {% endif %} {% endblock rendering_opts %} {% block inject %} {{super()}} {% endblock inject %} + {% block extras %} + {# extra chart attributes #} + {% if chart.extras %} + {{ chart.extras }} + {% endif %} + {% endblock extras %} + {% if chart.callback %} },{{ chart.callback }}); {% endif %} diff --git a/nvd3/templates/scatterchart.html b/nvd3/templates/scatterchart.html index 35bbebd5..0a88a06c 100644 --- a/nvd3/templates/scatterchart.html +++ b/nvd3/templates/scatterchart.html @@ -49,6 +49,10 @@ {{ super() }} {% endblock inject %} + {% block extras %} + {{ super () }} + {% endblock extras %} + {% block close %} {{ super() }} {% endblock close %} From 5bfa46e8916d393dbb3edab2520f725ffb2722f9 Mon Sep 17 00:00:00 2001 From: Cyd La Luz Date: Wed, 14 Mar 2018 16:41:14 -0700 Subject: [PATCH 47/70] Add specs and extras to two examples file; add feature for bullet chart and lineplusbarchart --- examples/discreteBarChart.py | 2 +- examples/pieChart.py | 2 +- nvd3/templates/bulletchart.html | 4 ++++ nvd3/templates/lineplusbarchart.html | 4 ++++ tests.py | 18 ++++++++++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/examples/discreteBarChart.py b/examples/discreteBarChart.py index 0fb6375f..e8ffa29b 100644 --- a/examples/discreteBarChart.py +++ b/examples/discreteBarChart.py @@ -16,7 +16,7 @@ output_file = open('test_discreteBarChart.html', 'w') type = "discreteBarChart" -chart = discreteBarChart(name='mygraphname', height=400, width=600) +chart = discreteBarChart(name='mygraphname', height=400, width=600, show_values=True, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") chart.set_containerheader("\n\n

" + type + "

\n\n") xdata = ["A", "B", "C", "D", "E", "F", "G"] ydata = [3, 12, -10, 5, 25, -7, 2] diff --git a/examples/pieChart.py b/examples/pieChart.py index 618c885d..3e208a6b 100644 --- a/examples/pieChart.py +++ b/examples/pieChart.py @@ -16,7 +16,7 @@ output_file = open('test_pieChart.html', 'w') type = "pieChart" -chart = pieChart(name=type, color_category='category20c', height=400, width=400) +chart = pieChart(name=type, color_category='category20c', height=400, width=400, extras="d3.selectAll('#piechart .nv-slice').style('opacity', 0.5);") chart.set_containerheader("\n\n

" + type + "

\n\n") chart.callback = ''' function(){ diff --git a/nvd3/templates/bulletchart.html b/nvd3/templates/bulletchart.html index 081dba96..985f4239 100644 --- a/nvd3/templates/bulletchart.html +++ b/nvd3/templates/bulletchart.html @@ -25,6 +25,10 @@ return chart; }); + + {% block extras %} + {{ super () }} + {% endblock extras %} {% endblock body %} diff --git a/nvd3/templates/lineplusbarchart.html b/nvd3/templates/lineplusbarchart.html index bfcb9069..009a7050 100644 --- a/nvd3/templates/lineplusbarchart.html +++ b/nvd3/templates/lineplusbarchart.html @@ -40,6 +40,10 @@ {{ super() }} {% endblock inject %} + {% block extras %} + {{ super () }} + {% endblock extras %} + {% block close %} {{ super() }} {% endblock close %} diff --git a/tests.py b/tests.py index 4de8b360..c1c291a5 100644 --- a/tests.py +++ b/tests.py @@ -279,6 +279,24 @@ def test_bulletChart_marker_optional(self): assert 'marker' not in chart.htmlcontent + def test_charts_with_extras(self): + # extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)" + type_bullet = 'bulletChart' + bullet_chart = bulletChart(name=type_bullet, height=100, width=500, extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)") + bullet_chart.buildhtml() + assert 'data_bulletchart' in bullet_chart.htmlcontent + assert "d3.selectAll('#mygraphname text').style('opacity', 0.5)" in bullet_chart.htmlcontent + + type_pie = "pieChart" + pie_chart = pieChart(name=type_pie, height=400, width=400, donut=True, donutRatio=0.2, extras="alert('Example of extra not even related to d3!')") + pie_chart.buildhtml() + assert "alert('Example of extra not even related to d3!')" in pie_chart.htmlcontent + + type_line_plus_bar = "linePlusBarChart" + line_plus_bar_chart = linePlusBarChart(name=type_line_plus_bar, date=True, height=350, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") + line_plus_bar_chart.buildhtml() + assert "d3.selectAll('#mygraphname text').style('fill', 'red')" in line_plus_bar_chart.htmlcontent + class FuncTest(unittest.TestCase): def test_stab(self): From 636edd88d00239bf4d68a383e6dad1cf0f72cf8e Mon Sep 17 00:00:00 2001 From: Bolke de Bruin Date: Sun, 25 Mar 2018 19:18:26 +0200 Subject: [PATCH 48/70] Update python-slugify to at least 1.2.5 Some concerns were raised that python-slugify due to its fixed dependency on GPL'd unidecode was incompliant to the GPL (also making python-nvd3 possibly incompliant). Since version 1.2.5 python- slugify allows an alternative to unidecode which removes those concerns. --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index b1af639c..7567c48f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -python-slugify>=1.1.4 +python-slugify>=1.2.5 Jinja2>=2.8 diff --git a/setup.py b/setup.py index ccda2b5e..cbe4e1b5 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ include_package_data=True, zip_safe=False, install_requires=[ - 'python-slugify==1.1.4', + 'python-slugify>=1.2.5', 'Jinja2>=2.8' # -*- Extra requirements: -*- ], From 5102ff6f08932c33fe1953499aaaea2362f7fc77 Mon Sep 17 00:00:00 2001 From: areski Date: Mon, 26 Mar 2018 12:54:05 +0200 Subject: [PATCH 49/70] [fix](load) add bulletchart to init --- nvd3/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvd3/__init__.py b/nvd3/__init__.py index cf223eae..c73235ac 100755 --- a/nvd3/__init__.py +++ b/nvd3/__init__.py @@ -14,7 +14,7 @@ 'stackedAreaChart', 'multiBarHorizontalChart', 'linePlusBarChart', 'cumulativeLineChart', 'scatterChart', 'discreteBarChart', 'multiBarChart', - 'multiChart'] + 'bulletChart', 'multiChart'] from .lineChart import lineChart From 04fafc89b6be6c5866822ba6f76aa6b30391fe4a Mon Sep 17 00:00:00 2001 From: Chris Simpkins Date: Tue, 8 Jan 2019 14:08:04 -0500 Subject: [PATCH 50/70] [README.rst] minor header typo fix Dependecies --> Dependencies --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ba5e1271..cbcec025 100644 --- a/README.rst +++ b/README.rst @@ -119,8 +119,8 @@ Install, upgrade and uninstall python-nvd3 with these commands:: $ pip uninstall python-nvd3 -Dependecies ------------ +Dependencies +------------ D3 and NvD3 can be installed through bower (which itself can be installed through npm). See http://bower.io/ and https://npmjs.org for further information. From fa1e513f0bbd4c23cc278b44d007557e93f530f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Wed, 28 Oct 2020 07:06:51 +0100 Subject: [PATCH 51/70] update nvd3/d3/jquery versions --- README.rst | 4 ++-- docs/source/_templates/page.html | 6 +++--- examples/demo_all.py | 8 ++++---- nvd3/NVD3Chart.py | 6 +++--- nvd3/bulletChart.py | 6 +++--- nvd3/ipynb.py | 12 ++++++------ 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.rst b/README.rst index cbcec025..f07013bd 100644 --- a/README.rst +++ b/README.rst @@ -132,8 +132,8 @@ Note : you might prefer to save your npm dependencies locally in a ``package.jso Then in the directory where you will use python-nvd3, just execute the following commands:: - $ bower install d3#3.5.5 - $ bower install nvd3#1.7.1 + $ bower install d3#3.5.17 + $ bower install nvd3#1.8.6 This will create a directory "bower_components" where d3 & nvd3 will be saved. diff --git a/docs/source/_templates/page.html b/docs/source/_templates/page.html index df16a8a9..b6874d6c 100644 --- a/docs/source/_templates/page.html +++ b/docs/source/_templates/page.html @@ -5,9 +5,9 @@ {% endblock %} {% block extrahead %} - - - + + + {% endblock %} {%- block body %} diff --git a/examples/demo_all.py b/examples/demo_all.py index 26baacf1..c2c161b4 100644 --- a/examples/demo_all.py +++ b/examples/demo_all.py @@ -35,10 +35,10 @@ - - - - + + + + """ diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index 621043f3..a55e1ac4 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -173,15 +173,15 @@ def __init__(self, **kwargs): self.header_css = [ '' % h for h in ( - 'https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.css' if self.remote_js_assets else self.assets_directory + 'nvd3/src/nv.d3.css', + 'https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.6/nv.d3.min.css' if self.remote_js_assets else self.assets_directory + 'nvd3/src/nv.d3.css', ) ] self.header_js = [ '' % h for h in ( - 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js' if self.remote_js_assets else self.assets_directory + 'd3/d3.min.js', - 'https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.js' if self.remote_js_assets else self.assets_directory + 'nvd3/nv.d3.min.js' + 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js' if self.remote_js_assets else self.assets_directory + 'd3/d3.min.js', + 'https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.6/nv.d3.min.js' if self.remote_js_assets else self.assets_directory + 'nvd3/nv.d3.min.js' ) ] diff --git a/nvd3/bulletChart.py b/nvd3/bulletChart.py index fa8368bb..d5701ed6 100644 --- a/nvd3/bulletChart.py +++ b/nvd3/bulletChart.py @@ -44,9 +44,9 @@ class bulletChart(TemplateMixin, NVD3Chart): - - - + + + diff --git a/nvd3/ipynb.py b/nvd3/ipynb.py index 5a177377..39c9c361 100644 --- a/nvd3/ipynb.py +++ b/nvd3/ipynb.py @@ -39,9 +39,9 @@ def _setup_ipython_formatter(ip): for chart_type in nvd3_all: html_formatter.for_type_by_name('nvd3.' + chart_type, chart_type, _print_html) - def initialize_javascript(d3_js_url='https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js', - nvd3_js_url='https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.js', - nvd3_css_url='https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.css', + def initialize_javascript(d3_js_url='https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js', + nvd3_js_url='https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.6/nv.d3.min.js', + nvd3_css_url='https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.6/nv.d3.min.css', use_remote=False): '''Initialize the ipython notebook to be able to display nvd3 results. by instructing IPython to load the nvd3 JS and css files, and the d3 JS file. @@ -52,9 +52,9 @@ def initialize_javascript(d3_js_url='https://cdnjs.cloudflare.com/ajax/libs/d3/3 use_remote: use remote hosts for d3.js, nvd3.js, and nv.d3.css (default False) * Note: the following options are ignored if use_remote is False: - nvd3_css_url: location of nvd3 css file (default https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.css) - nvd3_js_url: location of nvd3 javascript file (default https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.1/nv.d3.min.css) - d3_js_url: location of d3 javascript file (default https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js) + nvd3_css_url: location of nvd3 css file (default https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.6/nv.d3.min.css) + nvd3_js_url: location of nvd3 javascript file (default https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.6/nv.d3.min.css) + d3_js_url: location of d3 javascript file (default https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js) ''' from IPython.display import display, Javascript, HTML From ce6ed4ce3162970aa157d810f1a4035f749d1c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Wed, 28 Oct 2020 14:34:02 +0100 Subject: [PATCH 52/70] use formatters to format tooltip values instead of contentGenerators --- nvd3/templates/content.html | 30 +++++++++++++++--------------- nvd3/templates/piechart.html | 5 +++-- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/nvd3/templates/content.html b/nvd3/templates/content.html index a3831940..70250c46 100644 --- a/nvd3/templates/content.html +++ b/nvd3/templates/content.html @@ -65,23 +65,23 @@ {% if chart.model == 'pieChart' %} {% block pietooltip %} {% endblock pietooltip %} - {% else %} - chart.tooltipContent(function(key, y, e, graph) { - var x = String(graph.point.x); - var y = String(graph.point.y); - {{ chart.tooltip_condition_string }} - tooltip_str = '
'+key+'
' + y + ' {{ chart.tooltip_separator|default('at', True) }} ' + x; - return tooltip_str; - }); {% endif %} {% else %} - chart.tooltipContent(function(key, y, e, graph) { - var x = d3.time.format("{{ chart.charttooltip_dateformat }}")(new Date(parseInt(graph.point.x))); - var y = String(graph.point.y); - {{ chart.tooltip_condition_string }} - tooltip_str = '
'+key+'
' + y + ' {{ chart.tooltip_separator|default('on', True) }} ' + x; - return tooltip_str; - }); + {% if chart.model in ('discreteBarChart', ) %} + chart.tooltip.keyFormatter(function(d, i) { + return d3.time.format("{{ chart.charttooltip_dateformat }}")(new Date(parseInt(d))); + }); + {% endif %} + {% if chart.model in ('linePlusBarChart', 'lineChart', 'multiBarChart', 'cumulativeLineChart', 'lineWithFocusChart') %} + chart.tooltip.headerFormatter(function(d, i) { + return d3.time.format("{{ chart.charttooltip_dateformat }}")(new Date(parseInt(d))); + }); + {% endif %} + {% if chart.model in ('stackedAreaChart', ) %} + chart.interactiveLayer.tooltip.headerFormatter(function(d, i) { + return d3.time.format("{{ chart.charttooltip_dateformat }}")(new Date(parseInt(d))); + }); + {% endif %} {% endif %} {% endif %} {% endblock tooltip %} diff --git a/nvd3/templates/piechart.html b/nvd3/templates/piechart.html index 1cc45ea7..93a11e99 100644 --- a/nvd3/templates/piechart.html +++ b/nvd3/templates/piechart.html @@ -15,8 +15,9 @@ chart.color(d3.scale.{{ chart.color_category }}().range()); {% endif %} - chart.tooltipContent(function(key, y, e, graph) { - var x = String(key); + chart.tooltip.contentGenerator(function(d, elem) { + var x = String(d.data.label); + var y = String(d.data.value); {{ chart.tooltip_condition_string }} tooltip_str = '
'+x+'
' + y; return tooltip_str; From 9554b4a2c13c48429afd92257100a780a94ecf73 Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 29 Oct 2020 15:08:33 +0100 Subject: [PATCH 53/70] [fix](general) update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0568aa2c..78ecd3eb 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ bower.json bower_components archive +env htmlcov test_*.html From 3e3d7d3494c6406f113f42a75ee52cc6a9b0dcaf Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 29 Oct 2020 15:14:13 +0100 Subject: [PATCH 54/70] [fix](tooltip) remove unused tooltip_condition_string --- nvd3/NVD3Chart.py | 22 ---------------------- nvd3/templates/piechart.html | 1 - 2 files changed, 23 deletions(-) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index a55e1ac4..b4caf7c3 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -188,7 +188,6 @@ def __init__(self, **kwargs): #: Javascript code as string self.jschart = None self.custom_tooltip_flag = False - self.tooltip_condition_string = '' self.charttooltip = '' self.serie_no = 1 @@ -287,27 +286,11 @@ def add_serie(self, y, x, name=None, extra=None, **kwargs): _start = ("'" + str(_start) + "' + ") if _start else '' _end = (" + '" + str(_end) + "'") if _end else '' - if self.model == 'linePlusBarChart': - if self.tooltip_condition_string: - self.tooltip_condition_string += stab(5) - self.tooltip_condition_string += stab(0) + "if(key.indexOf('" + name + "') > -1 ){\n" +\ - stab(6) + "var y = " + _start + " String(graph.point.y) " + _end + ";\n" +\ - stab(5) + "}\n" - elif self.model == 'cumulativeLineChart': - self.tooltip_condition_string += stab(0) + "if(key == '" + name + "'){\n" +\ - stab(6) + "var y = " + _start + " String(e) " + _end + ";\n" +\ - stab(5) + "}\n" - else: - self.tooltip_condition_string += stab(5) + "if(key == '" + name + "'){\n" +\ - stab(6) + "var y = " + _start + " String(graph.point.y) " + _end + ";\n" +\ - stab(5) + "}\n" - if self.model == 'pieChart': _start = extra['tooltip']['y_start'] _end = extra['tooltip']['y_end'] _start = ("'" + str(_start) + "' + ") if _start else '' _end = (" + '" + str(_end) + "'") if _end else '' - self.tooltip_condition_string += "var y = " + _start + " String(y) " + _end + ";\n" # Increment series counter & append self.serie_no += 1 @@ -428,11 +411,6 @@ def buildjschart(self): """generate javascript code for the chart""" self.jschart = '' - # add custom tooltip string in jschart - # default condition (if build_custom_tooltip is not called explicitly with date_flag=True) - if self.tooltip_condition_string == '': - self.tooltip_condition_string = 'var y = String(graph.point.y);\n' - # Include data self.series_js = json.dumps(self.series) diff --git a/nvd3/templates/piechart.html b/nvd3/templates/piechart.html index 93a11e99..a707ac52 100644 --- a/nvd3/templates/piechart.html +++ b/nvd3/templates/piechart.html @@ -18,7 +18,6 @@ chart.tooltip.contentGenerator(function(d, elem) { var x = String(d.data.label); var y = String(d.data.value); - {{ chart.tooltip_condition_string }} tooltip_str = '
'+x+'
' + y; return tooltip_str; }); From f9cb41b5deaa0d7c338764d7008a4c9a5ad50dca Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 29 Oct 2020 15:20:57 +0100 Subject: [PATCH 55/70] [fix](test) update py version for travis-ci --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e4222da..2f46df5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,10 @@ language: python python: - 2.7 - - 3.3 - - 3.4 - - 3.5 + - 3.6 + - 3.7 + - 3.8 + - 3.9 install: - pip install -r requirements.txt From 27d5c194911cc6e328dcd427b2621b47817d2260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Sat, 28 Nov 2020 18:27:50 +0100 Subject: [PATCH 56/70] fix tests (there is no tooltip string in the output anymore) --- tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests.py b/tests.py index c1c291a5..63b73c70 100644 --- a/tests.py +++ b/tests.py @@ -79,7 +79,7 @@ def test_lineChart_tooltip(self): chart.buildhtml() - assert("tooltip_str =" in chart.htmlcontent) + assert(".tickFormat(d3.format(',.02f'));" in chart.htmlcontent) def test_linePlusBarChart(self): """Test line Plus Bar Chart""" @@ -201,7 +201,7 @@ def test_discreteBarChart(self): # We don't modify the xAxis, so make sure that it's not invoked. assert("chart.xAxis" in chart.htmlcontent) - assert("tooltip_str =" in chart.htmlcontent) + assert("var chart = nv.models.discreteBarChart();" in chart.htmlcontent) def test_pieChart(self): """Test Pie Chart""" From 1f3c969a774f5b15899d5bbdcde7288bd2b27b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Sat, 28 Nov 2020 19:49:50 +0100 Subject: [PATCH 57/70] generate examples with script into separate files --- .../classes-doc/examples/NVD3Chart.html | 4 ++ .../classes-doc/examples/bulletChart.html | 4 ++ .../examples/cumulativeLineChart.html | 62 ++++++++++++++++ .../examples/discreteBarChart.html | 58 +++++++++++++++ .../classes-doc/examples/lineChart.html | 71 +++++++++++++++++++ .../examples/linePlusBarChart.html | 70 ++++++++++++++++++ .../examples/lineWithFocusChart.html | 67 +++++++++++++++++ .../classes-doc/examples/multiBarChart.html | 57 +++++++++++++++ .../examples/multiBarHorizontalChart.html | 59 +++++++++++++++ .../classes-doc/examples/multiChart.html | 4 ++ .../source/classes-doc/examples/pieChart.html | 62 ++++++++++++++++ .../classes-doc/examples/scatterChart.html | 68 ++++++++++++++++++ .../examples/stackedAreaChart.html | 57 +++++++++++++++ generate_examples.sh | 10 +++ nvd3/bulletChart.py | 46 +----------- nvd3/cumulativeLineChart.py | 45 ++---------- nvd3/discreteBarChart.py | 32 +-------- nvd3/lineChart.py | 57 ++------------- nvd3/linePlusBarChart.py | 42 +---------- nvd3/lineWithFocusChart.py | 39 +--------- nvd3/multiBarChart.py | 37 +--------- nvd3/multiBarHorizontalChart.py | 52 +------------- nvd3/multiChart.py | 44 +----------- nvd3/pieChart.py | 44 +----------- nvd3/scatterChart.py | 62 +--------------- nvd3/stackedAreaChart.py | 40 +---------- 26 files changed, 687 insertions(+), 506 deletions(-) create mode 100644 docs/source/classes-doc/examples/NVD3Chart.html create mode 100644 docs/source/classes-doc/examples/bulletChart.html create mode 100644 docs/source/classes-doc/examples/cumulativeLineChart.html create mode 100644 docs/source/classes-doc/examples/discreteBarChart.html create mode 100644 docs/source/classes-doc/examples/lineChart.html create mode 100644 docs/source/classes-doc/examples/linePlusBarChart.html create mode 100644 docs/source/classes-doc/examples/lineWithFocusChart.html create mode 100644 docs/source/classes-doc/examples/multiBarChart.html create mode 100644 docs/source/classes-doc/examples/multiBarHorizontalChart.html create mode 100644 docs/source/classes-doc/examples/multiChart.html create mode 100644 docs/source/classes-doc/examples/pieChart.html create mode 100644 docs/source/classes-doc/examples/scatterChart.html create mode 100644 docs/source/classes-doc/examples/stackedAreaChart.html create mode 100755 generate_examples.sh diff --git a/docs/source/classes-doc/examples/NVD3Chart.html b/docs/source/classes-doc/examples/NVD3Chart.html new file mode 100644 index 00000000..5a00bfb5 --- /dev/null +++ b/docs/source/classes-doc/examples/NVD3Chart.html @@ -0,0 +1,4 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html diff --git a/docs/source/classes-doc/examples/bulletChart.html b/docs/source/classes-doc/examples/bulletChart.html new file mode 100644 index 00000000..5a00bfb5 --- /dev/null +++ b/docs/source/classes-doc/examples/bulletChart.html @@ -0,0 +1,4 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html diff --git a/docs/source/classes-doc/examples/cumulativeLineChart.html b/docs/source/classes-doc/examples/cumulativeLineChart.html new file mode 100644 index 00000000..306af9e8 --- /dev/null +++ b/docs/source/classes-doc/examples/cumulativeLineChart.html @@ -0,0 +1,62 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/docs/source/classes-doc/examples/discreteBarChart.html b/docs/source/classes-doc/examples/discreteBarChart.html new file mode 100644 index 00000000..2edf0818 --- /dev/null +++ b/docs/source/classes-doc/examples/discreteBarChart.html @@ -0,0 +1,58 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/docs/source/classes-doc/examples/lineChart.html b/docs/source/classes-doc/examples/lineChart.html new file mode 100644 index 00000000..e86db5a6 --- /dev/null +++ b/docs/source/classes-doc/examples/lineChart.html @@ -0,0 +1,71 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/docs/source/classes-doc/examples/linePlusBarChart.html b/docs/source/classes-doc/examples/linePlusBarChart.html new file mode 100644 index 00000000..9d03f2d4 --- /dev/null +++ b/docs/source/classes-doc/examples/linePlusBarChart.html @@ -0,0 +1,70 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/docs/source/classes-doc/examples/lineWithFocusChart.html b/docs/source/classes-doc/examples/lineWithFocusChart.html new file mode 100644 index 00000000..77dc3263 --- /dev/null +++ b/docs/source/classes-doc/examples/lineWithFocusChart.html @@ -0,0 +1,67 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/docs/source/classes-doc/examples/multiBarChart.html b/docs/source/classes-doc/examples/multiBarChart.html new file mode 100644 index 00000000..f3716400 --- /dev/null +++ b/docs/source/classes-doc/examples/multiBarChart.html @@ -0,0 +1,57 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/docs/source/classes-doc/examples/multiBarHorizontalChart.html b/docs/source/classes-doc/examples/multiBarHorizontalChart.html new file mode 100644 index 00000000..9bca3f85 --- /dev/null +++ b/docs/source/classes-doc/examples/multiBarHorizontalChart.html @@ -0,0 +1,59 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/docs/source/classes-doc/examples/multiChart.html b/docs/source/classes-doc/examples/multiChart.html new file mode 100644 index 00000000..5a00bfb5 --- /dev/null +++ b/docs/source/classes-doc/examples/multiChart.html @@ -0,0 +1,4 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html diff --git a/docs/source/classes-doc/examples/pieChart.html b/docs/source/classes-doc/examples/pieChart.html new file mode 100644 index 00000000..5bd122b9 --- /dev/null +++ b/docs/source/classes-doc/examples/pieChart.html @@ -0,0 +1,62 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/docs/source/classes-doc/examples/scatterChart.html b/docs/source/classes-doc/examples/scatterChart.html new file mode 100644 index 00000000..d8addb51 --- /dev/null +++ b/docs/source/classes-doc/examples/scatterChart.html @@ -0,0 +1,68 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/docs/source/classes-doc/examples/stackedAreaChart.html b/docs/source/classes-doc/examples/stackedAreaChart.html new file mode 100644 index 00000000..7ed41e75 --- /dev/null +++ b/docs/source/classes-doc/examples/stackedAreaChart.html @@ -0,0 +1,57 @@ +.. + _Generated with generated_examples.sh script + +.. raw:: html + +
+ + + + diff --git a/generate_examples.sh b/generate_examples.sh new file mode 100755 index 00000000..eda09418 --- /dev/null +++ b/generate_examples.sh @@ -0,0 +1,10 @@ +#!/bin/bash +mkdir "docs/source/classes-doc/examples/" +for file in nvd3/*Chart.py; do + html_filename="docs/source/classes-doc/examples/"`echo $file | sed "s/.*\///" | sed "s/\.py//"`".html" + echo $html_filename + echo -e "..\n _Generated with generated_examples.sh script\n\n.. raw:: html" > $html_filename + + cat $file | grep "Python example" -A1000 | grep -E "Javascript generated|Note that in case you" -m 1 -B 1000 | tail -n+2 | head -n-1 | sed "s/^[ \t]*//g" | python | sed "s/^/ /" >> $html_filename +done + diff --git a/nvd3/bulletChart.py b/nvd3/bulletChart.py index d5701ed6..221fcd2c 100644 --- a/nvd3/bulletChart.py +++ b/nvd3/bulletChart.py @@ -35,53 +35,11 @@ class bulletChart(TemplateMixin, NVD3Chart): measures=measures, markers=markers) chart.buildhtml() + print(chart.content) JavaScript generated: - .. raw:: html - - - - - - - - - - - -
- - - - - - + .. include:: ./examples/bulletChart.html ''' CHART_FILENAME = './bulletchart.html' diff --git a/nvd3/cumulativeLineChart.py b/nvd3/cumulativeLineChart.py index c29ddc1b..30c8f6d4 100644 --- a/nvd3/cumulativeLineChart.py +++ b/nvd3/cumulativeLineChart.py @@ -31,49 +31,14 @@ class cumulativeLineChart(TemplateMixin, NVD3Chart): extra_serie = {"tooltip": {"y_start": "", "y_end": " mins"}} chart.add_serie(name="Serie 2", y=y2data, x=xdata, extra=extra_serie) chart.buildhtml() + print(chart.content) + Javascript generated: - .. raw:: html - -
- + + .. include:: ./examples/cumulativeLineChart.html + """ diff --git a/nvd3/discreteBarChart.py b/nvd3/discreteBarChart.py index 9e109b3d..1f5792da 100644 --- a/nvd3/discreteBarChart.py +++ b/nvd3/discreteBarChart.py @@ -28,40 +28,12 @@ class discreteBarChart(TemplateMixin, NVD3Chart): chart.add_serie(y=ydata, x=xdata) chart.buildhtml() + print(chart.content) Javascript generated: - .. raw:: html - -
- You can also disable the tooltips by passing ``tooltips=False`` when diff --git a/nvd3/lineChart.py b/nvd3/lineChart.py index d832d8ec..d114007e 100644 --- a/nvd3/lineChart.py +++ b/nvd3/lineChart.py @@ -28,60 +28,15 @@ class lineChart(TemplateMixin, NVD3Chart): ydata2 = [9, 8, 11, 8, 3, 7, 10, 8, 6, 6, 9, 6, 5, 4, 3, 10, 0, 6, 3, 1, 0, 0, 0, 1] extra_serie = {"tooltip": {"y_start": "There are ", "y_end": " calls"}} - chart.add_serie(y=ydata, x=xdata, name='sine', extra=extra_serie, **kwargs1) + chart.add_serie(y=ydata, x=xdata, name='sine', extra=extra_serie) extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}} - chart.add_serie(y=ydata2, x=xdata, name='cose', extra=extra_serie, **kwargs2) + chart.add_serie(y=ydata2, x=xdata, name='cose', extra=extra_serie) chart.buildhtml() + print(chart.content) - Javascript rendered to: - - .. raw:: html - -
- + Javascript generated: + + .. include:: ./examples/lineChart.html See the source code of this page, to see the underlying javascript. """ diff --git a/nvd3/linePlusBarChart.py b/nvd3/linePlusBarChart.py index 4eaa5fc6..2cfe533b 100644 --- a/nvd3/linePlusBarChart.py +++ b/nvd3/linePlusBarChart.py @@ -39,7 +39,8 @@ class linePlusBarChart(TemplateMixin, NVD3Chart): extra_serie = {"tooltip": {"y_start": "There are ", "y_end": " min"}} chart.add_serie(name="Serie 2", y=y2data, x=xdata, extra=extra_serie) - chart.buildcontent() + chart.buildhtml() + print(chart.content) Note that in case you have two data serie with extreme different numbers, that you would like to format in different ways, @@ -51,44 +52,7 @@ class linePlusBarChart(TemplateMixin, NVD3Chart): Javascript generated: - .. raw:: html - -
- + .. include:: ./examples/linePlusBarChart.html """ CHART_FILENAME = "./lineplusbarchart.html" diff --git a/nvd3/lineWithFocusChart.py b/nvd3/lineWithFocusChart.py index 08fce373..b956d271 100644 --- a/nvd3/lineWithFocusChart.py +++ b/nvd3/lineWithFocusChart.py @@ -30,45 +30,12 @@ class lineWithFocusChart(TemplateMixin, NVD3Chart): "date_format": "%d %b %Y"} chart.add_serie(name="Serie 1", y=ydata, x=xdata, extra=extra_serie) chart.buildhtml() + print(chart.content) Javascript generated: - .. raw:: html - -
- + .. include:: ./examples/lineWithFocusChart.html + """ diff --git a/nvd3/multiBarChart.py b/nvd3/multiBarChart.py index cf335919..bab6adda 100644 --- a/nvd3/multiBarChart.py +++ b/nvd3/multiBarChart.py @@ -30,44 +30,11 @@ class multiBarChart(TemplateMixin, NVD3Chart): chart.add_serie(name="Serie 1", y=ydata1, x=xdata) chart.add_serie(name="Serie 2", y=ydata2, x=xdata) chart.buildhtml() + print(chart.content) Javascript generated: - .. raw:: html - -
- + .. include:: ./examples/multiBarChart.html """ diff --git a/nvd3/multiBarHorizontalChart.py b/nvd3/multiBarHorizontalChart.py index ac969c31..0028e86a 100644 --- a/nvd3/multiBarHorizontalChart.py +++ b/nvd3/multiBarHorizontalChart.py @@ -29,58 +29,12 @@ class multiBarHorizontalChart(TemplateMixin, NVD3Chart): extra_serie = {"tooltip": {"y_start": "", "y_end": " calls"}} chart.add_serie(name="Serie 2", y=y2data, x=xdata, extra=extra_serie) - chart.buildcontent() + chart.buildhtml() + print(chart.content) Javascript generated: - .. raw:: html - -
- + .. include:: ./examples/multiBarHorizontalChart.html """ diff --git a/nvd3/multiChart.py b/nvd3/multiChart.py index 1ef4cfaf..b40c4c5c 100644 --- a/nvd3/multiChart.py +++ b/nvd3/multiChart.py @@ -34,52 +34,12 @@ class multiChart(TemplateMixin, NVD3Chart): extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}} chart.add_serie(y=ydata2, x=xdata, type='bar', yaxis=2,name='spend', extra=extra_serie, **kwargs2) chart.buildhtml() + print(chart.content) Javascript renderd to: - .. raw:: html - -
- + .. include:: ./examples/multiChart.html See the source code of this page, to see the underlying javascript. """ diff --git a/nvd3/pieChart.py b/nvd3/pieChart.py index bcaf0492..6c513d83 100644 --- a/nvd3/pieChart.py +++ b/nvd3/pieChart.py @@ -32,51 +32,11 @@ class pieChart(TemplateMixin, NVD3Chart): extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} chart.add_serie(y=ydata, x=xdata, extra=extra_serie) chart.buildhtml() + print(chart.content) Javascript generated: - .. raw:: html - -
- + .. include:: ./examples/pieChart.html """ CHART_FILENAME = "./piechart.html" diff --git a/nvd3/scatterChart.py b/nvd3/scatterChart.py index c3a87d29..b622649b 100644 --- a/nvd3/scatterChart.py +++ b/nvd3/scatterChart.py @@ -38,69 +38,11 @@ class scatterChart(TemplateMixin, NVD3Chart): extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}} chart.add_serie(name="series 2", y=ydata2, x=xdata, extra=extra_serie, **kwargs2) chart.buildhtml() + print(chart.content) Javascript generated: - .. raw:: html - -
- + .. include:: ./examples/scatterChart.html """ diff --git a/nvd3/stackedAreaChart.py b/nvd3/stackedAreaChart.py index 8346cd2c..e246176f 100644 --- a/nvd3/stackedAreaChart.py +++ b/nvd3/stackedAreaChart.py @@ -30,47 +30,11 @@ class stackedAreaChart(TemplateMixin, NVD3Chart): chart.add_serie(name="Serie 1", y=ydata, x=xdata, extra=extra_serie) chart.add_serie(name="Serie 2", y=ydata2, x=xdata, extra=extra_serie) chart.buildhtml() + print(chart.content) Javascript generated: - .. raw:: html - -
- + .. include:: ./examples/stackedAreaChart.html """ From a84d7c1c9ef0e5dd450ba98f24ce0a74a3333e1c Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Sun, 23 May 2021 11:01:29 +1000 Subject: [PATCH 58/70] docs: fix a few simple typos There are small typos in: - nvd3/NVD3Chart.py - nvd3/bulletChart.py - nvd3/ipynb.py - nvd3/multiChart.py Fixes: - Should read `rendered` rather than `renderd`. - Should read `overridden` rather than `overriden`. - Should read `javascript` rather than `javscript`. - Should read `gauge` rather than `guage`. Closes #170 --- nvd3/NVD3Chart.py | 2 +- nvd3/bulletChart.py | 2 +- nvd3/ipynb.py | 2 +- nvd3/multiChart.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nvd3/NVD3Chart.py b/nvd3/NVD3Chart.py index b4caf7c3..83c0666c 100644 --- a/nvd3/NVD3Chart.py +++ b/nvd3/NVD3Chart.py @@ -45,7 +45,7 @@ class NVD3Chart(object): #: directory holding the assets (bower_components) assets_directory = './bower_components/' - # this attribute is overriden by children of this + # this attribute is overridden by children of this # class CHART_FILENAME = None template_environment = Environment(lstrip_blocks=True, trim_blocks=True, diff --git a/nvd3/bulletChart.py b/nvd3/bulletChart.py index d5701ed6..30310490 100644 --- a/nvd3/bulletChart.py +++ b/nvd3/bulletChart.py @@ -17,7 +17,7 @@ class bulletChart(TemplateMixin, NVD3Chart): A bullet chart is a variation of a bar graph used to indicate the value of a single variable in relation to a set of qualitative ranges. It is - inspired by a dashboard guage or thermometer chart. + inspired by a dashboard gauge or thermometer chart. Python example: diff --git a/nvd3/ipynb.py b/nvd3/ipynb.py index 39c9c361..8edb4e83 100644 --- a/nvd3/ipynb.py +++ b/nvd3/ipynb.py @@ -71,7 +71,7 @@ def initialize_javascript(d3_js_url='https://cdnjs.cloudflare.com/ajax/libs/d3/3 rel="stylesheet"/>''' % (nvd3_css_url))) # The following two methods for loading the script file are redundant. # This is intentional. - # Ipython's loading of javscript in version 1.x is a bit squirrely, especially + # Ipython's loading of javascript in version 1.x is a bit squirrely, especially # when creating demos to view in nbviewer. # by trying twice, in two different ways (one using jquery and one using plain old # HTML), we maximize our chances of successfully loading the script. diff --git a/nvd3/multiChart.py b/nvd3/multiChart.py index 1ef4cfaf..b4566ae7 100644 --- a/nvd3/multiChart.py +++ b/nvd3/multiChart.py @@ -36,7 +36,7 @@ class multiChart(TemplateMixin, NVD3Chart): chart.buildhtml() - Javascript renderd to: + Javascript rendered to: .. raw:: html From 9e8ada72d898ed8bb99495738dabfefbf4dc9303 Mon Sep 17 00:00:00 2001 From: areski Date: Wed, 4 Oct 2023 13:33:39 +0200 Subject: [PATCH 59/70] [fix](readme) update --- README.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.rst b/README.rst index f07013bd..83df4680 100644 --- a/README.rst +++ b/README.rst @@ -161,3 +161,9 @@ License ------- Python-nvd3 is licensed under MIT, see `MIT-LICENSE.txt`. + + +Maintainers +----------- + +If you want to help maintain this project, please get it touch. From 2f77421606efa526f0e7058485d9cf0da7bb8057 Mon Sep 17 00:00:00 2001 From: nuin <6273+nuin@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:12:24 -0600 Subject: [PATCH 60/70] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 83df4680..3830cef0 100644 --- a/README.rst +++ b/README.rst @@ -166,4 +166,4 @@ Python-nvd3 is licensed under MIT, see `MIT-LICENSE.txt`. Maintainers ----------- -If you want to help maintain this project, please get it touch. +If you want to help maintain this project, please get in touch. From b6fa40d68fe07057eda674aa6987175fc463fc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Thu, 18 Apr 2024 15:16:04 +0200 Subject: [PATCH 61/70] migrate Travis tests into GitHub actions --- .github/workflows/python-tests.yml | 36 ++++++++++++++++++++++++++++++ .travis.yml | 22 ------------------ 2 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/python-tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml new file mode 100644 index 00000000..e6de3c53 --- /dev/null +++ b/.github/workflows/python-tests.yml @@ -0,0 +1,36 @@ +name: Python Tests + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + fail-fast: false + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools + pip install -r requirements.txt + python setup.py install + pip install coveralls + + - name: Run tests + run: coverage run --source=nvd3 setup.py test + + - name: Finish coveralls + run: coveralls + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2f46df5c..00000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: python - -python: - - 2.7 - - 3.6 - - 3.7 - - 3.8 - - 3.9 - -install: - - pip install -r requirements.txt - - python setup.py install - - pip install coveralls - -script: - #- python tests.py - - coverage run --source=nvd3 setup.py test -notifications: - email: true - -after_success: - coveralls From 54b40394ab37955aec0bdeafb720fb5ee1800af3 Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 18 Apr 2024 15:45:42 +0200 Subject: [PATCH 62/70] [fix](general) update readme --- README.rst | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 3830cef0..c7022748 100644 --- a/README.rst +++ b/README.rst @@ -10,9 +10,6 @@ Python Wrapper for NVD3 - It's time for beautiful charts .. _Areski: https://github.com/areski/ .. _Oz: https://github.com/oz123/ -.. image:: https://api.travis-ci.org/areski/python-nvd3.png?branch=develop - :target: https://travis-ci.org/areski/python-nvd3 - .. image:: https://coveralls.io/repos/areski/python-nvd3/badge.png?branch=develop :target: https://coveralls.io/r/areski/python-nvd3?branch=develop @@ -32,10 +29,6 @@ Python Wrapper for NVD3 - It's time for beautiful charts :target: https://pypi.python.org/pypi/python-nvd3/ :alt: License -.. image:: https://requires.io/github/areski/python-nvd3/requirements.svg?branch=develop - :target: https://requires.io/github/areski/python-nvd3/requirements/?branch=develop - :alt: Requirements Status - NVD3 is an attempt to build re-usable charts and chart components for d3.js without taking away the power that d3.js offers you. @@ -46,8 +39,6 @@ These graphs can be part of your web application: .. image:: https://raw.githubusercontent.com/areski/python-nvd3/develop/docs/showcase/multiple-charts.png - - Want to try it yourself? Install python-nvd3, enter your python shell and try this quick demo:: >>> from nvd3 import pieChart @@ -109,6 +100,7 @@ Check out the documentation on `Read the Docs`_ for some live Chart examples! .. _Read the Docs: http://python-nvd3.readthedocs.org + Installation ------------ From 6aa30a0b59bb78db974632a7f06b3ad94b29d052 Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 18 Apr 2024 15:47:50 +0200 Subject: [PATCH 63/70] [fix](general) update classifiers up to py3.12 --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.py b/setup.py index cbe4e1b5..ab27dbe7 100644 --- a/setup.py +++ b/setup.py @@ -61,6 +61,13 @@ 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Multimedia :: Graphics :: Presentation', 'Topic :: Software Development :: Libraries :: Python Modules', ], From 69d0ff8315ad2f5e1142e3cf25830a181bbda971 Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 18 Apr 2024 15:55:38 +0200 Subject: [PATCH 64/70] [fix](general) replace type by chart_name --- .gitignore | 1 + README.rst | 4 +- docs/source/includes/introduction.txt | 4 +- docs/source/index.rst | 4 +- examples/cumulativeLineChart.py | 4 +- examples/demo_all.py | 32 ++++++------ examples/discreteBarChart.py | 4 +- examples/discreteBarChart_with_date.py | 4 +- examples/ipythonDemo.ipynb | 8 +-- examples/lineChart.py | 4 +- examples/lineChartXY.py | 4 +- examples/linePlusBarChart.py | 4 +- examples/lineWithFocusChart.py | 4 +- examples/multiBarChart.py | 4 +- examples/multiBarChart_date.py | 4 +- examples/multiBarHorizontalChart.py | 4 +- examples/multiChart.py | 4 +- examples/pieChart.py | 4 +- examples/scatterChart.py | 4 +- nvd3/bulletChart.py | 2 +- nvd3/multiChart.py | 4 +- tests.py | 70 +++++++++++++------------- 22 files changed, 91 insertions(+), 90 deletions(-) diff --git a/.gitignore b/.gitignore index 78ecd3eb..c15b2627 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ bower_components archive env +myenv htmlcov test_*.html diff --git a/README.rst b/README.rst index c7022748..667d5ca5 100644 --- a/README.rst +++ b/README.rst @@ -42,8 +42,8 @@ These graphs can be part of your web application: Want to try it yourself? Install python-nvd3, enter your python shell and try this quick demo:: >>> from nvd3 import pieChart - >>> type = 'pieChart' - >>> chart = pieChart(name=type, color_category='category20c', height=450, width=450) + >>> chart_name = 'pieChart' + >>> chart = pieChart(name=chart_name, color_category='category20c', height=450, width=450) >>> xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] >>> ydata = [3, 4, 0, 1, 5, 7, 3] >>> extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} diff --git a/docs/source/includes/introduction.txt b/docs/source/includes/introduction.txt index 414241ec..a1001bfd 100644 --- a/docs/source/includes/introduction.txt +++ b/docs/source/includes/introduction.txt @@ -52,8 +52,8 @@ After installation use python-nvd3 as follows :: # Open File to write the D3 Graph output_file = open('test-nvd3.html', 'w') - type = 'pieChart' - chart = pieChart(name=type, color_category='category20c', height=450, width=450) + chart_name = 'pieChart' + chart = pieChart(name=chart_name, color_category='category20c', height=450, width=450) chart.set_containerheader("\n\n

" + type + "

\n\n") xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] diff --git a/docs/source/index.rst b/docs/source/index.rst index 2915604c..30f22f45 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -25,8 +25,8 @@ These graphs can be part of your web application: Want to try it yourself? Install python-nvd3, enter your python shell and try this quick demo:: >>> from nvd3 import pieChart - >>> type = 'pieChart' - >>> chart = pieChart(name=type, color_category='category20c', height=450, width=450) + >>> chart_name = 'pieChart' + >>> chart = pieChart(name=chart_name, color_category='category20c', height=450, width=450) >>> xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] >>> ydata = [3, 4, 0, 1, 5, 7, 3] >>> extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} diff --git a/examples/cumulativeLineChart.py b/examples/cumulativeLineChart.py index d0864fd3..c3ecc444 100644 --- a/examples/cumulativeLineChart.py +++ b/examples/cumulativeLineChart.py @@ -21,8 +21,8 @@ # Open File for test output_file = open('test_cumulativeLineChart.html', 'w') -type = "cumulativeLineChart" -chart = cumulativeLineChart(name=type, height=350, x_is_date=True) +chart_name = "cumulativeLineChart" +chart = cumulativeLineChart(name=chart_name, height=350, x_is_date=True) chart.set_containerheader("\n\n

" + type + "

\n\n") xdata = list(range(nb_element)) diff --git a/examples/demo_all.py b/examples/demo_all.py index c2c161b4..175542c7 100644 --- a/examples/demo_all.py +++ b/examples/demo_all.py @@ -45,7 +45,7 @@ output_file.write(html_open) -type = "discreteBarChart" +chart_name = "discreteBarChart" chart = discreteBarChart(name='my graphname', height=400, width=800, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") xdata = ["A", "B", "C", "D", "E", "F", "G"] @@ -58,8 +58,8 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "pie Chart" -chart = pieChart(name=type, color_category='category20c', height=400, +chart_name = "pie Chart" +chart = pieChart(name=chart_name, color_category='category20c', height=400, width=400, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") @@ -74,7 +74,7 @@ # --------------------------------------- name = "lineChart-different-x-axis" -type = "lineChart" +chart_name = "lineChart" chart = lineChart(name=name, height=400, width=800, x_is_date=False, jquery_on_ready=True) @@ -98,7 +98,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "lineChart" +chart_name = "lineChart" chart = lineChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y %H", jquery_on_ready=True) @@ -123,7 +123,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "lineChartWithInteractiveGuideline" +chart_name = "lineChartWithInteractiveGuideline" chart = lineChart(name="lineChart-With-Interactive-Guideline", height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y %H", jquery_on_ready=True, use_interactive_guideline=True) @@ -149,7 +149,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "lineWithFocusChart" +chart_name = "lineWithFocusChart" chart = lineWithFocusChart(color_category='category20b', x_is_date=True, height=400, width=800, x_axis_format="%d %b %Y", jquery_on_ready=True) @@ -177,7 +177,7 @@ # --------------------------------------- -type = "stackedAreaChart" +chart_name = "stackedAreaChart" chart = stackedAreaChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y %I", jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") @@ -197,7 +197,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "linePlusBarChart" +chart_name = "linePlusBarChart" chart = linePlusBarChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y", jquery_on_ready=True, focus_enable=True) @@ -219,7 +219,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "cumulativeLineChart" +chart_name = "cumulativeLineChart" chart = cumulativeLineChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y", jquery_on_ready=True) @@ -240,7 +240,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "multiBarHorizontalChart" +chart_name = "multiBarHorizontalChart" chart = multiBarHorizontalChart(height=400, width=800, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") @@ -258,7 +258,7 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "multiBarChart" +chart_name = "multiBarChart" chart = multiBarChart(height=400, width=800, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 10 @@ -275,8 +275,8 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "multiBarChartDate" -chart = multiBarChart(name=type, height=400, width=800, x_is_date=True, jquery_on_ready=True) +chart_name = "multiBarChartDate" +chart = multiBarChart(name=chart_name, height=400, width=800, x_is_date=True, jquery_on_ready=True) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 100 start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) @@ -297,8 +297,8 @@ output_file.write(chart.htmlcontent) # --------------------------------------- -type = "scatterChart" -chart = scatterChart(name=type, height=350, width=800, x_is_date=False) +chart_name = "scatterChart" +chart = scatterChart(name=chart_name, height=350, width=800, x_is_date=False) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 50 xdata = [i + random.randint(1, 10) for i in range(nb_element)] diff --git a/examples/discreteBarChart.py b/examples/discreteBarChart.py index e8ffa29b..952a4f20 100644 --- a/examples/discreteBarChart.py +++ b/examples/discreteBarChart.py @@ -15,7 +15,7 @@ # Open File for test output_file = open('test_discreteBarChart.html', 'w') -type = "discreteBarChart" +chart_name = "discreteBarChart" chart = discreteBarChart(name='mygraphname', height=400, width=600, show_values=True, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") chart.set_containerheader("\n\n

" + type + "

\n\n") xdata = ["A", "B", "C", "D", "E", "F", "G"] @@ -33,7 +33,7 @@ output_file = open('test_discreteBarChart2.html', 'w') -type = "discreteBarChart" +chart_name = "discreteBarChart" chart = discreteBarChart(name='mygraphname', height=400, width=600, tooltips=False) chart.set_containerheader("\n\n

" + type + "

\n\n") diff --git a/examples/discreteBarChart_with_date.py b/examples/discreteBarChart_with_date.py index f8798657..9d6c2fa1 100644 --- a/examples/discreteBarChart_with_date.py +++ b/examples/discreteBarChart_with_date.py @@ -18,7 +18,7 @@ # Open File for test output_file = open('test_discreteBarChart_with_date.html', 'w') -type = "discreteBarChart" +chart_name = "discreteBarChart" start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) nb_element = 10 @@ -27,7 +27,7 @@ xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] -chart = discreteBarChart(name=type, height=400, width=600, x_is_date=True, x_axis_format="%d-%b") +chart = discreteBarChart(name=chart_name, height=400, width=600, x_is_date=True, x_axis_format="%d-%b") chart.set_containerheader("\n\n

" + type + "

\n\n") extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} diff --git a/examples/ipythonDemo.ipynb b/examples/ipythonDemo.ipynb index f2f5dd1c..696dda0f 100644 --- a/examples/ipythonDemo.ipynb +++ b/examples/ipythonDemo.ipynb @@ -86,8 +86,8 @@ }, "outputs": [], "source": [ - "type = 'stackedAreaChart'\n", - "chart2 = nvd3.stackedAreaChart(name=type,height=450,width=500, \n", + "chart_name = 'stackedAreaChart'\n", + "chart2 = nvd3.stackedAreaChart(name=chart_name,height=450,width=500, \n", " use_interactive_guideline=True)\n", "nb_element = 50\n", "xdata = range(nb_element)\n", @@ -142,8 +142,8 @@ }, "outputs": [], "source": [ - "type = 'pieChart'\n", - "chart1 = nvd3.pieChart(name=type, color_category='category20c', height=450, width=450)\n", + "chart_name = 'pieChart'\n", + "chart1 = nvd3.pieChart(name=chart_name, color_category='category20c', height=450, width=450)\n", "chart1.set_containerheader(\"\\n\\n

\" + type + \"

\\n\\n\")\n", "\n", "#Create the keys\n", diff --git a/examples/lineChart.py b/examples/lineChart.py index 1dce1b9a..053b7e76 100644 --- a/examples/lineChart.py +++ b/examples/lineChart.py @@ -14,8 +14,8 @@ # Open File for test output_file = open('test_lineChart.html', 'w') # --------------------------------------- -type = "lineChart" -chart = lineChart(name=type, x_is_date=False, x_axis_format="AM_PM") +chart_name = "lineChart" +chart = lineChart(name=chart_name, x_is_date=False, x_axis_format="AM_PM") xdata = list(range(0, 24)) ydata = [0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 4, 3, 3, 5, 7, 5, 3, 16, 6, 9, 15, 4, 12] diff --git a/examples/lineChartXY.py b/examples/lineChartXY.py index f74a1a9a..1e8ae2d8 100644 --- a/examples/lineChartXY.py +++ b/examples/lineChartXY.py @@ -14,8 +14,8 @@ output_file = open('test_lineChartXY.html', 'w') -type = "lineChart" -chart = lineChart(name=type, x_is_date=False, +chart_name = "lineChart" +chart = lineChart(name=chart_name, x_is_date=False, x_axis_format=".1f", y_axis_format=".1f", width=500, height=500, show_legend=False) diff --git a/examples/linePlusBarChart.py b/examples/linePlusBarChart.py index 3dbeba71..e1d38265 100644 --- a/examples/linePlusBarChart.py +++ b/examples/linePlusBarChart.py @@ -20,8 +20,8 @@ output_file = open('test_linePlusBarChart.html', 'w') -type = "linePlusBarChart" -chart = linePlusBarChart(name=type, height=350, width=750, +chart_name = "linePlusBarChart" +chart = linePlusBarChart(name=chart_name, height=350, width=750, x_is_date=True, x_axis_format="%d %b %Y", focus_enable=True) chart.set_containerheader("\n\n

" + type + "

\n\n") diff --git a/examples/lineWithFocusChart.py b/examples/lineWithFocusChart.py index 7d765019..8e14f700 100644 --- a/examples/lineWithFocusChart.py +++ b/examples/lineWithFocusChart.py @@ -21,8 +21,8 @@ # Open File for test output_file = open('test_lineWithFocusChart.html', 'w') # --------------------------------------- -type = "lineWithFocusChart" -chart = lineWithFocusChart(name=type, height=550, width=850, +chart_name = "lineWithFocusChart" +chart = lineWithFocusChart(name=chart_name, height=550, width=850, color_category='category20b', x_is_date=True, x_axis_format="%d %b %Y %H", focus_enable=True) chart.set_containerheader("\n\n

" + type + "

\n\n") diff --git a/examples/multiBarChart.py b/examples/multiBarChart.py index f914a356..96752284 100644 --- a/examples/multiBarChart.py +++ b/examples/multiBarChart.py @@ -15,8 +15,8 @@ # Open File for test output_file = open('test_multiBarChart.html', 'w') -type = "multiBarChart" -chart = multiBarChart(name=type, height=350) +chart_name = "multiBarChart" +chart = multiBarChart(name=chart_name, height=350) chart.set_containerheader("\n\n

" + type + "

\n\n") chart.callback = ''' function(){ diff --git a/examples/multiBarChart_date.py b/examples/multiBarChart_date.py index afd5ff02..b1557e0a 100644 --- a/examples/multiBarChart_date.py +++ b/examples/multiBarChart_date.py @@ -17,9 +17,9 @@ # Open File for test output_file = open('test_multiBarChart_date.html', 'w') -type = "multiBarChart" +chart_name = "multiBarChart" -chart = multiBarChart(name=type, height=350, x_is_date=True) +chart = multiBarChart(name=chart_name, height=350, x_is_date=True) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 100 diff --git a/examples/multiBarHorizontalChart.py b/examples/multiBarHorizontalChart.py index c8b5c790..84d2e41e 100644 --- a/examples/multiBarHorizontalChart.py +++ b/examples/multiBarHorizontalChart.py @@ -15,8 +15,8 @@ # Open File for test output_file = open('test_multiBarHorizontalChart.html', 'w') -type = "multiBarHorizontalChart" -chart = multiBarHorizontalChart(name=type, height=350) +chart_name = "multiBarHorizontalChart" +chart = multiBarHorizontalChart(name=chart_name, height=350) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 10 diff --git a/examples/multiChart.py b/examples/multiChart.py index 501c2044..f1960e5c 100644 --- a/examples/multiChart.py +++ b/examples/multiChart.py @@ -14,8 +14,8 @@ # Open File for test output_file = open('test_multiChart.html', 'w') # --------------------------------------- -type = "multiChart" -chart = multiChart(name=type, x_is_date=False, x_axis_format="AM_PM") +chart_name = "multiChart" +chart = multiChart(name=chart_name, x_is_date=False, x_axis_format="AM_PM") xdata = [1,2,3,4,5,6] ydata = [115.5,160.5,108,145.5,84,70.5] diff --git a/examples/pieChart.py b/examples/pieChart.py index 3e208a6b..e192b436 100644 --- a/examples/pieChart.py +++ b/examples/pieChart.py @@ -15,8 +15,8 @@ # Open File for test output_file = open('test_pieChart.html', 'w') -type = "pieChart" -chart = pieChart(name=type, color_category='category20c', height=400, width=400, extras="d3.selectAll('#piechart .nv-slice').style('opacity', 0.5);") +chart_name = "pieChart" +chart = pieChart(name=chart_name, color_category='category20c', height=400, width=400, extras="d3.selectAll('#piechart .nv-slice').style('opacity', 0.5);") chart.set_containerheader("\n\n

" + type + "

\n\n") chart.callback = ''' function(){ diff --git a/examples/scatterChart.py b/examples/scatterChart.py index 51338907..d58d8522 100644 --- a/examples/scatterChart.py +++ b/examples/scatterChart.py @@ -15,8 +15,8 @@ # Open File for test output_file = open('test_scatterChart.html', 'w') -type = "scatterChart" -chart = scatterChart(name=type, height=350, width=800, x_is_date=False) +chart_name = "scatterChart" +chart = scatterChart(name=chart_name, height=350, width=800, x_is_date=False) chart.set_containerheader("\n\n

" + type + "

\n\n") nb_element = 50 xdata = [i + random.randint(1, 10) for i in range(nb_element)] diff --git a/nvd3/bulletChart.py b/nvd3/bulletChart.py index 6805ff07..867c2e1a 100644 --- a/nvd3/bulletChart.py +++ b/nvd3/bulletChart.py @@ -22,7 +22,7 @@ class bulletChart(TemplateMixin, NVD3Chart): Python example: from nvd3.bulletChart import bulletChart - chart = bulletChart.bulletChart(name=type, height=100, width=500) + chart = bulletChart.bulletChart(name=chart_name, height=100, width=500) title = 'Revenue', subtitle = 'US$, in thousands' ranges = [150, 225, 300] diff --git a/nvd3/multiChart.py b/nvd3/multiChart.py index f94bb9b5..2880fd82 100644 --- a/nvd3/multiChart.py +++ b/nvd3/multiChart.py @@ -20,8 +20,8 @@ class multiChart(TemplateMixin, NVD3Chart): Python example:: from nvd3 import multiChart - type = "multiChart" - chart = multiChart(name=type, x_is_date=False, x_axis_format="AM_PM") + chart_name = "multiChart" + chart = multiChart(name=chart_name, x_is_date=False, x_axis_format="AM_PM") xdata = [1,2,3,4,5,6] ydata = [115.5,160.5,108,145.5,84,70.5] diff --git a/tests.py b/tests.py index 63b73c70..2e7c64fe 100644 --- a/tests.py +++ b/tests.py @@ -32,8 +32,8 @@ def test_chartWithBadName(self): def test_lineWithFocusChart(self): """Test Line With Focus Chart""" - type = "lineWithFocusChart" - chart = lineWithFocusChart(name=type, date=True, height=350) + chart_name = "lineWithFocusChart" + chart = lineWithFocusChart(name=chart_name, date=True, height=350) nb_element = 100 xdata = list(range(nb_element)) xdata = [1365026400000 + x * 100000 for x in xdata] @@ -45,8 +45,8 @@ def test_lineWithFocusChart(self): def test_lineChart(self): """Test Line Chart""" - type = "lineChart" - chart = lineChart(name=type, date=True, height=350) + chart_name = "lineChart" + chart = lineChart(name=chart_name, date=True, height=350) nb_element = 100 xdata = list(range(nb_element)) xdata = [1365026400000 + x * 100000 for x in xdata] @@ -61,8 +61,8 @@ def test_lineChart(self): def test_lineChart_tooltip(self): """Test Line Chart""" - type = "lineChart" - chart = lineChart(name=type, date=True, height=350) + chart_name = "lineChart" + chart = lineChart(name=chart_name, date=True, height=350) nb_element = 100 xdata = list(range(nb_element)) xdata = [1365026400000 + x * 100000 for x in xdata] @@ -83,8 +83,8 @@ def test_lineChart_tooltip(self): def test_linePlusBarChart(self): """Test line Plus Bar Chart""" - type = "linePlusBarChart" - chart = linePlusBarChart(name=type, date=True, height=350) + chart_name = "linePlusBarChart" + chart = linePlusBarChart(name=chart_name, date=True, height=350) start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) nb_element = 100 xdata = list(range(nb_element)) @@ -99,8 +99,8 @@ def test_linePlusBarChart(self): def test_stackedAreaChart(self): """Test Stacked Area Chart""" - type = "stackedAreaChart" - chart = stackedAreaChart(name=type, height=400) + chart_name = "stackedAreaChart" + chart = stackedAreaChart(name=chart_name, height=400) nb_element = 100 xdata = list(range(nb_element)) xdata = [100 + x for x in xdata] @@ -112,8 +112,8 @@ def test_stackedAreaChart(self): def test_MultiBarChart(self): """Test Multi Bar Chart""" - type = "MultiBarChart" - chart = multiBarChart(name=type, height=400) + chart_name = "MultiBarChart" + chart = multiBarChart(name=chart_name, height=400) nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(1, 10) for i in range(nb_element)] @@ -123,9 +123,9 @@ def test_MultiBarChart(self): def test_multiChart(self): """Test Multi (line plus bar) Chart""" - type = "multiChart" + chart_name = "multiChart" chart = multiChart( - name=type, x_is_date=False, x_axis_format="AM_PM", + name=chart_name, x_is_date=False, x_axis_format="AM_PM", no_data_message='custom message shows when there is no data', xAxis_staggerLabel=True ) @@ -147,8 +147,8 @@ def test_multiChart(self): def test_multiBarHorizontalChart(self): """Test multi Bar Horizontal Chart""" - type = "multiBarHorizontalChart" - chart = multiBarHorizontalChart(name=type, height=350) + chart_name = "multiBarHorizontalChart" + chart = multiBarHorizontalChart(name=chart_name, height=350) nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(-10, 10) for i in range(nb_element)] @@ -159,8 +159,8 @@ def test_multiBarHorizontalChart(self): def test_cumulativeLineChart(self): """Test Cumulative Line Chart""" - type = "cumulativeLineChart" - chart = cumulativeLineChart(name=type, height=400) + chart_name = "cumulativeLineChart" + chart = cumulativeLineChart(name=chart_name, height=400) start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) nb_element = 100 xdata = list(range(nb_element)) @@ -173,8 +173,8 @@ def test_cumulativeLineChart(self): def test_scatterChart(self): """Test Scatter Chart""" - type = "scatterChart" - chart = scatterChart(name=type, date=True, height=350) + chart_name = "scatterChart" + chart = scatterChart(name=chart_name, date=True, height=350) nb_element = 100 xdata = [i + random.randint(1, 10) for i in range(nb_element)] ydata = [i * random.randint(1, 10) for i in range(nb_element)] @@ -191,8 +191,8 @@ def test_scatterChart(self): def test_discreteBarChart(self): """Test discrete Bar Chart""" - type = "discreteBarChart" - chart = discreteBarChart(name=type, height=350) + chart_name = "discreteBarChart" + chart = discreteBarChart(name=chart_name, height=350) xdata = ["A", "B", "C", "D", "E", "F", "G"] ydata = [3, 12, -10, 5, 35, -7, 2] @@ -205,8 +205,8 @@ def test_discreteBarChart(self): def test_pieChart(self): """Test Pie Chart""" - type = "pieChart" - chart = pieChart(name=type, color_category='category20c', height=400, width=400) + chart_name = "pieChart" + chart = pieChart(name=chart_name, color_category='category20c', height=400, width=400) xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] color_list = ['orange', 'yellow', '#C5E946', '#95b43f', 'red', '#FF2259', '#F6A641'] extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}, "color_list": color_list} @@ -218,16 +218,16 @@ def test_pieChart(self): def test_donutPieChart(self): """Test Donut Pie Chart""" - type = "pieChart" - chart = pieChart(name=type, height=400, width=400, donut=True, donutRatio=0.2) + chart_name = "pieChart" + chart = pieChart(name=chart_name, height=400, width=400, donut=True, donutRatio=0.2) xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] ydata = [3, 4, 0, 1, 5, 7, 3] chart.add_serie(y=ydata, x=xdata) chart.buildhtml() def test_can_create_bulletChart(self): - type = 'bulletChart' - chart = bulletChart(name=type, height=100, width=500) + chart_name = 'bulletChart' + chart = bulletChart(name=chart_name, height=100, width=500) title = 'Revenue', subtitle = 'US$, in thousands' ranges = [150, 225, 300] @@ -242,8 +242,8 @@ def test_can_create_bulletChart(self): chart.buildhtml() def test_bulletChart_htmlcontent_correct(self): - type = 'bulletChart' - chart = bulletChart(name=type, height=100, width=500) + chart_name = 'bulletChart' + chart = bulletChart(name=chart_name, height=100, width=500) title = 'Revenue', subtitle = 'USD, in mill' ranges = [100, 250, 300] @@ -262,8 +262,8 @@ def test_bulletChart_htmlcontent_correct(self): assert 'nv.models.bulletChart();' in chart.htmlcontent def test_bulletChart_marker_optional(self): - type = 'bulletChart' - chart = bulletChart(name=type, height=100, width=500) + chart_name = 'bulletChart' + chart = bulletChart(name=chart_name, height=100, width=500) title = 'Revenue', subtitle = 'USD, in mill' ranges = [100, 250, 300] @@ -282,18 +282,18 @@ def test_bulletChart_marker_optional(self): def test_charts_with_extras(self): # extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)" type_bullet = 'bulletChart' - bullet_chart = bulletChart(name=type_bullet, height=100, width=500, extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)") + bullet_chart = bulletChart(name=chart_name_bullet, height=100, width=500, extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)") bullet_chart.buildhtml() assert 'data_bulletchart' in bullet_chart.htmlcontent assert "d3.selectAll('#mygraphname text').style('opacity', 0.5)" in bullet_chart.htmlcontent type_pie = "pieChart" - pie_chart = pieChart(name=type_pie, height=400, width=400, donut=True, donutRatio=0.2, extras="alert('Example of extra not even related to d3!')") + pie_chart = pieChart(name=chart_name_pie, height=400, width=400, donut=True, donutRatio=0.2, extras="alert('Example of extra not even related to d3!')") pie_chart.buildhtml() assert "alert('Example of extra not even related to d3!')" in pie_chart.htmlcontent type_line_plus_bar = "linePlusBarChart" - line_plus_bar_chart = linePlusBarChart(name=type_line_plus_bar, date=True, height=350, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") + line_plus_bar_chart = linePlusBarChart(name=chart_name_line_plus_bar, date=True, height=350, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") line_plus_bar_chart.buildhtml() assert "d3.selectAll('#mygraphname text').style('fill', 'red')" in line_plus_bar_chart.htmlcontent From 203c6901da967ce53648853292b55258f938a39f Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 18 Apr 2024 15:59:02 +0200 Subject: [PATCH 65/70] [fix](general) replace type by chart_name --- tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests.py b/tests.py index 2e7c64fe..2f3d80dc 100644 --- a/tests.py +++ b/tests.py @@ -281,19 +281,19 @@ def test_bulletChart_marker_optional(self): def test_charts_with_extras(self): # extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)" - type_bullet = 'bulletChart' - bullet_chart = bulletChart(name=chart_name_bullet, height=100, width=500, extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)") + chart_name = 'bulletChart' + bullet_chart = bulletChart(name=chart_name, height=100, width=500, extras="d3.selectAll('#mygraphname text').style('opacity', 0.5)") bullet_chart.buildhtml() assert 'data_bulletchart' in bullet_chart.htmlcontent assert "d3.selectAll('#mygraphname text').style('opacity', 0.5)" in bullet_chart.htmlcontent - type_pie = "pieChart" - pie_chart = pieChart(name=chart_name_pie, height=400, width=400, donut=True, donutRatio=0.2, extras="alert('Example of extra not even related to d3!')") + chart_name = "pieChart" + pie_chart = pieChart(name=chart_name, height=400, width=400, donut=True, donutRatio=0.2, extras="alert('Example of extra not even related to d3!')") pie_chart.buildhtml() assert "alert('Example of extra not even related to d3!')" in pie_chart.htmlcontent - type_line_plus_bar = "linePlusBarChart" - line_plus_bar_chart = linePlusBarChart(name=chart_name_line_plus_bar, date=True, height=350, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") + chart_name = "linePlusBarChart" + line_plus_bar_chart = linePlusBarChart(name=chart_name, date=True, height=350, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") line_plus_bar_chart.buildhtml() assert "d3.selectAll('#mygraphname text').style('fill', 'red')" in line_plus_bar_chart.htmlcontent From f907c4a0ff31d76f1b70c430ea706cce01838d94 Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 18 Apr 2024 16:16:17 +0200 Subject: [PATCH 66/70] [fix](general) replace type by chart_name --- .gitignore | 1 + docs/source/includes/introduction.txt | 2 +- examples/cumulativeLineChart.py | 2 +- examples/demo_all.py | 24 ++++++++++++------------ examples/discreteBarChart.py | 4 ++-- examples/discreteBarChart_with_date.py | 2 +- examples/ipythonDemo.ipynb | 2 +- examples/linePlusBarChart.py | 2 +- examples/lineWithFocusChart.py | 2 +- examples/multiBarChart.py | 2 +- examples/multiBarChart_date.py | 2 +- examples/multiBarHorizontalChart.py | 2 +- examples/pieChart.py | 2 +- examples/scatterChart.py | 2 +- 14 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index c15b2627..c69b9ca6 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ bower_components archive env myenv +nvd3_env htmlcov test_*.html diff --git a/docs/source/includes/introduction.txt b/docs/source/includes/introduction.txt index a1001bfd..a32fe22f 100644 --- a/docs/source/includes/introduction.txt +++ b/docs/source/includes/introduction.txt @@ -54,7 +54,7 @@ After installation use python-nvd3 as follows :: chart_name = 'pieChart' chart = pieChart(name=chart_name, color_category='category20c', height=450, width=450) - chart.set_containerheader("\n\n

" + type + "

\n\n") + chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = ["Orange", "Banana", "Pear", "Kiwi", "Apple", "Strawberry", "Pineapple"] ydata = [3, 4, 0, 1, 5, 7, 3] diff --git a/examples/cumulativeLineChart.py b/examples/cumulativeLineChart.py index c3ecc444..63ae11ec 100644 --- a/examples/cumulativeLineChart.py +++ b/examples/cumulativeLineChart.py @@ -23,7 +23,7 @@ chart_name = "cumulativeLineChart" chart = cumulativeLineChart(name=chart_name, height=350, x_is_date=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] diff --git a/examples/demo_all.py b/examples/demo_all.py index 175542c7..1d426e23 100644 --- a/examples/demo_all.py +++ b/examples/demo_all.py @@ -47,7 +47,7 @@ chart_name = "discreteBarChart" chart = discreteBarChart(name='my graphname', height=400, width=800, jquery_on_ready=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = ["A", "B", "C", "D", "E", "F", "G"] ydata = [3, 12, -10, 5, 25, -7, 2] @@ -61,7 +61,7 @@ chart_name = "pie Chart" chart = pieChart(name=chart_name, color_category='category20c', height=400, width=400, jquery_on_ready=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") color_list = ['orange', 'yellow', '#C5E946', '#95b43f', 'red', '#FF2259', '#F6A641'] extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}, "color_list": color_list} @@ -102,7 +102,7 @@ chart = lineChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y %H", jquery_on_ready=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] @@ -128,7 +128,7 @@ height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y %H", jquery_on_ready=True, use_interactive_guideline=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] @@ -153,7 +153,7 @@ chart = lineWithFocusChart(color_category='category20b', x_is_date=True, height=400, width=800, x_axis_format="%d %b %Y", jquery_on_ready=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] @@ -180,7 +180,7 @@ chart_name = "stackedAreaChart" chart = stackedAreaChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y %I", jquery_on_ready=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] @@ -201,7 +201,7 @@ chart = linePlusBarChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y", jquery_on_ready=True, focus_enable=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] @@ -223,7 +223,7 @@ chart = cumulativeLineChart(height=400, width=800, x_is_date=True, x_axis_format="%d %b %Y", jquery_on_ready=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] @@ -242,7 +242,7 @@ chart_name = "multiBarHorizontalChart" chart = multiBarHorizontalChart(height=400, width=800, jquery_on_ready=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") nb_element = 10 xdata = list(range(nb_element)) @@ -260,7 +260,7 @@ chart_name = "multiBarChart" chart = multiBarChart(height=400, width=800, jquery_on_ready=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(1, 10) for i in range(nb_element)] @@ -277,7 +277,7 @@ chart_name = "multiBarChartDate" chart = multiBarChart(name=chart_name, height=400, width=800, x_is_date=True, jquery_on_ready=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") nb_element = 100 start_time = int(time.mktime(datetime.datetime(2012, 6, 1).timetuple()) * 1000) xdata = range(nb_element) @@ -299,7 +299,7 @@ chart_name = "scatterChart" chart = scatterChart(name=chart_name, height=350, width=800, x_is_date=False) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") nb_element = 50 xdata = [i + random.randint(1, 10) for i in range(nb_element)] ydata = [i * random.randint(1, 10) for i in range(nb_element)] diff --git a/examples/discreteBarChart.py b/examples/discreteBarChart.py index 952a4f20..776a47b0 100644 --- a/examples/discreteBarChart.py +++ b/examples/discreteBarChart.py @@ -17,7 +17,7 @@ chart_name = "discreteBarChart" chart = discreteBarChart(name='mygraphname', height=400, width=600, show_values=True, extras="d3.selectAll('#mygraphname text').style('fill', 'red')") -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = ["A", "B", "C", "D", "E", "F", "G"] ydata = [3, 12, -10, 5, 25, -7, 2] @@ -36,7 +36,7 @@ chart_name = "discreteBarChart" chart = discreteBarChart(name='mygraphname', height=400, width=600, tooltips=False) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = ["A", "B", "C", "D", "E", "F", "G"] ydata = [3, 12, -10, 5, 25, -7, 2] diff --git a/examples/discreteBarChart_with_date.py b/examples/discreteBarChart_with_date.py index 9d6c2fa1..ebafafd4 100644 --- a/examples/discreteBarChart_with_date.py +++ b/examples/discreteBarChart_with_date.py @@ -28,7 +28,7 @@ ydata = [i + random.randint(1, 10) for i in range(nb_element)] chart = discreteBarChart(name=chart_name, height=400, width=600, x_is_date=True, x_axis_format="%d-%b") -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") extra_serie = {"tooltip": {"y_start": "", "y_end": " cal"}} chart.add_serie(y=ydata, x=xdata, extra=extra_serie) diff --git a/examples/ipythonDemo.ipynb b/examples/ipythonDemo.ipynb index 696dda0f..46637d73 100644 --- a/examples/ipythonDemo.ipynb +++ b/examples/ipythonDemo.ipynb @@ -144,7 +144,7 @@ "source": [ "chart_name = 'pieChart'\n", "chart1 = nvd3.pieChart(name=chart_name, color_category='category20c', height=450, width=450)\n", - "chart1.set_containerheader(\"\\n\\n

\" + type + \"

\\n\\n\")\n", + "chart1.set_containerheader(\"\\n\\n

\" + chart_name + \"

\\n\\n\")\n", "\n", "#Create the keys\n", "xdata = [\"Orange\", \"Banana\", \"Pear\", \"Kiwi\", \"Apple\", \"Strawberry\", \"Pineapple\"]\n", diff --git a/examples/linePlusBarChart.py b/examples/linePlusBarChart.py index e1d38265..f8981df7 100644 --- a/examples/linePlusBarChart.py +++ b/examples/linePlusBarChart.py @@ -24,7 +24,7 @@ chart = linePlusBarChart(name=chart_name, height=350, width=750, x_is_date=True, x_axis_format="%d %b %Y", focus_enable=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] diff --git a/examples/lineWithFocusChart.py b/examples/lineWithFocusChart.py index 8e14f700..bd71dfee 100644 --- a/examples/lineWithFocusChart.py +++ b/examples/lineWithFocusChart.py @@ -25,7 +25,7 @@ chart = lineWithFocusChart(name=chart_name, height=550, width=850, color_category='category20b', x_is_date=True, x_axis_format="%d %b %Y %H", focus_enable=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") xdata = list(range(nb_element)) xdata = [start_time + x * 1000000000 for x in xdata] diff --git a/examples/multiBarChart.py b/examples/multiBarChart.py index 96752284..d07876e9 100644 --- a/examples/multiBarChart.py +++ b/examples/multiBarChart.py @@ -17,7 +17,7 @@ chart_name = "multiBarChart" chart = multiBarChart(name=chart_name, height=350) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") chart.callback = ''' function(){ d3.selectAll(".nv-bar").on('click', diff --git a/examples/multiBarChart_date.py b/examples/multiBarChart_date.py index b1557e0a..19eff29e 100644 --- a/examples/multiBarChart_date.py +++ b/examples/multiBarChart_date.py @@ -20,7 +20,7 @@ chart_name = "multiBarChart" chart = multiBarChart(name=chart_name, height=350, x_is_date=True) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") nb_element = 100 start_time = int(time.mktime(datetime.datetime(2013, 6, 1).timetuple()) * 1000) diff --git a/examples/multiBarHorizontalChart.py b/examples/multiBarHorizontalChart.py index 84d2e41e..cd03fa9a 100644 --- a/examples/multiBarHorizontalChart.py +++ b/examples/multiBarHorizontalChart.py @@ -17,7 +17,7 @@ chart_name = "multiBarHorizontalChart" chart = multiBarHorizontalChart(name=chart_name, height=350) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") nb_element = 10 xdata = list(range(nb_element)) diff --git a/examples/pieChart.py b/examples/pieChart.py index e192b436..207695f4 100644 --- a/examples/pieChart.py +++ b/examples/pieChart.py @@ -17,7 +17,7 @@ chart_name = "pieChart" chart = pieChart(name=chart_name, color_category='category20c', height=400, width=400, extras="d3.selectAll('#piechart .nv-slice').style('opacity', 0.5);") -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") chart.callback = ''' function(){ d3.selectAll(".nv-pie .nv-pie .nv-slice").on('click', diff --git a/examples/scatterChart.py b/examples/scatterChart.py index d58d8522..97c70af8 100644 --- a/examples/scatterChart.py +++ b/examples/scatterChart.py @@ -17,7 +17,7 @@ chart_name = "scatterChart" chart = scatterChart(name=chart_name, height=350, width=800, x_is_date=False) -chart.set_containerheader("\n\n

" + type + "

\n\n") +chart.set_containerheader("\n\n

" + chart_name + "

\n\n") nb_element = 50 xdata = [i + random.randint(1, 10) for i in range(nb_element)] ydata = [i * random.randint(1, 10) for i in range(nb_element)] From d8b3e0ee5bba20ea15afb4cf4ac16736414a5232 Mon Sep 17 00:00:00 2001 From: areski Date: Mon, 22 Apr 2024 09:39:12 +0200 Subject: [PATCH 67/70] [fix](version) release prep --- update_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update_version.sh b/update_version.sh index 8be0cab8..33077f49 100755 --- a/update_version.sh +++ b/update_version.sh @@ -1,6 +1,6 @@ # # Usage: -# ./update_version.sh 0.12.0 +# ./update_version.sh 0.14.0 # git flow release start v$1 @@ -12,6 +12,6 @@ sed -i -e "s/version='.*'/version='$1'/g" setup.py #git commit docs nvd3/__init__.py -m "Update to version v$1" git commit -a -m "Update to version v$1" git flow release finish v$1 -python setup.py sdist +python setup.py sdist twine upload dist/python-nvd3-$1.tar.gz git push origin develop; git push origin master; git push --tags From 6a0afdc5c8e8cb5d9fad20834181a7a1aa4b8715 Mon Sep 17 00:00:00 2001 From: areski Date: Mon, 22 Apr 2024 09:39:20 +0200 Subject: [PATCH 68/70] Update to version v0.14.0 --- nvd3/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nvd3/__init__.py b/nvd3/__init__.py index c73235ac..2c1eed1d 100755 --- a/nvd3/__init__.py +++ b/nvd3/__init__.py @@ -9,7 +9,7 @@ Project location : https://github.com/areski/python-nvd3 """ -__version__ = '0.14.2' +__version__ = '0.14.0' __all__ = ['lineChart', 'pieChart', 'lineWithFocusChart', 'stackedAreaChart', 'multiBarHorizontalChart', 'linePlusBarChart', 'cumulativeLineChart', diff --git a/setup.py b/setup.py index ab27dbe7..920fdbc9 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( name='python-nvd3', - version='0.14.2', + version='0.14.0', description="Python NVD3 - Chart Library for d3.js", long_description=readme + '\n\n' + history, keywords='plot, graph, nvd3, d3', From fee4f1a91e7e4a2c2a27ff2b62556d8db493b6b1 Mon Sep 17 00:00:00 2001 From: areski Date: Mon, 22 Apr 2024 09:49:52 +0200 Subject: [PATCH 69/70] [fix](version) release prep --- update_version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_version.sh b/update_version.sh index 33077f49..c342e7b9 100755 --- a/update_version.sh +++ b/update_version.sh @@ -1,6 +1,6 @@ # # Usage: -# ./update_version.sh 0.14.0 +# ./update_version.sh 0.16.0 # git flow release start v$1 From 456c24faf63866bf624718859e4836572167b0d8 Mon Sep 17 00:00:00 2001 From: areski Date: Mon, 22 Apr 2024 09:49:58 +0200 Subject: [PATCH 70/70] Update to version v0.16.0 --- nvd3/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nvd3/__init__.py b/nvd3/__init__.py index 2c1eed1d..71823c58 100755 --- a/nvd3/__init__.py +++ b/nvd3/__init__.py @@ -9,7 +9,7 @@ Project location : https://github.com/areski/python-nvd3 """ -__version__ = '0.14.0' +__version__ = '0.16.0' __all__ = ['lineChart', 'pieChart', 'lineWithFocusChart', 'stackedAreaChart', 'multiBarHorizontalChart', 'linePlusBarChart', 'cumulativeLineChart', diff --git a/setup.py b/setup.py index 920fdbc9..27a2741e 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( name='python-nvd3', - version='0.14.0', + version='0.16.0', description="Python NVD3 - Chart Library for d3.js", long_description=readme + '\n\n' + history, keywords='plot, graph, nvd3, d3',