1

使用 WebMatrix 和 razor (cshtml)

我有一个图表,但条形图是默认的蓝色。我想根据它们的值(即触发值或目标值)更改它们的颜色。

我该怎么做呢?我有一个使用以下代码的图表:

var db = Database.Open("data");
var itot = db.QueryValue("SELECT COALESCE(SUM(SUBTOTAL),0) from dbo.DR_TRANS where         TRANSDATE = datediff(d,0,getdate()) and transtype = 1 and SUBTOTAL >0") ?? 0;
var ctot = db.QueryValue("SELECT COALESCE(SUM(SUBTOTAL),0) from dbo.DR_TRANS where     TRANSDATE = datediff(d,0,getdate()) and TRANSTYPE = 1 and SUBTOTAL <0") ?? 0;
var itotnn = itot ?? 0;
var ctotnn = ctot ?? 0;
var nett = itotnn + ctotnn ?? 0;
var myChart = new Chart(width: 160, height: 500)
.AddTitle("Sales")
.AddSeries(
    name: "Today",
    xValue: new[] { "Actual", "Target" },
    yValues: new[] { nett, 18200 })
.Write();`
4

0 回答 0