<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tips &#8211; Sibeesh Passion</title>
	<atom:link href="https://www.sibeeshpassion.com/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Wed, 23 Dec 2015 12:51:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>Tips &#8211; Sibeesh Passion</title>
	<link>https://www.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Client Side Chart Widget in HTML 5: Part 8 (Pie Chart With Custom ToolTip)</title>
		<link>https://www.sibeeshpassion.com/client-side-chart-widget-in-html-5-part-8-pie-chart-with-custom-tooltip/</link>
					<comments>https://www.sibeeshpassion.com/client-side-chart-widget-in-html-5-part-8-pie-chart-with-custom-tooltip/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Thu, 29 Jan 2015 20:01:56 +0000</pubDate>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[HTML5 Chart]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Pie Chart]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=1271</guid>

					<description><![CDATA[In this article we will see how to create a pie chart in HTML5 with custom tool tip. I hope you have read my first two articles in this series that explains the loading of Bar Charts, Pie Charts, Line Charts, Doughnut Charts, Polar Area Charts, Radar Charts and Line Chart with custom tooltip. Please see the following links. Client-Side Chart Widget in HTML 5: Part 1 (Bar Chart) Client-Side Chart Widget in HTML 5: Part 2 (Pie Chart) Client-Side Chart Widget in HTML 5: Part 3 (Line Chart) Client-Side Chart Widget in HTML 5: Part 4 (Doughnut Chart) Client-Side [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this article we will see how to create a pie chart in <a href="http://sibeeshpassion.com/category/html5/" target="_blank">HTML5 </a> with custom tool tip. I hope you have read my first two articles in this series that explains the loading of Bar Charts, Pie Charts, Line Charts, Doughnut Charts, Polar Area Charts, Radar Charts and Line Chart with custom tooltip. Please see the following links.</p>
<p><a href="http://www.c-sharpcorner.com/uploadfile/65794e/client-side-chart-widget-in-html-5-part-1-bar-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 1 (Bar Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html-5-part-2-pie-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 2 (Pie Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html5-part-3-line-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 3 (Line Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html5-part-4-doughnut-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 4 (Doughnut Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html5-part-5-polar-area-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 5 (Polar Area Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html5-part-6-radar-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 6 (Radar Chart)</a><br />
<a href="http://sibeeshpassion.com/client-side-chart-widget-in-html-5-part-7-line-chart-with-custom-tooltip/" target="_blank">Client Side Chart Widget in HTML 5: Part 7 (Line Chart With Custom ToolTip)</a><br />
Now we will explain a client Pie Chart widget with custom tooltip in HTML5. </p>
<p><strong>Background</strong></p>
<p>Please download the necessary files here.</p>
<p>Using the code</p>
<p><strong>A simple HTML</strong></p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
   &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
      &lt;head&gt;<br />
         &lt;title&gt; Pie Chart widget with custom tooltip Using Chart.js&lt;/title&gt;<br />
      &lt;/head&gt;<br />
      &lt;body&gt;&lt;/body&gt;<br />
   &lt;/html&gt;<br />
[/html]</p>
<p><strong>Included JavaScript file</strong></p>
<p>[html]<br />
&lt;script src=&quot;Chart.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js&quot;&gt;&lt;/script&gt;<br />
[/html]   </p>
<p><strong>Include UI Elements</strong></p>
<p>[html]<br />
&lt;div id=&quot;canvas-holder&quot;&gt;<br />
    &lt;canvas id=&quot;chart-area1&quot; width=&quot;50&quot; height=&quot;50&quot; /&gt;<br />
&lt;/div&gt;<br />
&lt;div id=&quot;canvas-holder&quot;&gt;<br />
    &lt;canvas id=&quot;chart-area2&quot; width=&quot;300&quot; height=&quot;300&quot; /&gt;<br />
&lt;/div&gt;<br />
&lt;div id=&quot;chartjs-tooltip&quot;&gt;&lt;/div&gt;<br />
 [/html]</p>
<p><strong>Call the Chart Function</strong></p>
<p>[js]<br />
window.onload = function () {<br />
    var ctx1 = document.getElementById(&quot;chart-area1&quot;).getContext(&quot;2d&quot;);<br />
    window.myPie = new Chart(ctx1).Pie(pieData);  </p>
<p>    var ctx2 = document.getElementById(&quot;chart-area2&quot;).getContext(&quot;2d&quot;);<br />
    window.myPie = new Chart(ctx2).Pie(pieData);<br />
;<br />
[/js]</p>
<p>Here we are loading the chart in the chart-area1 and chart-area2. As you can see in the preceding code, pieData is the data we will load into the chart.</p>
<p>[js]<br />
var pieData = [{<br />
           value: 300,<br />
           color: &quot;#F7464A&quot;,<br />
           highlight: &quot;#FF5A5E&quot;,<br />
           label: &quot;Monday&quot;<br />
       }, {<br />
           value: 50,<br />
           color: &quot;#46BFBD&quot;,<br />
           highlight: &quot;#5AD3D1&quot;,<br />
           label: &quot;Tuesday&quot;<br />
       }, {<br />
           value: 100,<br />
           color: &quot;#FDB45C&quot;,<br />
           highlight: &quot;#FFC870&quot;,<br />
           label: &quot;Wednesday&quot;<br />
       }, {<br />
           value: 40,<br />
           color: &quot;#949FB1&quot;,<br />
           highlight: &quot;#A8B3C5&quot;,<br />
           label: &quot;Thursday&quot;<br />
       }, {<br />
           value: 120,<br />
           color: &quot;#4D5360&quot;,<br />
           highlight: &quot;#616774&quot;,<br />
           label: &quot;Friday&quot;<br />
       }];<br />
[/js]</p>
<p> <strong>Properties</strong></p>
<li>Value</li>
<li>Color</li>
<li>Highlight</li>
<li>Label</li>
<p>Here you can change the properties as you want. </p>
<p>Now add the following style.</p>
<p>[css]<br />
&lt;style&gt;<br />
        #canvas-holder {<br />
            width: 100%;<br />
            margin-top: 50px;<br />
            text-align: center;<br />
        }  </p>
<p>        #chartjs-tooltip {<br />
            opacity: 1;<br />
            position: absolute;<br />
            background: rgba(0, 0, 0, .7);<br />
            color: white;<br />
            padding: 3px;<br />
            border-radius: 3px;<br />
            -webkit-transition: all .1s ease;<br />
            transition: all .1s ease;<br />
            pointer-events: none;<br />
            -webkit-transform: translate(-50%, 0);<br />
            transform: translate(-50%, 0);<br />
        }  </p>
<p>            #chartjs-tooltip.below {<br />
                -webkit-transform: translate(-50%, 0);<br />
                transform: translate(-50%, 0);<br />
            }  </p>
<p>                #chartjs-tooltip.below:before {<br />
                    border: solid;<br />
                    border-color: #111 transparent;<br />
                    border-color: rgba(0, 0, 0, .8) transparent;<br />
                    border-width: 0 8px 8px 8px;<br />
                    bottom: 1em;<br />
                    content: &quot;&quot;;<br />
                    display: block;<br />
                    left: 50%;<br />
                    position: absolute;<br />
                    z-index: 99;<br />
                    -webkit-transform: translate(-50%, -100%);<br />
                    transform: translate(-50%, -100%);<br />
                }  </p>
<p>            #chartjs-tooltip.above {<br />
                -webkit-transform: translate(-50%, -100%);<br />
                transform: translate(-50%, -100%);<br />
            }  </p>
<p>                #chartjs-tooltip.above:before {<br />
                    border: solid;<br />
                    border-color: #111 transparent;<br />
                    border-color: rgba(0, 0, 0, .8) transparent;<br />
                    border-width: 8px 8px 0 8px;<br />
                    bottom: 1em;<br />
                    content: &quot;&quot;;<br />
                    display: block;<br />
                    left: 50%;<br />
                    top: 100%;<br />
                    position: absolute;<br />
                    z-index: 99;<br />
                    -webkit-transform: translate(-50%, 0);<br />
                    transform: translate(-50%, 0);<br />
                }<br />
&lt;/style&gt;<br />
[/css]</p>
<p><strong>Load the tool tip</strong></p>
<p>You can include the tool tip as follows.</p>
<p>[js]<br />
Chart.defaults.global.customTooltips = function (tooltip) {  </p>
<p>            // Tooltip Element<br />
            var tooltipEl = $(&#8216;#chartjs-tooltip&#8217;);  </p>
<p>            // Hide if no tooltip<br />
            if (!tooltip) {<br />
                tooltipEl.css({<br />
                    opacity: 0<br />
                });<br />
                return;<br />
            }  </p>
<p>            // Set caret Position<br />
            tooltipEl.removeClass(&#8216;above below&#8217;);<br />
            tooltipEl.addClass(tooltip.yAlign);  </p>
<p>            // Set Text<br />
            tooltipEl.html(tooltip.text);  </p>
<p>            // Find Y Location on page<br />
            var top;<br />
            if (tooltip.yAlign == &#8216;above&#8217;) {<br />
                top = tooltip.y &#8211; tooltip.caretHeight &#8211; tooltip.caretPadding;<br />
            } else {<br />
                top = tooltip.y + tooltip.caretHeight + tooltip.caretPadding;<br />
            }  </p>
<p>            // Display, position, and set styles for font<br />
            tooltipEl.css({<br />
                opacity: 1,<br />
                left: tooltip.chart.canvas.offsetLeft + tooltip.x + &#8216;px&#8217;,<br />
                top: tooltip.chart.canvas.offsetTop + top + &#8216;px&#8217;,<br />
                fontFamily: tooltip.fontFamily,<br />
                fontSize: tooltip.fontSize,<br />
                fontStyle: tooltip.fontStyle,<br />
            });<br />
        };<br />
[/js]</p>
<p>Please note that you can change your tooltip as needed.</p>
<p><strong>Complete Code</strong></p>
<p>[html]<br />
&lt;!doctype html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Pie Chart with Custom Tooltips&lt;/title&gt;<br />
    &lt;script src=&quot;Chart.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;style&gt;<br />
        #canvas-holder {<br />
            width: 100%;<br />
            margin-top: 50px;<br />
            text-align: center;<br />
        }  </p>
<p>        #chartjs-tooltip {<br />
            opacity: 1;<br />
            position: absolute;<br />
            background: rgba(0, 0, 0, .7);<br />
            color: white;<br />
            padding: 3px;<br />
            border-radius: 3px;<br />
            -webkit-transition: all .1s ease;<br />
            transition: all .1s ease;<br />
            pointer-events: none;<br />
            -webkit-transform: translate(-50%, 0);<br />
            transform: translate(-50%, 0);<br />
        }  </p>
