How to add new chart(any charts, highcharts or d3

2019-09-14 18:34发布

问题:

I have created an application using Serenity framework. I have completed basic functionality for CRUD using serenity. Based on my tables I need to have graphical representations, any charts like high charts, D3 charts or any . 1. How can I get data from the tables using serenity framework ? 2. How can I customise the data into graphical representations ?

回答1:

Finally I have found the answer for this. We can use sql queries as well as stored procedure to fetch data from DB. I have used stored procedure to get the data from db.

In repository page you can call stored procedure,

public ListResponse<MyRow> GetCustomData(IDbConnection connection)
    {
        var data = connection.Query<MyRow>("GetOrders",
            param: new
            {
                startDate = request.nstartDate,
                endDate = request.EndDate
            },
            commandType: System.Data.CommandType.StoredProcedure);

        var response = new ListResponse<MyRow>();
        response.Entities = (List<MyRow>)data;
        return response;

}

I have already defined MyRow as OrderRow like this using MyRow = Entities.OrderRow;.

You can call this method from your controller. You can pass the value to model and can use data for chart lik highcharts or d3 charts.

Hope this will help you.