بهار آموزش با تخفیف های شگفت انگیز توسینسو بهار آموزش با تخفیف های شگفت انگیز توسینسو
مانده تا پایان تخفیف
مشاهده دوره ها
0

عدم نمایش چارت در modal در asp.net mvc

سلام دوستان عزیزم خسته نباشید ، می خوام یک چارت رو داخل modal رسم کنم ولی یک مشکل وجود داره وقتی برنامه رو اجرا میکنم چیزی نمایش داده نمیشه! ولی وقتی debugger میزارم و بر نامه رو اجرا میکنم چارت به درستی نمایش داده میشه! نمی دونم مشکل چیه. چه فرقی بین حالت که برنامه رو اجرا میکنیم و حالتی که debugger میزاریم و trace میکنیم هست؟!مگه سورس هر دو یکسان نیست؟ اینم سورس برنامه :


@{
    ViewBag.Title = "LoginC";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>LoginC</h2>
<!-- Draw-Chart -->
<div class="modal fade" id="Draw-Chart" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog ">
        <div class="box box-info modal-content">
            <div class="box-header" style="background: rgb(162,217,231);">
                <div class="box-tools pull-left">
                    <button class="btn btn-default btn-sm BtnClose" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button>
                </div>
                <h3 class="box-title TittleModalBox" style="max-width: 500px;text-overflow: ellipsis;white-space: nowrap;">نمودار میله ای</h3>
            </div>
            <form role="form" method="post" action="" novalidate="novalidate">
                <input type="hidden" value="0" name="Id" />
                <div class="box-body clearfix">
                    <div class="message"></div>


                    <!-- Main content -->
                    <section class="content">
                        <div class="row">
                            <div class="col-md-6">
                                <!-- AREA CHART -->
                                <div class="box box-primary">
                                    <div class="box-header with-border">
                                        <h3 class="box-title">Area Chart</h3>
                                        <div class="box-tools pull-left">
                                            <button type="button" class="btn btn-box-tool" data-widget="collapse">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                                        </div>
                                    </div>
                                    <div class="box-body">
                                        <div class="chart">
                                            <canvas id="areaChart" style="height:250px"></canvas>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                                <!-- DONUT CHART -->
                                <div class="box box-danger">
                                    <div class="box-header with-border">
                                        <h3 class="box-title">Donut Chart</h3>
                                        <div class="box-tools pull-left">
                                            <button type="button" class="btn btn-box-tool" data-widget="collapse">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                                        </div>
                                    </div>
                                    <div class="box-body">
                                        <canvas id="pieChart" style="height:250px"></canvas>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                            </div>
                            <!-- /.col (LEFT) -->
                            <div class="col-md-6">
                                <!-- LINE CHART -->
                                <div class="box box-info">
                                    <div class="box-header with-border">
                                        <h3 class="box-title">Line Chart</h3>
                                        <div class="box-tools pull-left">
                                            <button type="button" class="btn btn-box-tool" data-widget="collapse">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                                        </div>
                                    </div>
                                    <div class="box-body">
                                        <div class="chart">
                                            <canvas id="lineChart" style="height:250px"></canvas>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                                <!-- BAR CHART -->
                                <div class="box box-success">
                                    <div class="box-header with-border">
                                        <h3 class="box-title">Bar Chart</h3>
                                        <div class="box-tools pull-left">
                                            <button type="button" class="btn btn-box-tool" data-widget="collapse">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                                        </div>
                                    </div>
                                    <div class="box-body">
                                        <div class="chart">
                                            <canvas id="barChart" style="height:230px"></canvas>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                            </div>
                            <!-- /.col (RIGHT) -->
                        </div>
                        <!-- /.row -->
                    </section>
                    <!-- /.content -->


                    
                    
                </div>
                @*<div class="box-footer clearfix">
                    <button type="submit" class="btn btn-success accept pull-left" id="load" data-loading-text="لطفا منتظر بمانید ...<i class='fa fa-spinner fa-spin '></i> ">
                       ورود
				 <i class="fa " aria-hidden="true"></i>

				</button>

                </div>*@
            </form>
            <div class="overlay" style="display: none"></div>
            <div class="loading-img" style="display: none"></div>
        </div>
    </div>
</div>
@section Head{
<script src="/public/plugins/chartjs/Chart.min.js"></script>
<script type="text/javascript">
    $(function () {
        debugger
        $("#Draw-Chart").modal('show');
        /* ChartJS
 * -------
 * Here we will create a few charts using ChartJS
 */

        //--------------
        //- AREA CHART -
        //--------------

        // Get context with jQuery - using jQuery's .get() method.
        var areaChartCanvas = $("#areaChart").get(0).getContext("2d");
        // This will get the first returned node in the jQuery collection.
        var areaChart = new Chart(areaChartCanvas);

        var areaChartData = {
            labels: ["January", "February", "March", "April", "May", "June", "July"],
            datasets: [
              {
                  label: "Electronics",
                  fillColor: "rgba(210, 214, 222, 1)",
                  strokeColor: "rgba(210, 214, 222, 1)",
                  pointColor: "rgba(210, 214, 222, 1)",
                  pointStrokeColor: "#c1c7d1",
                  pointHighlightFill: "#fff",
                  pointHighlightStroke: "rgba(220,220,220,1)",
                  data: [65, 59, 80, 81, 56, 55, 40]
              },
              {
                  label: "Digital Goods",
                  fillColor: "rgba(60,141,188,0.9)",
                  strokeColor: "rgba(60,141,188,0.8)",
                  pointColor: "#3b8bba",
                  pointStrokeColor: "rgba(60,141,188,1)",
                  pointHighlightFill: "#fff",
                  pointHighlightStroke: "rgba(60,141,188,1)",
                  data: [28, 48, 40, 19, 86, 27, 90]
              }
            ]
        };

        var areaChartOptions = {
            //Boolean - If we should show the scale at all
            showScale: true,
            //Boolean - Whether grid lines are shown across the chart
            scaleShowGridLines: false,
            //String - Colour of the grid lines
            scaleGridLineColor: "rgba(0,0,0,.05)",
            //Number - Width of the grid lines
            scaleGridLineWidth: 1,
            //Boolean - Whether to show horizontal lines (except X axis)
            scaleShowHorizontalLines: true,
            //Boolean - Whether to show vertical lines (except Y axis)
            scaleShowVerticalLines: true,
            //Boolean - Whether the line is curved between points
            bezierCurve: true,
            //Number - Tension of the bezier curve between points
            bezierCurveTension: 0.3,
            //Boolean - Whether to show a dot for each point
            pointDot: false,
            //Number - Radius of each point dot in pixels
            pointDotRadius: 4,
            //Number - Pixel width of point dot stroke
            pointDotStrokeWidth: 1,
            //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
            pointHitDetectionRadius: 20,
            //Boolean - Whether to show a stroke for datasets
            datasetStroke: true,
            //Number - Pixel width of dataset stroke
            datasetStrokeWidth: 2,
            //Boolean - Whether to fill the dataset with a color
            datasetFill: true,
            //String - A legend template
            legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>",
            //Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
            maintainAspectRatio: true,
            //Boolean - whether to make the chart responsive to window resizing
            responsive: true
        };

        //Create the line chart
        areaChart.Line(areaChartData, areaChartOptions);

        //-------------
        //- LINE CHART -
        //--------------
        var lineChartCanvas = $("#lineChart").get(0).getContext("2d");
        var lineChart = new Chart(lineChartCanvas);
        var lineChartOptions = areaChartOptions;
        lineChartOptions.datasetFill = false;
        lineChart.Line(areaChartData, lineChartOptions);

        //-------------
        //- PIE CHART -
        //-------------
        // Get context with jQuery - using jQuery's .get() method.
        var pieChartCanvas = $("#pieChart").get(0).getContext("2d");
        var pieChart = new Chart(pieChartCanvas);
        var PieData = [
          {
              value: 700,
              color: "#f56954",
              highlight: "#f56954",
              label: "Chrome"
          },
          {
              value: 500,
              color: "#00a65a",
              highlight: "#00a65a",
              label: "IE"
          },
          {
              value: 400,
              color: "#f39c12",
              highlight: "#f39c12",
              label: "FireFox"
          },
          {
              value: 600,
              color: "#00c0ef",
              highlight: "#00c0ef",
              label: "Safari"
          },
          {
              value: 300,
              color: "#3c8dbc",
              highlight: "#3c8dbc",
              label: "Opera"
          },
          {
              value: 100,
              color: "#d2d6de",
              highlight: "#d2d6de",
              label: "Navigator"
          }
        ];
        var pieOptions = {
            //Boolean - Whether we should show a stroke on each segment
            segmentShowStroke: true,
            //String - The colour of each segment stroke
            segmentStrokeColor: "#fff",
            //Number - The width of each segment stroke
            segmentStrokeWidth: 2,
            //Number - The percentage of the chart that we cut out of the middle
            percentageInnerCutout: 50, // This is 0 for Pie charts
            //Number - Amount of animation steps
            animationSteps: 100,
            //String - Animation easing effect
            animationEasing: "easeOutBounce",
            //Boolean - Whether we animate the rotation of the Doughnut
            animateRotate: true,
            //Boolean - Whether we animate scaling the Doughnut from the centre
            animateScale: false,
            //Boolean - whether to make the chart responsive to window resizing
            responsive: true,
            // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
            maintainAspectRatio: true,
            //String - A legend template
            legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
        };
        //Create pie or douhnut chart
        // You can switch between pie and douhnut using the method below.
        pieChart.Doughnut(PieData, pieOptions);

        //-------------
        //- BAR CHART -
        //-------------
        var barChartCanvas = $("#barChart").get(0).getContext("2d");
        var barChart = new Chart(barChartCanvas);
        var barChartData = areaChartData;
        barChartData.datasets[1].fillColor = "#00a65a";
        barChartData.datasets[1].strokeColor = "#00a65a";
        barChartData.datasets[1].pointColor = "#00a65a";
        var barChartOptions = {
            //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
            scaleBeginAtZero: true,
            //Boolean - Whether grid lines are shown across the chart
            scaleShowGridLines: true,
            //String - Colour of the grid lines
            scaleGridLineColor: "rgba(0,0,0,.05)",
            //Number - Width of the grid lines
            scaleGridLineWidth: 1,
            //Boolean - Whether to show horizontal lines (except X axis)
            scaleShowHorizontalLines: true,
            //Boolean - Whether to show vertical lines (except Y axis)
            scaleShowVerticalLines: true,
            //Boolean - If there is a stroke on each bar
            barShowStroke: true,
            //Number - Pixel width of the bar stroke
            barStrokeWidth: 2,
            //Number - Spacing between each of the X value sets
            barValueSpacing: 5,
            //Number - Spacing between data sets within X values
            barDatasetSpacing: 1,
            //String - A legend template
            legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].fillColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>",
            //Boolean - whether to make the chart responsive
            responsive: true,
            maintainAspectRatio: true
        };

        barChartOptions.datasetFill = false;
        barChart.Bar(barChartData, barChartOptions);
   
    });
</script>
    }