<p>            #chartjs-tooltip.below {<br />
                -webkit-transform: translate(-50%, 0);<br />
                transform: translate(-50%, 0);<br />
            }  </p>
<p>                #chartjs-tooltip.below:before {<br />
                    border: solid;<br />
                    border-color: #111 transparent;<br />
                    border-color: rgba(0, 0, 0, .8) transparent;<br />
                    border-width: 0 8px 8px 8px;<br />
                    bottom: 1em;<br />
                    content: &quot;&quot;;<br />
                    display: block;<br />
                    left: 50%;<br />
                    position: absolute;<br />
                    z-index: 99;<br />
                    -webkit-transform: translate(-50%, -100%);<br />
                    transform: translate(-50%, -100%);<br />
                }  </p>
<p>            #chartjs-tooltip.above {<br />
                -webkit-transform: translate(-50%, -100%);<br />
                transform: translate(-50%, -100%);<br />
            }  </p>
<p>                #chartjs-tooltip.above:before {<br />
                    border: solid;<br />
                    border-color: #111 transparent;<br />
                    border-color: rgba(0, 0, 0, .8) transparent;<br />
                    border-width: 8px 8px 0 8px;<br />
                    bottom: 1em;<br />
                    content: &quot;&quot;;<br />
                    display: block;<br />
                    left: 50%;<br />
                    top: 100%;<br />
                    position: absolute;<br />
                    z-index: 99;<br />
                    -webkit-transform: translate(-50%, 0);<br />
                    transform: translate(-50%, 0);<br />
                }<br />
    &lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    Pie Chart With Custom Tooltip @ &lt;a href=&quot;www.sibeeshpassion.com&quot;&gt;www.sibeeshpassion.com&lt;/a&gt;<br />
    &lt;div id=&quot;canvas-holder&quot;&gt;<br />
        &lt;canvas id=&quot;chart-area1&quot; width=&quot;50&quot; height=&quot;50&quot; /&gt;<br />
    &lt;/div&gt;<br />
    &lt;div id=&quot;canvas-holder&quot;&gt;<br />
        &lt;canvas id=&quot;chart-area2&quot; width=&quot;300&quot; height=&quot;300&quot; /&gt;<br />
    &lt;/div&gt;<br />
    &lt;div id=&quot;chartjs-tooltip&quot;&gt;&lt;/div&gt;  </p>
