How to display data from database using pie and doughnut charts in angularjs
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-chart.js/0.10.2/angular-chart.js"></script>
<canvas id="pie" class="chart chart-pie" chart-data="data" chart-labels="labels" chart-options="options" width="207%"></canvas>
<canvas id="doughnut" class="chart chart-doughnut" chart-data="data" chart-labels="labels" chart-options="options" width="207%"></canvas>
[HttpGet]
[ActionName("GetDashboard")]
public string GetDashboardDetails()
{
SqlDataReader reader = null;
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["ERPConnectionString"].ConnectionString;
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.CommandText = "REPORT_WH_DASHBOARD";
sqlCmd.Connection = myConnection;
myConnection.Open();
reader = sqlCmd.ExecuteReader();
List<Dashboard> dboard = new List<Dashboard>();
Dashboard db = null;
while (reader.Read())
{
db = new Dashboard();
db.Transit = Convert.ToInt32(reader.GetValue(0));
db.Issued = Convert.ToInt32(reader.GetValue(1));
db.Stock = Convert.ToInt32(reader.GetValue(2));
//db.Total = Convert.ToInt32(reader.GetValue(12));
db.TransitPercent = Convert.ToInt32(reader.GetValue(4));
db.IssuedPercent = Convert.ToInt32(reader.GetValue(5));
db.StockPercent = Convert.ToInt32(reader.GetValue(6));
db.TransitValue = Convert.ToInt32(reader.GetValue(7));
db.IssuedValue = Convert.ToInt32(reader.GetValue(8));
db.StockValue = Convert.ToInt32(reader.GetValue(9));
db.AverageDays = Convert.ToInt32(reader.GetValue(10));
dboard.Add(db);
}
myConnection.Close();
return (new JavaScriptSerializer().Serialize(dboard));
}
USE [ERPT]
GO
--EXEC REPORT_WH_DASHBOARD
/****** Object: StoredProcedure [dbo].[REPORT_WH_DASHBOARD] Script Date: 7/22/2019 10:46:35 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[REPORT_WH_DASHBOARD]
AS
BEGIN
SELECT 421651 AS 'Transit',
631251 AS 'Issued',
421651 AS 'Stock',
--SUM(421651 + 631251 + 421651) AS 'Total',
CAST( ((421651 * 1.0)/ SUM(421651 + 631251 + 421651)) * 100 AS NUMERIC(9,0)) AS 'Transit Percent',
CAST( ((631251 * 1.0)/ SUM(421651 + 631251 + 421651)) * 100 AS NUMERIC(9,0)) AS 'Issued Percent',
CAST( ((421651 * 1.0)/ SUM(421651 + 631251 + 421651)) * 100 AS NUMERIC(9,0)) AS 'Stock Percent',
10000000 AS 'Transit Value',
21200542 AS 'Issued Value',
10000000 AS 'Stock Value',
58 AS 'Average Days'
END
GO
Here, I want to display the amount for transit, issued and stock.
10000000 AS 'Transit Value',
21200542 AS 'Issued Value',
10000000 AS 'Stock Value',