Сделайте диаграмму inspinia на основе графика. js dynamic c в mvc5? - PullRequest
1 голос
/ 01 апреля 2020

Кто-нибудь использовал тему INSPINIA в MVC и делал ее графики динамическими c, чтобы извлекать данные из базы данных и отображать их через диаграммы?

Какую помощь я ищу, что добавить в контроллер и затем использовать его в поле данных графика:

@Scripts.Render("~/plugins/flot")

    <script type="text/javascript">
        $(document).ready(function () {
            var barOptions = {
                series: {
                    bars: {
                        show: true,
                        barWidth: 0.6,
                        fill: true,
                        fillColor: {
                            colors: [{
                                opacity: 0.8
                            }, {
                                opacity: 0.8
                            }]
                        }
                    }
                },
                xaxis: {
                    tickDecimals: 0
                },
                colors: ["#1ab394"],
                grid: {
                    color: "#999999",
                    hoverable: true,
                    clickable: true,
                    tickColor: "#D4D4D4",
                    borderWidth: 0
                },
                legend: {
                    show: false
                },
                tooltip: true,
                tooltipOpts: {
                    content: "x: %x, y: %y"
                }
            };
            var barData = {
                label: "bar",
                data: [         ** //What to use here? To replace this data?**
                        [1, 40],
                        [2, 25],
                        [3, 19],
                        [4, 34],
                        [5, 32],
                        [6, 22]
                    ]
                };
            $.plot($("#flot-bar-chart"), [barData], barOptions);
            var barOptions = {
                series: {
                    lines: {
                        show: true,
                        lineWidth: 2,
                        fill: true,
                        fillColor: {
                            colors: [{
                                opacity: 0.0
                            }, {
                                opacity: 0.0
                            }]
                        }
                    }
                },
                xaxis: {
                    tickDecimals: 0
                },
                colors: ["#1ab394"],
                grid: {
                    color: "#999999",
                    hoverable: true,
                    clickable: true,
                    tickColor: "#D4D4D4",
                    borderWidth: 0
                },
                legend: {
                    show: false
                },
                tooltip: true,
                tooltipOpts: {
                    content: "x: %x, y: %y"
                }
            };
            var barData = {
                label: "bar",
                data: ** What to use here? To replace this data?**
            };
            doPlot("right");
            $("button").click(function () {
                doPlot($(this).text());
            });
        });

Здесь мне нужна некоторая помощь в части контроллера, я хочу получить по двум значениям как ось х и ось у модели ( Работник) которого зовут и зарплата:

public class Worker
    {
        public int ID { get; set; }

        public string Name { get; set; }

        public string Position { get; set; }

        public string Office { get; set; }

        public string Extn { get; set; }

        public string Salary { get; set; }

    }
...