score:1
Accepted answer
since you are working on django, i would draw this graph with plotly.
in your views.py:
import plotly.offline as pyo
import plotly.graph_objs as go
import datetime as dt
import calendar
time_values = blog.objects.all().order_by("created_at")
time_values = [ element.created_at for element in time_values ]
time_values = [ element.month for element in time_values ]
published_amounts = [ 1 for element in time_values ]
new_time_values = [ time_values[0] ]
published_amounts = [ 0 ]
j=0
# the cycle prevents mixing months from different years
for i in range( 1, len(time_values) ):
if time_values[i]==time_values[i-1]:
published_amounts[j] = published_amounts[j] + 1
else:
new_time_values.append(time_values[i])
published_amounts.append(1)
j=j+1
new_time_values = [calendar.month_name[element] for element in new_time_values ]
post_line = go.scatter(
x=new_time_values,
y=published_amounts,
mode='lines+markers',
name="published posts",
)
data = [ post_line, ]
layout = go.layout(showlegend=true, )
fig = go.figure(data=data, layout=layout)
plt_div = pyo.plot(fig, output_type='div')
context_dict={
"plt_div":plt_div
}
return render(request, 'your_page.html', context_dict)
then in your template you simply have to put
{{plt_div}}
where you want your graph to be displayed.
Source: stackoverflow.com
Related Query
- How to create a line chart indicating which month a user wrote more or less blogs?
- How can I create a horizontal scrolling Chart.js line chart with a locked y axis?
- How to create a gradient fill line chart in latest Chart JS version (3.3.2)?
- How to change the chart line or area colors according to the user need?
- how can i use chart.js to create a chart that has one time series line and one linear line on it at the same time?
- How to plot a line chart which has both the start and points outside the canvas area using Chart.js
- How to create a line on a chart using chartjs-plugin-annotation
- How to bind data from Controler to chartjs line chart to create it as dynamic?
- Create a line chart using an user input table from a data table in chart.js
- how to create line chart using chart.js in angular 2+
- Chart.js - How to set a line chart dataset as disabled on load
- create a multi line chart using Chart.js
- How to add an on click event to my Line chart using Chart.js
- Chart.js how to show cursor pointer for labels & legends in line chart
- How to display Line Chart dataset point labels with Chart.js?
- How to create datasets dynamically for chart.js Line chart?
- How to add second Y-axis for Bar and Line chart in Chart.js?
- How to create stacked bar chart using react-chartjs-2?
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- How to display value of only one datapoint in line chart
- How to align Chart.JS line chart labels to the center
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How can I remove extra whitespace from the bottom of a line chart in chart.js?
- How can I create a time series line graph in chart.js?
- How to create single value Doughnut or Pie chart using Chart.js?
- how to create multiple chart on one component vue
- how to change Y axis value dynamically based on user input in Chartjs for Line chart?
- How to draw Horizontal line on Bar Chart Chartjs
- how to set chart.js grid color for line chart
- how to programmatically make a line chart point active/highlighted
More Query from same tag
- How to only draw the graph and the Xaxis gridlines using chart.js
- Could not find elementById on mat-card-content
- React + Chart.js 2.0: How to put a label inside of a doughnut chart?
- Why can I not see a data value when hovering over a point on the radar chart?
- Multiple bubble chart datasets for chartjs
- I want to add label on only specific vue chart
- ChartJS Doughnut Charts Gradient Fill
- Chart.js combine two pieces of data into one bar
- how can i use chart.js to create a chart that has one time series line and one linear line on it at the same time?
- How to target only X or Y value in jsonObj array
- Is it possible to add a click event in chart.js that directs you to a url?
- Chart JS Zoom Pan
- how to update chartjs2 option (scale.tick.max)
- Draw horizontal lines in Chart.js 2.0
- Add MQTT topics and data to chartjs
- Chart.js two columns on page - left column is squished until page resize
- is it possible to sum up the properties of an array of objects and to filter it according to another property?
- Age pyramid chart using chart.js
- Programmatically creating labels for Chart.js in angular?
- How to Remove Unnecessary Spaces around a semi-Doughnut Chart.js Chart
- Display two datasets from an array using chart.js in node.js
- How to set subscript text in Chart.js axis title
- Chart.js : straight lines instead of curves
- Programmatically change to another key in object
- charts.js: how to get the legend colors of the labels
- Chart.JS - Tooltips - Issue: 3 data points, all three individual tooltips showing for each data point
- Chart.js canvas y axis
- Using lodash to prepare data for "last day user registration" chart
- Reopening a "ChartJS" chart in a new window (VS, C#, ChartJS)
- Chart to update from a drop down selection