示例#1
0
    void LoadObjectArray(CategoryData data)
    {
        GraphChartBase graph  = GraphObject.GetComponent <GraphChartBase>();
        var            parent = mParser.GetObject(data.ParentObjectName);

        if (parent == null)
        {
            Debug.LogWarning("Object " + data.ParentObjectName + " does not exist in the document");
            return;
        }

        int length = mParser.GetArraySize(parent);

        try
        {
            for (int i = 0; i < length; i++)
            {
                object item      = mParser.GetItemObject(parent, i);
                double x         = ParseItem(mParser.GetChildObjectValue(item, data.XDataObjectName), data.XDateFormat);
                double y         = ParseItem(mParser.GetChildObjectValue(item, data.YDataObjectName), data.YDateFormat);
                double pointSize = -1;
                if (String.IsNullOrEmpty(data.SizeDataObjectName) == false)
                {
                    pointSize = double.Parse(mParser.GetChildObjectValue(item, data.SizeDataObjectName));
                }
                graph.DataSource.AddPointToCategory(data.Name, x, y, pointSize);
            }
        }
        catch (Exception e)
        {
            Debug.LogWarning("Data for category " + data.Name + " does not match the specified format. Ended with exception : " + e.ToString());
        }
    }