1

目前我有这个代码:

<script type="text/javascript" src="/Scripts/highstock.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    var yAxisOptions = [],
    seriesOptions = []; 
    @{
        var measureType = Model.sensorMeasurements.Values.First();
        int i = 0;
        foreach (System.Reflection.PropertyInfo propertyInfo in measureType.GetType().GetProperties())
        {
            if (propertyInfo.Name == "ID" || propertyInfo.Name == "sensorID" || propertyInfo.Name == "timemark")
            {
                continue;
            }

            @: seriesOptions[@i] = { marker: { states: { hover: { enabled: false},},}, data: [

            bool firstData = true;

            foreach (ManualSensors.Models.ManualMeasurement x in Model.sensorMeasurements.Values)
            {
                System.Reflection.PropertyInfo pData = x.GetType().GetProperty(propertyInfo.Name);
                System.Reflection.PropertyInfo pDate = x.GetType().GetProperty("timemark");

                var m_data = pData.GetValue(x, null);
                DateTime m_date = (DateTime)pDate.GetValue(x, null);

                if (m_data.ToString() == "")
                {
                    continue;
                }

                if (firstData)
                {
                    firstData = false;

                    @:[Date.parse('@m_date.ToString("MM/dd/yyyy HH:mm:ss")'), @m_data.ToString()]
                }
                else
                {
                    @:,[Date.parse('@m_date.ToString("MM/dd/yyyy HH:mm:ss")'), @m_data.ToString()]
                } 
            }
            @:  ], name: '@propertyInfo.Name',  type: 'line', };
            i++;
        }

    }   
    createChart();
    // create the chart when all data is loaded
    function createChart() {
    chart = new Highcharts.StockChart({
    chart: {
    renderTo: 'container',
    borderWidth: 0.5,
    marginTop: 0,
    marginBottom: 30,
    zoomType: 'x',
    },
    scrollbar : {
        enabled : false
    },
    rangeSelector: {
        enabled : false
    },
    navigator: {
        enabled: false
    },
    tooltip: {
        enabled: false
    },
    series: seriesOptions
    });
    }
});
        </script>
        <div id="container">
        </div>

这是一个 mvc 视图,我正在将系列构建为数组中的元素,一个一个地,我很确定系列很好,但它在

chart = new Highcharts.StockChart({

在 createChart() 函数中,说图表没有被拒绝......有人可以帮我实现我想要的,创建简单的 stockChart 并使用这里显示的数据吗?谢谢

4

0 回答 0