<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alok bharti on Medium]]></title>
        <description><![CDATA[Stories by Alok bharti on Medium]]></description>
        <link>https://medium.com/@alok.lnjpitcs17?source=rss-100db5cd94fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XS7_DYrzpSu_VKg_</url>
            <title>Stories by Alok bharti on Medium</title>
            <link>https://medium.com/@alok.lnjpitcs17?source=rss-100db5cd94fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 14:12:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alok.lnjpitcs17/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Use Highcharts with Django.]]></title>
            <link>https://medium.com/@alok.lnjpitcs17/how-to-use-highcharts-with-django-82d9b837b614?source=rss-100db5cd94fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/82d9b837b614</guid>
            <category><![CDATA[django-framework]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django-rest-framework]]></category>
            <category><![CDATA[django-admin]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Alok bharti]]></dc:creator>
            <pubDate>Sun, 19 Sep 2021 10:30:58 GMT</pubDate>
            <atom:updated>2021-09-19T10:30:58.710Z</atom:updated>
            <content:encoded><![CDATA[<h4>Highcharts is a cool open-source JavaScript library that helps you render HTML charts. It is responsive and counts with 8 different chart types.</h4><p>In this tutorial, we are going to explore a little bit of how to make Django talk with Highcharts and render some simple charts based on data extracted from our models.</p><h3>Installation</h3><h4>&lt;script src=”https://code.highcharts.com/highcharts.js&quot;&gt;&lt;/script&gt;</h4><h4>&lt;script src=”https://code.highcharts.com/modules/exporting.js&quot;&gt;&lt;/script&gt;</h4><h4>&lt;script src=”https://code.highcharts.com/modules/export-data.js&quot;&gt;&lt;/script&gt;</h4><h4>&lt;script src=”https://code.highcharts.com/modules/accessibility.js&quot;&gt;&lt;/script&gt;</h4><p>We are going to use the two models below, Category and ItemList:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6052a49f846cd7c28a9358c24984f7e/href">https://medium.com/media/e6052a49f846cd7c28a9358c24984f7e/href</a></iframe><h3>2. Line and Bar Chart.</h3><p>For the first example, we are only going to retrieve the category-wise count and render it as a line and bar chart. In this strategy, we are going to return the chart data as part of the view context and inject the results in the JavaScript code using the Django template language.</p><p><strong>views.py</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1a21319744dd684ecc463e6c09b8546/href">https://medium.com/media/e1a21319744dd684ecc463e6c09b8546/href</a></iframe><h4>For the urls.py just a simple routing:</h4><h3>urls.py</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/718a6af85a01d04ae056ffded2094d66/href">https://medium.com/media/718a6af85a01d04ae056ffded2094d66/href</a></iframe><h3>Now the template.</h3><p>line_chart_page.html</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63726aaa45c59dc2ace87bbbcac30c98/href">https://medium.com/media/63726aaa45c59dc2ace87bbbcac30c98/href</a></iframe><h4>The code above looks like this:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5RZQy1xjFZFX_hj_UZeaGQ.png" /></figure><h3>Note:</h3><p><strong>If you want to create a Bar chart you just need to replace chart:{type: ‘bar’} in line_chart_page.html.</strong></p><h3>Conclusions</h3><p>I hope this tutorial helped you to get started with working with charts using Highcharts. I published another tutorial soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82d9b837b614" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use Highcharts with Django.]]></title>
            <link>https://medium.com/@alok.lnjpitcs17/how-to-use-highcharts-with-django-d300b70a0c11?source=rss-100db5cd94fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/d300b70a0c11</guid>
            <dc:creator><![CDATA[Alok bharti]]></dc:creator>
            <pubDate>Tue, 14 Sep 2021 12:45:00 GMT</pubDate>
            <atom:updated>2021-09-14T13:06:48.123Z</atom:updated>
            <content:encoded><![CDATA[<h4>Highcharts is a cool open-source JavaScript library that helps you render HTML charts. It is responsive and counts with 8 different chart types.</h4><p>In this tutorial, we are going to explore a little bit of how to make Django talk with Highcharts and render some simple charts based on data extracted from our models.</p><h3>Installation</h3><p>For this tutorial all you are going to do is add the Highcharts lib to your HTML page:</p><h4>&lt;script src=”https://code.highcharts.com/highcharts.js&quot;&gt;&lt;/script&gt;</h4><h4>&lt;script src=”https://code.highcharts.com/modules/exporting.js&quot;&gt;&lt;/script&gt;</h4><h4>&lt;script src=”https://code.highcharts.com/modules/export-data.js&quot;&gt;&lt;/script&gt;</h4><h4>&lt;script src=”https://code.highcharts.com/modules/accessibility.js&quot;&gt;&lt;/script&gt;</h4><p>We are going to use the two models below, Category and ItemList:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*zKoVeQe8gFg2vxjoc8kWDw.png" /></figure><h3>1. Pie Chart</h3><p>For the first example, we are only going to retrieve the category-wise count and render it as a pie chart. In this strategy, we are going to return the chart data as part of the view context and inject the results in the JavaScript code using the Django template language.</p><p><strong>views.py</strong></p><pre>import json<br>from django.db.models import Count<br>from django.shortcuts import render<br>from programming_app.models import ItemList<br><br><br>def category_pie_chart(request):<br>items = ItemList.objects.values(<br>&#39;category__name&#39;).annotate(tot=Count(&#39;id&#39;))</pre><pre>category_data_source = {<br>        &#39;name&#39;: &quot;Categories Data&quot;,<br>        &quot;data&quot;: []<br>    }<br>for key in items:<br>    data = {<br>       &#39;name&#39;: key[&#39;category__name&#39;],<br>        &#39;y&#39;: key[&#39;tot&#39;],<br>    }<br>    category_data_source[&#39;data&#39;].append(data)<br><br>category_chart_data = {<br>        &#39;chart&#39;: {&#39;type&#39;: &#39;pie&#39;},<br>        &#39;title&#39;: {&#39;text&#39;: &quot;Categories Wise Data&quot;},<br>        &#39;setOptions&#39;: {<br>            &#39;lang&#39;: {<br>                &#39;thousandsSep&#39;: &#39;,&#39;<br>            }<br>        },<br>        &#39;accessibility&#39;: {<br>            &#39;announceNewData&#39;: {<br>                &#39;enabled&#39;: True<br>            }<br>        },<br>        &#39;plotOptions&#39;: {<br>            &#39;series&#39;: {<br>                &#39;dataLabels&#39;: {<br>                    &#39;enabled&#39;: True,<br>                    &#39;format&#39;: &#39;{point.name}: &lt;br&gt;{point.percentage:.1f} %&lt;br&gt;total: {point.y}&#39;,<br>                    &#39;padding&#39;: 0,<br>                    &#39;style&#39;: {<br>                        &#39;fontSize&#39;: &#39;10px&#39;<br>                    }<br>                }<br>            }<br>        },<br>        &#39;tooltip&#39;: {<br>            &#39;headerFormat&#39;: &#39;&lt;span style=&quot;font-size:11px; color:#8e5ea2&quot;&gt;{series.name}&lt;br&gt;{point.percentage:.1f} %&#39;<br>                            &#39;&lt;/span&gt;&lt;br&gt;&#39;,<br>            &#39;pointFormat&#39;: &#39;&lt;span style=&quot;color:#3cba9f&quot;&gt;{point.name}&lt;/span&gt;: &lt;b&gt;{point.y}&lt;/b&gt;&lt;br/&gt;&#39;<br>                           <br>        },<br>        &#39;series&#39;: [category_data_source],<br>    }<br>    context = {<br>        &#39;category_wise_pie_data&#39;: json.dumps(category_chart_data)<br>    }<br>    return render(request, &#39;programming_app/pie_chart_page.html&#39;, context)</pre><h4>For the urls.py just a simple routing:</h4><h4>urls.py</h4><pre>from django.conf.urls import url<br>from django.contrib import admin<br><br>from programming_app import views<br><br>urlpatterns = [<br>    url(https://medium.com/r&#39;^admin/&#39;,%20admin.site.urls),<br>    url(https://medium.com/r&#39;^pie_chart_page/&#39;,%20views.category_pie_chart),<br>]</pre><h4>Now the template.</h4><p>pie_chart_page.html</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;Pie Chart Page&lt;/title&gt;<br>   &lt;script src=&quot;https://code.highcharts.com/highcharts.js&quot;&gt;&lt;/script&gt;<br>        &lt;script src=&quot;https://code.highcharts.com/modules/exporting.js&quot;&gt;&lt;/script&gt;<br>        &lt;script src=&quot;https://code.highcharts.com/modules/export-data.js&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;https://code.highcharts.com/modules/accessibility.js&quot;&gt;&lt;/script&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;div id=&quot;container_data&quot;&gt;&lt;/div&gt;<br>&lt;script&gt;<br>       Highcharts.chart(&#39;container_data&#39;,      {{category_wise_pie_data|safe }});<br>&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>The code above looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTC8gBQz7zBgo7i6TkbwXg.png" /></figure><h3>Conclusions</h3><p>I hope this tutorial helped you to get started with working with charts using Highcharts. I published another tutorial on the same subject soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d300b70a0c11" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>