این عکس از حالت debugger :

سلام دوستان عزیزم خسته نباشید ، می خوام یک چارت رو داخل  modal رسم کنم ولی یک مشکل وجود داره وقتی برنامه رو اجرا میکنم چیزی نمایش داده نمیشه! ولی وقتی debugger میزارم و بر نامه رو اجرا میکنم چارت به درستی نمایش داده میشه! نمی دونم مشکل چیه. چه فرقی بین حالت که برنامه رو اجرا میکنیم و حالتی که debugger میزاریم و trace میکنیم هست؟!مگه سورس هر دو یکسان نیست؟ اینم سورس برنامه :
<js>

@{
    ViewBag.Title = LoginC;
    Layout = ~/Views/Shared/_Layout.cshtml;
}

<h2>LoginC</h2>
<!-- Draw-Chart -->
<div class=modal fade id=Draw-Chart tabindex=-1 role=dialog aria-labelledby=exampleModalLabel aria-hidden=true>
    <div class=modal-dialog >
        <div class=box box-info modal-content>
            <div class=box-header style=background: rgb(162,217,231);>
                <div class=box-tools pull-left>
                    <button class=btn btn-default btn-sm BtnClose data-dismiss=modal aria-label=Close><i class=fa fa-times></i></button>
                </div>
                <h3 class=box-title TittleModalBox style=max-width: 500px;text-overflow: ellipsis;white-space: nowrap;>نمودار میله ای</h3>
            </div>
            <form role=form method=post action= novalidate=novalidate>
                <input type=hidden value=0 name=Id />
                <div class=box-body clearfix>
                    <div class=message></div>


                    <!-- Main content -->
                    <section class=content>
                        <div class=row>
                            <div class=col-md-6>
                                <!-- AREA CHART -->
                                <div class=box box-primary>
                                    <div class=box-header with-border>
                                        <h3 class=box-title>Area Chart</h3>
                                        <div class=box-tools pull-left>
                                            <button type=button class=btn btn-box-tool data-widget=collapse>
                                                <i class=fa fa-minus></i>
                                            </button>
                                            <button type=button class=btn btn-box-tool data-widget=remove><i class=fa fa-times></i></button>
                                        </div>
                                    </div>
                                    <div class=box-body>
                                        <div class=chart>
                                            <canvas id=areaChart style=height:250px></canvas>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                                <!-- DONUT CHART -->
                                <div class=box box-danger>
                                    <div class=box-header with-border>
                                        <h3 class=box-title>Donut Chart</h3>
                                        <div class=box-tools pull-left>
                                            <button type=button class=btn btn-box-tool data-widget=collapse>
                                                <i class=fa fa-minus></i>
                                            </button>
                                            <button type=button class=btn btn-box-tool data-widget=remove><i class=fa fa-times></i></button>
                                        </div>
                                    </div>
                                    <div class=box-body>
                                        <canvas id=pieChart style=height:250px></canvas>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                            </div>
                            <!-- /.col (LEFT) -->
                            <div class=col-md-6>
                                <!-- LINE CHART -->
                                <div class=box box-info>
                                    <div class=box-header with-border>
                                        <h3 class=box-title>Line Chart</h3>
                                        <div class=box-tools pull-left>
                                            <button type=button class=btn btn-box-tool data-widget=collapse>
                                                <i class=fa fa-minus></i>
                                            </button>
                                            <button type=button class=btn btn-box-tool data-widget=remove><i class=fa fa-times></i></button>
                                        </div>
                                    </div>
                                    <div class=box-body>
                                        <div class=chart>
                                            <canvas id=lineChart style=height:250px></canvas>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                                <!-- BAR CHART -->
                                <div class=box box-success>
                                    <div class=box-header with-border>
                                        <h3 class=box-title>Bar Chart</h3>
                                        <div class=box-tools pull-left>
                                            <button type=button class=btn btn-box-tool data-widget=collapse>
                                                <i class=fa fa-minus></i>
                                            </button>
                                            <button type=button class=btn btn-box-tool data-widget=remove><i class=fa fa-times></i></button>
                                        </div>
                                    </div>
                                    <div class=box-body>
                                        <div class=chart>
                                            <canvas id=barChart style=height:230px></canvas>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                            </div>
                            <!-- /.col (RIGHT) -->
                        </div>
                        <!-- /.row -->
                    </section>
                    <!-- /.content -->


                    
                    
                </div>
                @*<div class=box-footer clearfix>
                    <button type=submit class=btn btn-success accept pull-left id=load data-loading-text=لطفا منتظر بمانید ...<i class='fa fa-spinner fa-spin '></i> >
                       ورود
				 <i class=fa  aria-hidden=true></i>

				</button>

                </div>*@
            </form>
            <div class=overlay style=display: none></div>
            <div class=loading-img style=display: none></div>
        </div>
    </div>
