How To Implement Google CandlestickChart In MVC

Step1: Create New MVC Application.

Step2: Now Write Below code in your _Layout.cshtml page.

<!DOCTYPE html>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>

    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        google.charts.load('current', { 'packages': ['corechart'] });
        function CandlestickChart() {
            var data = google.visualization.arrayToDataTable([
                ['Jan', 20, 28, 38, 45],
                ['Feb', 31, 38, 55, 66],
                ['Mar', 50, 55, 77, 80],
                ['Apr', 77, 77, 66, 50],
                ['May', 68, 66, 22, 15]
                // Treat first row as data as well.
            ], true);
            var options = {
                legend: 'none'
            var chart = new google.visualization.CandlestickChart(document.getElementById('CandlesticChart_div'));
            chart.draw(data, options);
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
    <div class="container body-content">
        <hr />
            <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>

    @RenderSection("scripts", required: false)

Step3: write below code in your index.cshtml page

<div id="CandlesticChart_div" style="width: 900px; height: 500px;"></div>

Step4:  Now see the output.

Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories