1

我仍在尝试使用ChartJS完成我的图表。它进展顺利,但我遇到了一个我无法解决的问题。

我正在尝试显示我的客户销售图表。它有效,但他希望我从零开始图表。相反,它会自动从我的最低销售额开始,这在这种情况下是不合适的。

第二个问题是,周六和周一之间没有空间(他的商店周日不营业),但他想在那里休息一下。

有人可以帮助我吗?

那是我使用的代码(我删除了 SqlServer 访问代码并替换了实际销售值):

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/globalize/0.1.1/globalize.min.js"></script>
<script type="text/javascript" src="http://cdn3.devexpress.com/jslib/13.1.4/js/dx.chartjs.js"></script>   



<script>
    $(document).ready(function () {


   <% 
    Dim SalesList As Dictionary(Of DateTime, Integer) = New Dictionary(Of Date, Integer)

    SalesList.Add(New DateTime(2013, 6, 3), 12)
    SalesList.Add(New DateTime(2013, 6, 4), 14)
    SalesList.Add(New DateTime(2013, 6, 5), 9)
    SalesList.Add(New DateTime(2013, 6, 6), 15)
    SalesList.Add(New DateTime(2013, 6, 7), 9)
    SalesList.Add(New DateTime(2013, 6, 8), 4)
    SalesList.Add(New DateTime(2013, 6, 10), 11)

    Response.Write("var dataSource = [")
    For Each sales In SalesList
        Response.Write("{ date: '" + sales.Key + "', sales: " + sales.Value.ToString() + "},")
    Next

    Response.Write("]")
    %>

        var chart = $("#chartContainer").dxChart({
            dataSource: dataSource,
            series: {
                    type: "area",
                    argumentField: "date",
                    valueField: "sales",
                    name: "Sales"
            },
            title: "Sales"
        });
    });
</script>


<div id="chartContainer" style="width:800px;height:400px;"/>
4

1 回答 1

1

You can set minimum value of chart using following code:

valueAxis: {
    min: 0
}

More info on ChartJS documentation

I'm not sure I understand your second problem; I think you want to show you argument axis as contionus axis of time; now you have a list of possible string values, not datetime. You can specify it like this:

argumentAxis: {
    argumentType: 'datetime'
}

It forces dxChart to convert string data to date time. More info here

于 2013-06-11T15:30:51.983 回答