</div>
@section Head{
<script src=/public/plugins/chartjs/Chart.min.js></script>
<script type=text/javascript>
    $(function () {
        debugger
        $(#Draw-Chart).modal('show');
        /* ChartJS
 * -------
 * Here we will create a few charts using ChartJS
 */

        //--------------
        //- AREA CHART -
        //--------------

        // Get context with jQuery - using jQuery's .get() method.
        var areaChartCanvas = $(#areaChart).get(0).getContext(2d);
        // This will get the first returned node in the jQuery collection.
        var areaChart = new Chart(areaChartCanvas);

        var areaChartData = {
            labels: [January, February, March, April, May, June, July],
            datasets: [
              {
                  label: Electronics,
                  fillColor: rgba(210, 214, 222, 1),
                  strokeColor: rgba(210, 214, 222, 1),
                  pointColor: rgba(210, 214, 222, 1),
                  pointStrokeColor: #c1c7d1,
                  pointHighlightFill: #fff,
                  pointHighlightStroke: rgba(220,220,220,1),
                  data: [65, 59, 80, 81, 56, 55, 40]
              },
              {
                  label: Digital Goods,
                  fillColor: rgba(60,141,188,0.9),
                  strokeColor: rgba(60,141,188,0.8),
                  pointColor: #3b8bba,
                  pointStrokeColor: rgba(60,141,188,1),
                  pointHighlightFill: #fff,
                  pointHighlightStroke: rgba(60,141,188,1),
                  data: [28, 48, 40, 19, 86, 27, 90]
              }
            ]
        };

        var areaChartOptions = {
            //Boolean - If we should show the scale at all
            showScale: true,
            //Boolean - Whether grid lines are shown across the chart
            scaleShowGridLines: false,
            //String - Colour of the grid lines
            scaleGridLineColor: rgba(0,0,0,.05),
            //Number - Width of the grid lines
            scaleGridLineWidth: 1,
            //Boolean - Whether to show horizontal lines (except X axis)
            scaleShowHorizontalLines: true,
            //Boolean - Whether to show vertical lines (except Y axis)
            scaleShowVerticalLines: true,
            //Boolean - Whether the line is curved between points
            bezierCurve: true,
            //Number - Tension of the bezier curve between points
            bezierCurveTension: 0.3,
            //Boolean - Whether to show a dot for each point
            pointDot: false,
            //Number - Radius of each point dot in pixels
            pointDotRadius: 4,
            //Number - Pixel width of point dot stroke
            pointDotStrokeWidth: 1,
            //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
            pointHitDetectionRadius: 20,
            //Boolean - Whether to show a stroke for datasets
            datasetStroke: true,
            //Number - Pixel width of dataset stroke
            datasetStrokeWidth: 2,
            //Boolean - Whether to fill the dataset with a color
            datasetFill: true,
            //String - A legend template
            legendTemplate: <ul class=\<%=name.toLowerCase()%>-legend\><% for (var i=0; i<datasets.length; i++){%><li><span style=\background-color:<%=datasets[i].lineColor%>\></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>,
            //Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
            maintainAspectRatio: true,
            //Boolean - whether to make the chart responsive to window resizing
            responsive: true
        };

        //Create the line chart
        areaChart.Line(areaChartData, areaChartOptions);

        //-------------
        //- LINE CHART -
        //--------------
        var lineChartCanvas = $(#lineChart).get(0).getContext(2d);
        var lineChart = new Chart(lineChartCanvas);
        var lineChartOptions = areaChartOptions;
        lineChartOptions.datasetFill = false;
        lineChart.Line(areaChartData, lineChartOptions);

        //-------------
        //- PIE CHART -
        //-------------
        // Get context with jQuery - using jQuery's .get() method.
        var pieChartCanvas = $(#pieChart).get(0).getContext(2d);
        var pieChart = new Chart(pieChartCanvas);
        var PieData = [
          {
              value: 700,
              color: #f56954,
              highlight: #f56954,
              label: Chrome
          },
          {
              value: 500,
              color: #00a65a,
              highlight: #00a65a,
              label: IE
          },
          {
              value: 400,
              color: #f39c12,
              highlight: #f39c12,
              label: FireFox
          },
          {
              value: 600,
              color: #00c0ef,
              highlight: #00c0ef,
              label: Safari
          },
          {
              value: 300,
              color: #3c8dbc,
              highlight: #3c8dbc,
              label: Opera
          },
          {
              value: 100,
              color: #d2d6de,
              highlight: #d2d6de,
              label: Navigator
          }
        ];
        var pieOptions = {
            //Boolean - Whether we should show a stroke on each segment
            segmentShowStroke: true,
            //String - The colour of each segment stroke
            segmentStrokeColor: #fff,
            //Number - The width of each segment stroke
            segmentStrokeWidth: 2,
            //Number - The percentage of the chart that we cut out of the middle
            percentageInnerCutout: 50, // This is 0 for Pie charts
            //Number - Amount of animation steps
            animationSteps: 100,
            //String - Animation easing effect
            animationEasing: easeOutBounce,
            //Boolean - Whether we animate the rotation of the Doughnut
            animateRotate: true,
            //Boolean - Whether we animate scaling the Doughnut from the centre
            animateScale: false,
            //Boolean - whether to make the chart responsive to window resizing
            responsive: true,
            // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
            maintainAspectRatio: true,
            //String - A legend template
            legendTemplate: <ul class=\<%=name.toLowerCase()%>-legend\><% for (var i=0; i<segments.length; i++){%><li><span style=\background-color:<%=segments[i].fillColor%>\></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>
        };
        //Create pie or douhnut chart
        // You can switch between pie and douhnut using the method below.
        pieChart.Doughnut(PieData, pieOptions);

        //-------------
        //- BAR CHART -
        //-------------
        var barChartCanvas = $(#barChart).get(0).getContext(2d);
        var barChart = new Chart(barChartCanvas);
        var barChartData = areaChartData;
        barChartData.datasets[1].fillColor = #00a65a;
        barChartData.datasets[1].strokeColor = #00a65a;
        barChartData.datasets[1].pointColor = #00a65a;
        var barChartOptions = {
            //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
            scaleBeginAtZero: true,
            //Boolean - Whether grid lines are shown across the chart
            scaleShowGridLines: true,
            //String - Colour of the grid lines
            scaleGridLineColor: rgba(0,0,0,.05),
            //Number - Width of the grid lines
            scaleGridLineWidth: 1,
            //Boolean - Whether to show horizontal lines (except X axis)
            scaleShowHorizontalLines: true,
            //Boolean - Whether to show vertical lines (except Y axis)
            scaleShowVerticalLines: true,
            //Boolean - If there is a stroke on each bar
            barShowStroke: true,
            //Number - Pixel width of the bar stroke
            barStrokeWidth: 2,
            //Number - Spacing between each of the X value sets
            barValueSpacing: 5,
            //Number - Spacing between data sets within X values
            barDatasetSpacing: 1,
            //String - A legend template
            legendTemplate: <ul class=\<%=name.toLowerCase()%>-legend\><% for (var i=0; i<datasets.length; i++){%><li><span style=\background-color:<%=datasets[i].fillColor%>\></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>,
            //Boolean - whether to make the chart responsive
            responsive: true,
            maintainAspectRatio: true
        };

        barChartOptions.datasetFill = false;
        barChart.Bar(barChartData, barChartOptions);
   
    });
</script>
    }
<js>
این عکس از حالت debugger :
||http://tosinso.com/files/get/edf24976-5fc8-452a-9724-9311fde15f25||
اینم عکس از حالت اجرا :(صفحه خالیه)
||http://tosinso.com/files/get/f97fb1e1-1c3f-4088-9383-f4fde147b4dc||

اینم عکس از حالت اجرا :(صفحه خالیه)

سلام دوستان عزیزم خسته نباشید ، می خوام یک چارت رو داخل  modal رسم کنم ولی یک مشکل وجود داره وقتی برنامه رو اجرا میکنم چیزی نمایش داده نمیشه! ولی وقتی debugger میزارم و بر نامه رو اجرا میکنم چارت به درستی نمایش داده میشه! نمی دونم مشکل چیه. چه فرقی بین حالت که برنامه رو اجرا میکنیم و حالتی که debugger میزاریم و trace میکنیم هست؟!مگه سورس هر دو یکسان نیست؟ اینم سورس برنامه :
<js>

@{
    ViewBag.Title = LoginC;
    Layout = ~/Views/Shared/_Layout.cshtml;
}

<h2>LoginC</h2>
<!-- Draw-Chart -->
<div class=modal fade id=Draw-Chart tabindex=-1 role=dialog aria-labelledby=exampleModalLabel aria-hidden=true>
    <div class=modal-dialog >
        <div class=box box-info modal-content>
            <div class=box-header style=background: rgb(162,217,231);>
                <div class=box-tools pull-left>
                    <button class=btn btn-default btn-sm BtnClose data-dismiss=modal aria-label=Close><i class=fa fa-times></i></button>
                </div>
                <h3 class=box-title TittleModalBox style=max-width: 500px;text-overflow: ellipsis;white-space: nowrap;>نمودار میله ای</h3>
            </div>
            <form role=form method=post action= novalidate=novalidate>
                <input type=hidden value=0 name=Id />
                <div class=box-body clearfix>
                    <div class=message></div>


                    <!-- Main content -->
                    <section class=content>
                        <div class=row>
                            <div class=col-md-6>
                                <!-- AREA CHART -->
                                <div class=box box-primary>
                                    <div class=box-header with-border>
                                        <h3 class=box-title>Area Chart</h3>
                                        <div class=box-tools pull-left>
                                            <button type=button class=btn btn-box-tool data-widget=collapse>
                                                <i class=fa fa-minus></i>
                                            </button>
                                            <button type=button class=btn btn-box-tool data-widget=remove><i class=fa fa-times></i></button>
                                        </div>
                                    </div>
                                    <div class=box-body>
                                        <div class=chart>
                                            <canvas id=areaChart style=height:250px></canvas>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                                <!-- DONUT CHART -->
                                <div class=box box-danger>
                                    <div class=box-header with-border>
                                        <h3 class=box-title>Donut Chart</h3>
                                        <div class=box-tools pull-left>
                                            <button type=button class=btn btn-box-tool data-widget=collapse>
                                                <i class=fa fa-minus></i>
                                            </button>
                                            <button type=button class=btn btn-box-tool data-widget=remove><i class=fa fa-times></i></button>
                                        </div>
                                    </div>
                                    <div class=box-body>
                                        <canvas id=pieChart style=height:250px></canvas>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                            </div>
                            <!-- /.col (LEFT) -->
                            <div class=col-md-6>
                                <!-- LINE CHART -->
                                <div class=box box-info>
                                    <div class=box-header with-border>
                                        <h3 class=box-title>Line Chart</h3>
                                        <div class=box-tools pull-left>
                                            <button type=button class=btn btn-box-tool data-widget=collapse>
                                                <i class=fa fa-minus></i>
                                            </button>
                                            <button type=button class=btn btn-box-tool data-widget=remove><i class=fa fa-times></i></button>
                                        </div>
                                    </div>
                                    <div class=box-body>
                                        <div class=chart>
                                            <canvas id=lineChart style=height:250px></canvas>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                                <!-- BAR CHART -->
                                <div class=box box-success>
                                    <div class=box-header with-border>
                                        <h3 class=box-title>Bar Chart</h3>
                                        <div class=box-tools pull-left>
                                            <button type=button class=btn btn-box-tool data-widget=collapse>
                                                <i class=fa fa-minus></i>
                                            </button>
                                            <button type=button class=btn btn-box-tool data-widget=remove><i class=fa fa-times></i></button>
                                        </div>
                                    </div>
                                    <div class=box-body>
                                        <div class=chart>
                                            <canvas id=barChart style=height:230px></canvas>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                                <!-- /.box -->
                            </div>
                            <!-- /.col (RIGHT) -->
                        </div>
                        <!-- /.row -->
                    </section>
                    <!-- /.content -->


                    
                    
                </div>
                @*<div class=box-footer clearfix>
                    <button type=submit class=btn btn-success accept pull-left id=load data-loading-text=لطفا منتظر بمانید ...<i class='fa fa-spinner fa-spin '></i> >
                       ورود
				 <i class=fa  aria-hidden=true></i>

				</button>

                </div>*@
            </form>
            <div class=overlay style=display: none></div>
            <div class=loading-img style=display: none></div>
        </div>
    </div>
</div>
@section Head{
<script src=/public/plugins/chartjs/Chart.min.js></script>
<script type=text/javascript>
    $(function () {
        debugger
        $(#Draw-Chart).modal('show');
        /* ChartJS
 * -------
 * Here we will create a few charts using ChartJS
 */

        //--------------
        //- AREA CHART -
        //--------------

        // Get context with jQuery - using jQuery's .get() method.
        var areaChartCanvas = $(#areaChart).get(0).getContext(2d);
        // This will get the first returned node in the jQuery collection.
        var areaChart = new Chart(areaChartCanvas);

        var areaChartData = {
            labels: [January, February, March, April, May, June, July],
            datasets: [
              {
                  label: Electronics,
                  fillColor: rgba(210, 214, 222, 1),
                  strokeColor: rgba(210, 214, 222, 1),
                  pointColor: rgba(210, 214, 222, 1),
                  pointStrokeColor: #c1c7d1,
                  pointHighlightFill: #fff,
                  pointHighlightStroke: rgba(220,220,220,1),
                  data: [65, 59, 80, 81, 56, 55, 40]
              },
              {
                  label: Digital Goods,
                  fillColor: rgba(60,141,188,0.9),
                  strokeColor: rgba(60,141,188,0.8),
                  pointColor: #3b8bba,
                  pointStrokeColor: rgba(60,141,188,1),
                  pointHighlightFill: #fff,
                  pointHighlightStroke: rgba(60,141,188,1),
                  data: [28, 48, 40, 19, 86, 27, 90]
              }
            ]
        };

        var areaChartOptions = {
            //Boolean - If we should show the scale at all
            showScale: true,
            //Boolean - Whether grid lines are shown across the chart
            scaleShowGridLines: false,
            //String - Colour of the grid lines
            scaleGridLineColor: rgba(0,0,0,.05),
            //Number - Width of the grid lines
            scaleGridLineWidth: 1,
            //Boolean - Whether to show horizontal lines (except X axis)
            scaleShowHorizontalLines: true,
            //Boolean - Whether to show vertical lines (except Y axis)
            scaleShowVerticalLines: true,
            //Boolean - Whether the line is curved between points
            bezierCurve: true,
            //Number - Tension of the bezier curve between points
            bezierCurveTension: 0.3,
            //Boolean - Whether to show a dot for each point
            pointDot: false,
            //Number - Radius of each point dot in pixels
            pointDotRadius: 4,
            //Number - Pixel width of point dot stroke
            pointDotStrokeWidth: 1,
            //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
            pointHitDetectionRadius: 20,
            //Boolean - Whether to show a stroke for datasets
            datasetStroke: true,
            //Number - Pixel width of dataset stroke
            datasetStrokeWidth: 2,
            //Boolean - Whether to fill the dataset with a color
            datasetFill: true,
            //String - A legend template
            legendTemplate: <ul class=\<%=name.toLowerCase()%>-legend\><% for (var i=0; i<datasets.length; i++){%><li><span style=\background-color:<%=datasets[i].lineColor%>\></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>,
            //Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
            maintainAspectRatio: true,
            //Boolean - whether to make the chart responsive to window resizing
            responsive: true
        };

        //Create the line chart
        areaChart.Line(areaChartData, areaChartOptions);

        //-------------
        //- LINE CHART -
        //--------------
        var lineChartCanvas = $(#lineChart).get(0).getContext(2d);
        var lineChart = new Chart(lineChartCanvas);
        var lineChartOptions = areaChartOptions;
        lineChartOptions.datasetFill = false;
        lineChart.Line(areaChartData, lineChartOptions);

        //-------------
        //- PIE CHART -
        //-------------
        // Get context with jQuery - using jQuery's .get() method.
        var pieChartCanvas = $(#pieChart).get(0).getContext(2d);
        var pieChart = new Chart(pieChartCanvas);
        var PieData = [
          {
              value: 700,
              color: #f56954,
              highlight: #f56954,
              label: Chrome
          },
          {
              value: 500,
              color: #00a65a,
              highlight: #00a65a,
              label: IE
          },
          {
              value: 400,
              color: #f39c12,
              highlight: #f39c12,
              label: FireFox
          },
          {
              value: 600,
              color: #00c0ef,
              highlight: #00c0ef,
              label: Safari
          },
          {
              value: 300,
              color: #3c8dbc,
              highlight: #3c8dbc,
              label: Opera
          },
          {
              value: 100,
              color: #d2d6de,
              highlight: #d2d6de,
              label: Navigator
          }
        ];
        var pieOptions = {
            //Boolean - Whether we should show a stroke on each segment
            segmentShowStroke: true,
            //String - The colour of each segment stroke
            segmentStrokeColor: #fff,
            //Number - The width of each segment stroke
            segmentStrokeWidth: 2,
            //Number - The percentage of the chart that we cut out of the middle
            percentageInnerCutout: 50, // This is 0 for Pie charts
            //Number - Amount of animation steps
            animationSteps: 100,
            //String - Animation easing effect
            animationEasing: easeOutBounce,
            //Boolean - Whether we animate the rotation of the Doughnut
            animateRotate: true,
            //Boolean - Whether we animate scaling the Doughnut from the centre
            animateScale: false,
            //Boolean - whether to make the chart responsive to window resizing
            responsive: true,
            // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
            maintainAspectRatio: true,
            //String - A legend template
            legendTemplate: <ul class=\<%=name.toLowerCase()%>-legend\><% for (var i=0; i<segments.length; i++){%><li><span style=\background-color:<%=segments[i].fillColor%>\></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>
        };
        //Create pie or douhnut chart
        // You can switch between pie and douhnut using the method below.
        pieChart.Doughnut(PieData, pieOptions);

        //-------------
        //- BAR CHART -
        //-------------
        var barChartCanvas = $(#barChart).get(0).getContext(2d);
        var barChart = new Chart(barChartCanvas);
        var barChartData = areaChartData;
        barChartData.datasets[1].fillColor = #00a65a;
        barChartData.datasets[1].strokeColor = #00a65a;
        barChartData.datasets[1].pointColor = #00a65a;
        var barChartOptions = {
            //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
            scaleBeginAtZero: true,
            //Boolean - Whether grid lines are shown across the chart
            scaleShowGridLines: true,
            //String - Colour of the grid lines
            scaleGridLineColor: rgba(0,0,0,.05),
            //Number - Width of the grid lines
            scaleGridLineWidth: 1,
            //Boolean - Whether to show horizontal lines (except X axis)
            scaleShowHorizontalLines: true,
            //Boolean - Whether to show vertical lines (except Y axis)
            scaleShowVerticalLines: true,
            //Boolean - If there is a stroke on each bar
            barShowStroke: true,
            //Number - Pixel width of the bar stroke
            barStrokeWidth: 2,
            //Number - Spacing between each of the X value sets
            barValueSpacing: 5,
            //Number - Spacing between data sets within X values
            barDatasetSpacing: 1,
            //String - A legend template
            legendTemplate: <ul class=\<%=name.toLowerCase()%>-legend\><% for (var i=0; i<datasets.length; i++){%><li><span style=\background-color:<%=datasets[i].fillColor%>\></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>,
            //Boolean - whether to make the chart responsive
            responsive: true,
            maintainAspectRatio: true
        };

        barChartOptions.datasetFill = false;
        barChart.Bar(barChartData, barChartOptions);
   
    });
</script>
    }
<js>
این عکس از حالت debugger :
||http://tosinso.com/files/get/edf24976-5fc8-452a-9724-9311fde15f25||
اینم عکس از حالت اجرا :(صفحه خالیه)
||http://tosinso.com/files/get/f97fb1e1-1c3f-4088-9383-f4fde147b4dc||

پرسیده شده در 1395/06/21 توسط

1 پاسخ

0

با سلام

بعضی مواقع کامپایلر از اجرای خطوط صرف نطر میکنه . با کد زیر یه delay تو اجرا ایجاد کنید

var delay=1000; //1 second

setTimeout(function() {

//your code to be executed after 1 second

}, delay);

پاسخ در 1395/06/21 توسط

پاسخ شما