<p>    &lt;script&gt;<br />
        Chart.defaults.global.customTooltips = function (tooltip) {  </p>
<p>            // Tooltip Element<br />
            var tooltipEl = $(&#8216;#chartjs-tooltip&#8217;);  </p>
<p>            // Hide if no tooltip<br />
            if (!tooltip) {<br />
                tooltipEl.css({<br />
                    opacity: 0<br />
                });<br />
                return;<br />
            }  </p>
<p>            // Set caret Position<br />
            tooltipEl.removeClass(&#8216;above below&#8217;);<br />
            tooltipEl.addClass(tooltip.yAlign);  </p>
<p>            // Set Text<br />
            tooltipEl.html(tooltip.text);  </p>
<p>            // Find Y Location on page<br />
            var top;<br />
            if (tooltip.yAlign == &#8216;above&#8217;) {<br />
                top = tooltip.y &#8211; tooltip.caretHeight &#8211; tooltip.caretPadding;<br />
            } else {<br />
                top = tooltip.y + tooltip.caretHeight + tooltip.caretPadding;<br />
            }  </p>
<p>            // Display, position, and set styles for font<br />
            tooltipEl.css({<br />
                opacity: 1,<br />
                left: tooltip.chart.canvas.offsetLeft + tooltip.x + &#8216;px&#8217;,<br />
                top: tooltip.chart.canvas.offsetTop + top + &#8216;px&#8217;,<br />
                fontFamily: tooltip.fontFamily,<br />
                fontSize: tooltip.fontSize,<br />
                fontStyle: tooltip.fontStyle,<br />
            });<br />
        };  </p>
<p>        var pieData = [{<br />
            value: 300,<br />
            color: &quot;#F7464A&quot;,<br />
            highlight: &quot;#FF5A5E&quot;,<br />
            label: &quot;Monday&quot;<br />
        }, {<br />
            value: 50,<br />
            color: &quot;#46BFBD&quot;,<br />
            highlight: &quot;#5AD3D1&quot;,<br />
            label: &quot;Tuesday&quot;<br />
        }, {<br />
            value: 100,<br />
            color: &quot;#FDB45C&quot;,<br />
            highlight: &quot;#FFC870&quot;,<br />
            label: &quot;Wednesday&quot;<br />
        }, {<br />
            value: 40,<br />
            color: &quot;#949FB1&quot;,<br />
            highlight: &quot;#A8B3C5&quot;,<br />
            label: &quot;Thursday&quot;<br />
        }, {<br />
            value: 120,<br />
            color: &quot;#4D5360&quot;,<br />
            highlight: &quot;#616774&quot;,<br />
            label: &quot;Friday&quot;<br />
        }];  </p>
<p>        window.onload = function () {<br />
            var ctx1 = document.getElementById(&quot;chart-area1&quot;).getContext(&quot;2d&quot;);<br />
            window.myPie = new Chart(ctx1).Pie(pieData);  </p>
<p>            var ctx2 = document.getElementById(&quot;chart-area2&quot;).getContext(&quot;2d&quot;);<br />
            window.myPie = new Chart(ctx2).Pie(pieData);<br />
        };<br />
    &lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Output</strong></p>
<div id="attachment_11050" style="width: 274px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/01/Pie-Chart-In-HTML5.jpg"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-11050" src="http://sibeeshpassion.com/wp-content/uploads/2015/01/Pie-Chart-In-HTML5.jpg" alt="Pie Chart In HTML5" width="264" height="345" class="size-full wp-image-11050" srcset="/wp-content/uploads/2015/01/Pie-Chart-In-HTML5.jpg 264w, /wp-content/uploads/2015/01/Pie-Chart-In-HTML5-230x300.jpg 230w" sizes="(max-width: 264px) 100vw, 264px" /></a><p id="caption-attachment-11050" class="wp-caption-text">Pie Chart In HTML5</p></div>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/client-side-chart-widget-in-html-5-part-8-pie-chart-with-custom-tooltip/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Client Side Chart Widget in HTML 5: Part 7 (Line Chart With Custom ToolTip)</title>
		<link>https://www.sibeeshpassion.com/client-side-chart-widget-in-html-5-part-7-line-chart-with-custom-tooltip/</link>
					<comments>https://www.sibeeshpassion.com/client-side-chart-widget-in-html-5-part-7-line-chart-with-custom-tooltip/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Thu, 29 Jan 2015 19:59:18 +0000</pubDate>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[HTML5 Chart]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Line Chart]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=1211</guid>

					<description><![CDATA[In this article we will see how to create a line chart in HTML5 with custom tool tip. We all works in charts right?. Charts are the most effective form of data representation. Here we will see a client side line chart. I hope you have read my first two articles in this series that explains the loading of Bar Charts, Pie Charts, Line Charts, Doughnut Charts, Polar Area Charts and Radar Charts. Please see the following links. Client-Side Chart Widget in HTML 5: Part 1 (Bar Chart) Client-Side Chart Widget in HTML 5: Part 2 (Pie Chart) Client-Side Chart [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this article we will see how to create a line chart in <a href="http://sibeeshpassion.com/category/html5/" target="_blank">HTML5 </a> with custom tool tip. We all works in charts right?. Charts are the most effective form of data representation. Here we will see a client side line chart. I hope you have read my first two articles in this series that explains the loading of Bar Charts, Pie Charts, Line Charts, Doughnut Charts, Polar Area Charts and Radar Charts. Please see the following links.</p>
<p><a href="http://www.c-sharpcorner.com/uploadfile/65794e/client-side-chart-widget-in-html-5-part-1-bar-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 1 (Bar Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html-5-part-2-pie-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 2 (Pie Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html5-part-3-line-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 3 (Line Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html5-part-4-doughnut-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 4 (Doughnut Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html5-part-5-polar-area-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 5 (Polar Area Chart)</a><br />
<a href="http://www.c-sharpcorner.com/UploadFile/65794e/client-side-chart-widget-in-html5-part-6-radar-chart/" target="_blank">Client-Side Chart Widget in HTML 5: Part 6 (Radar Chart)</a></p>
<p>Now we will explain a client Line Chart widget with custom tooltip in HTML5. </p>
<p><strong>Background</strong></p>
<p>Please download the necessary files <a href="http://www.chartjs.org/" target="_blank">here</a>.</p>
<p><strong>Using the code</strong></p>
<p><strong>A simple HTML</strong><br />
[html]<br />
&lt;!DOCTYPE html&gt;<br />
   &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
      &lt;head&gt;<br />
         &lt;title&gt; Line Chart widget with custom tooltip Using Chart.js&lt;/title&gt;<br />
      &lt;/head&gt;<br />
      &lt;body&gt;&lt;/body&gt;<br />
   &lt;/html&gt;<br />
[/html]</p>
<p><strong>Included JavaScript file</strong></p>
<p>[html]<br />
&lt;script src=&quot;Chart.js&quot;&gt;&lt;/script&gt;<br />
&lt;script src=&quot;http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js&quot;&gt;&lt;/script&gt;<br />
[/html]</p>
<p><strong>Call the Chart Function</strong><br />
[js]<br />
window.onload = function () {<br />
   var ctx1 = document.getElementById(&quot;myChart&quot;).getContext(&quot;2d&quot;);<br />
   window.myLine = new Chart(ctx1).Line(lineChartData, {<br />
      showScale: false,<br />
      pointDot: true,<br />
      responsive: true<br />
   });<br />
};<br />
[/js]</p>
<p>Here we are loading the chart in the myChart. As you can see in the preceding code, lineChartData is the data we will load into the chart.<br />
[js]<br />
var lineChartData = {<br />
    labels: [&quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;, &quot;Sunday&quot;],<br />
    datasets: [{<br />
        label: &quot;My First dataset&quot;,<br />
        fillColor: &quot;rgba(220,220,220,0.2)&quot;,<br />
        strokeColor: &quot;rgba(220,220,220,1)&quot;,<br />
        pointColor: &quot;rgba(220,220,220,1)&quot;,<br />
        pointStrokeColor: &quot;#fff&quot;,<br />
        pointHighlightFill: &quot;#fff&quot;,<br />
        pointHighlightStroke: &quot;rgba(220,220,220,1)&quot;,<br />
        data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]<br />
    }, {<br />
        label: &quot;My Second dataset&quot;,<br />
        fillColor: &quot;rgba(151,187,205,0.2)&quot;,<br />
        strokeColor: &quot;rgba(151,187,205,1)&quot;,<br />
        pointColor: &quot;rgba(151,187,205,1)&quot;,<br />
        pointStrokeColor: &quot;#fff&quot;,<br />
        pointHighlightFill: &quot;#fff&quot;,<br />
        pointHighlightStroke: &quot;rgba(151,187,205,1)&quot;,<br />
        data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]<br />
    }]<br />
       };<br />
[/js]</p>
<p><strong>Properties  </strong></p>
<li>Labels</li>
<li>Datasets</li>
<li>label ( label for your dataset)</li>
<li>fillColor</li>
<li>strokeColor</li>
<li>pointColor</li>
<li>pointStrokeColor</li>
<li>pointHighlightFill</li>
<li>pointHighlightStroke</li>
<li>data</li>
<p>Here you can change the properties as you want. Now add the following style for our tooltip:<br />
[css]<br />
&lt;style&gt;<br />
    #chartjs-tooltip {<br />
        opacity: 1;<br />
        position: absolute;<br />
        background: rgba(0, 0, 0, .7);<br />
        color: white;<br />
        padding: 3px;<br />
        border-radius: 3px;<br />
        -webkit-transition: all .1s ease;<br />
        transition: all .1s ease;<br />
        pointer-events: none;<br />
        -webkit-transform: translate(-50%, 0);<br />
        transform: translate(-50%, 0);<br />
    }  </p>
<p>    .chartjs-tooltip-key {<br />
        display: inline-block;<br />
        width: 10px;<br />
        height: 10px;<br />
    }<br />
&lt;/style&gt;<br />
[/css]</p>
<p><strong>Load the tooltip</strong></p>
<p>You can include the tooltip as follows.<br />
[js]<br />
Chart.defaults.global.pointHitDetectionRadius = 1;<br />
Chart.defaults.global.customTooltips = function (tooltip) {<br />
    var tooltipEl = $(&#8216;#chartjs-tooltip&#8217;);  </p>
<p>    if (!tooltip) {<br />
        tooltipEl.css({<br />
            opacity: 0<br />
        });<br />
        return;<br />
    }  </p>
<p>    tooltipEl.removeClass(&#8216;above below&#8217;);<br />
    tooltipEl.addClass(tooltip.yAlign);  </p>
<p>    var innerHtml = &#8221;;<br />
    for (var i = tooltip.labels.length &#8211; 1; i &gt;= 0; i&#8211;) {<br />
        innerHtml += [<br />
            &#8216;&lt;div class=&quot;chartjs-tooltip-section&quot;&gt;&#8217;,<br />
            &#8216;   &lt;span class=&quot;chartjs-tooltip-key&quot; style=&quot;background-color:&#8217; + tooltip.legendColors[i].fill + &#8216;&quot;&gt;&lt;/span&gt;&#8217;,<br />
            &#8216;   &lt;span class=&quot;chartjs-tooltip-value&quot;&gt;&#8217; + &#8216;My Custom Tooltip : &#8216;+ tooltip.labels[i] + &#8216;&lt;/span&gt;&#8217;,<br />
            &#8216;&lt;/div&gt;&#8217;<br />
        ].join(&#8221;);<br />
    }<br />
    tooltipEl.html(innerHtml);  </p>
<p>    tooltipEl.css({<br />
        opacity: 1,<br />
        left: tooltip.chart.canvas.offsetLeft + tooltip.x + &#8216;px&#8217;,<br />
        top: tooltip.chart.canvas.offsetTop + tooltip.y + &#8216;px&#8217;,<br />
        fontFamily: tooltip.fontFamily,<br />
        fontSize: tooltip.fontSize,<br />
        fontStyle: tooltip.fontStyle,<br />
    });<br />
};<br />
[/js]</p>
<p>Please note that you can change your tooltip as needed.</p>
<p><strong>Complete Code</strong><br />
[html]<br />
&lt;!doctype html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;Line Chart with Custom Tooltips&lt;/title&gt;<br />
    &lt;script src=&quot;Chart.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;style&gt;<br />
        #canvas-holder1 {<br />
            width: 300px;<br />
            margin: 20px auto;<br />
        }  </p>
<p>        #chartjs-tooltip {<br />
            opacity: 1;<br />
            position: absolute;<br />
            background: rgba(0, 0, 0, .7);<br />
            color: white;<br />
            padding: 3px;<br />
            border-radius: 3px;<br />
            -webkit-transition: all .1s ease;<br />
            transition: all .1s ease;<br />
            pointer-events: none;<br />
            -webkit-transform: translate(-50%, 0);<br />
            transform: translate(-50%, 0);<br />
        }  </p>
<p>        .chartjs-tooltip-key {<br />
            display: inline-block;<br />
            width: 10px;<br />
            height: 10px;<br />
        }<br />
    &lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;div&gt;<br />
        Line Chart With Custom Tooltip @ &lt;a href=&quot;www.sibeeshpassion.com&quot;&gt;www.sibeeshpassion.com&lt;/a&gt;<br />
        &lt;canvas id=&quot;myChart&quot;&gt;&lt;/canvas&gt;<br />
    &lt;/div&gt;<br />
    &lt;div id=&quot;chartjs-tooltip&quot;&gt;&lt;/div&gt;  </p>
<p>    &lt;script&gt;  </p>
<p>        Chart.defaults.global.pointHitDetectionRadius = 1;<br />
        Chart.defaults.global.customTooltips = function (tooltip) {  </p>
<p>            var tooltipEl = $(&#8216;#chartjs-tooltip&#8217;);  </p>
<p>            if (!tooltip) {<br />
                tooltipEl.css({<br />
                    opacity: 0<br />
                });<br />
                return;<br />
            }  </p>
<p>            tooltipEl.removeClass(&#8216;above below&#8217;);<br />
            tooltipEl.addClass(tooltip.yAlign);  </p>
<p>            var innerHtml = &#8221;;<br />
            for (var i = tooltip.labels.length &#8211; 1; i &gt;= 0; i&#8211;) {<br />
                innerHtml += [<br />
                    &#8216;&lt;div class=&quot;chartjs-tooltip-section&quot;&gt;&#8217;,<br />
                    &#8216;   &lt;span class=&quot;chartjs-tooltip-key&quot; style=&quot;background-color:&#8217; + tooltip.legendColors[i].fill + &#8216;&quot;&gt;&lt;/span&gt;&#8217;,<br />
                    &#8216;   &lt;span class=&quot;chartjs-tooltip-value&quot;&gt;&#8217; + &#8216;My Custom Tooltip : &#8216;+ tooltip.labels[i] + &#8216;&lt;/span&gt;&#8217;,<br />
                    &#8216;&lt;/div&gt;&#8217;<br />
                ].join(&#8221;);<br />
            }<br />
            tooltipEl.html(innerHtml);  </p>
<p>            tooltipEl.css({<br />
                opacity: 1,<br />
                left: tooltip.chart.canvas.offsetLeft + tooltip.x + &#8216;px&#8217;,<br />
                top: tooltip.chart.canvas.offsetTop + tooltip.y + &#8216;px&#8217;,<br />
                fontFamily: tooltip.fontFamily,<br />
                fontSize: tooltip.fontSize,<br />
                fontStyle: tooltip.fontStyle,<br />
            });<br />
        };<br />
        var randomScalingFactor = function () {<br />
            return Math.round(Math.random() * 100);<br />
        };<br />
        var lineChartData = {<br />
            labels: [&quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;, &quot;Sunday&quot;],<br />
            datasets: [{<br />
                label: &quot;My First dataset&quot;,<br />
                fillColor: &quot;rgba(220,220,220,0.2)&quot;,<br />
                strokeColor: &quot;rgba(220,220,220,1)&quot;,<br />
                pointColor: &quot;rgba(220,220,220,1)&quot;,<br />
                pointStrokeColor: &quot;#fff&quot;,<br />
                pointHighlightFill: &quot;#fff&quot;,<br />
                pointHighlightStroke: &quot;rgba(220,220,220,1)&quot;,<br />
                data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]<br />
            }, {<br />
                label: &quot;My Second dataset&quot;,<br />
                fillColor: &quot;rgba(151,187,205,0.2)&quot;,<br />
                strokeColor: &quot;rgba(151,187,205,1)&quot;,<br />
                pointColor: &quot;rgba(151,187,205,1)&quot;,<br />
                pointStrokeColor: &quot;#fff&quot;,<br />
                pointHighlightFill: &quot;#fff&quot;,<br />
                pointHighlightStroke: &quot;rgba(151,187,205,1)&quot;,<br />
                data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]<br />
            }]<br />
        };  </p>
<p>        window.onload = function () {<br />
            var ctx1 = document.getElementById(&quot;myChart&quot;).getContext(&quot;2d&quot;);<br />
            window.myLine = new Chart(ctx1).Line(lineChartData, {<br />
                showScale: false,<br />
                pointDot: true,<br />
                responsive: true<br />
            });<br />
        };<br />
    &lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
[/html]</p>
<p><strong>Output</strong></p>
<div id="attachment_11048" style="width: 634px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2015/01/Line-Chart.jpg"><img decoding="async" aria-describedby="caption-attachment-11048" src="http://sibeeshpassion.com/wp-content/uploads/2015/01/Line-Chart.jpg" alt="Line Chart With Custom Tool Tip" width="624" height="323" class="size-full wp-image-11048" srcset="/wp-content/uploads/2015/01/Line-Chart.jpg 624w, /wp-content/uploads/2015/01/Line-Chart-300x155.jpg 300w, /wp-content/uploads/2015/01/Line-Chart-400x207.jpg 400w" sizes="(max-width: 624px) 100vw, 624px" /></a><p id="caption-attachment-11048" class="wp-caption-text">Line Chart With Custom Tool Tip</p></div>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/client-side-chart-widget-in-html-5-part-7-line-chart-with-custom-tooltip/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
