示例#1
0
文件: App.cs 项目: r3h0/Demos
        private static Chart CreatePolarChart(string rootEl, int seed = 0)
        {
            var chartConfig = new Chart.ChartConfiguration
            {
                type = "polarArea",
                data = new Chart.LinearChartData
                {
                    labels   = GetLabels(),
                    datasets = new[]
                    {
                        new Chart.ChartDataSets
                        {
                            label           = "Dataset 1",
                            data            = GetRandomData(100, seed),
                            borderWidth     = 1,
                            backgroundColor = GetBackgroundColor(),
                            borderColor     = GetBorderColor()
                        }
                    }
                },
                options = new Chart.ChartOptions
                {
                    responsive          = true,
                    maintainAspectRatio = false
                }
            };

            var chart = new Chart(rootEl, chartConfig);

            return(chart);
        }
示例#2
0
文件: App.cs 项目: r3h0/Demos
        private static Chart CreateBarChart(string rootEl, int seed = 0)
        {
            var chartConfig = new Chart.ChartConfiguration
            {
                type = "bar",
                data = new Chart.LinearChartData
                {
                    labels   = GetLabels(),
                    datasets = new[]
                    {
                        new Chart.ChartDataSets
                        {
                            label           = "Dataset 1",
                            data            = GetRandomData(100, seed),
                            borderWidth     = 1,
                            backgroundColor = GetBackgroundColor(),
                            borderColor     = GetBorderColor()
                        }
                    }
                },
                options = new Chart.ChartOptions
                {
                    responsive = true
                }
            };

            var rootElD = (HTMLCanvasElement)document.getElementById(rootEl);
            //@ rootElD = rootElD.getContext("2d");

            var chart = new Chart(rootElD, chartConfig);

            return(chart);
        }