Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:areski/python-nvd3

  • Loading branch information...
commit 701540a992816151f571cfb3e04a1c8411891a12 2 parents 44eca38 + dde234d
@areski authored
Showing with 34 additions and 1 deletion.
  1. +1 −0  CONTRIBUTORS
  2. +26 −0 examples/demo_all.py
  3. +7 −1 nvd3/NVD3Chart.py
View
1  CONTRIBUTORS
@@ -15,3 +15,4 @@ bevanj
frewie
agorrod
freeseacher (Aleksey Shirokih)
+miquelcamprodon
View
26 examples/demo_all.py
@@ -98,6 +98,32 @@
output_file.write(chart.htmlcontent)
#---------------------------------------
+type = "lineChartWithInteractiveGuideline"
+chart = lineChart(name="lineChartWithInteractiveGuideline",
+ height=350, x_is_date=True, x_axis_format="%d %b %Y %H",
+ jquery_on_ready=True,use_interactive_guideline=True)
+
+chart.set_containerheader("\n\n<h2>" + type + "</h2>\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)]
+ydata2 = [x * 2 for x in ydata]
+
+#Configure a color for a specific serie
+kwargs1 = {'color': 'green'}
+kwargs2 = {'color': 'red'}
+
+extra_serie = {"tooltip": {"y_start": "There is ", "y_end": " calls"},
+ "date_format": "%d %b %Y %I:%M:%S %p"}
+chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie, **kwargs1)
+extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}}
+chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie, **kwargs2)
+
+chart.buildcontent()
+
+output_file.write(chart.htmlcontent)
+#---------------------------------------
+
type = "lineWithFocusChart"
chart = lineWithFocusChart(color_category='category20b', x_is_date=True,
x_axis_format="%d %b %Y", jquery_on_ready=True)
View
8 nvd3/NVD3Chart.py
@@ -71,6 +71,7 @@ class NVD3Chart:
* ``stacked`` - False / True
* ``style`` - Special style
* ``template_page_nvd3`` - template variable
+ * ``use_interactive_guideline`` - False / True
* ``width`` - Set graph width
* ``x_axis_date`` - False / True
* ``show_legend`` - False / True
@@ -107,6 +108,7 @@ class NVD3Chart:
color_list = [] # for pie chart
tag_script_js = True
charttooltip_dateformat = None
+ use_interactive_guideline = False
x_axis_format = ''
show_legend = True
show_labels = True
@@ -139,6 +141,7 @@ def __init__(self, **kwargs):
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)
+ self.use_interactive_guideline = kwargs.get("use_interactive_guideline", False)
self.chart_attr = kwargs.get("chart_attr", {})
self.assets_directory = kwargs.get('assets_directory', './bower_components/')
@@ -389,7 +392,10 @@ def buildjschart(self):
self.jschart += 'nv.addGraph(function() {\n'
- self.jschart += stab(2) + 'var chart = nv.models.%s();\n' % self.model
+ self.jschart += stab(2) + 'var chart = nv.models.%s()' % self.model
+ if self.use_interactive_guideline:
+ self.jschart += '.useInteractiveGuideline(true)'
+ self.jschart += ';\n'
if self.model != 'pieChart' and not self.color_list:
if self.color_category:
Please sign in to comment.
Something went wrong with that request. Please try again.