Exemplo n.º 1
0
 void Start()
 {
     Camera.main.transform.position = new Vector3(4.5f, 6f, -11.5f);
     Rawdata = DataAdaptor.ReadCSVFile("Assets/stacked_data_accident1.csv");   // reading csv file
     foreach (string item in Rawdata)
     {
         data.Add(float.Parse(item));                                // converting data from string to float
     }
     columnCount = DataAdaptor.header.Split(',').Length;
     rowCount    = data.Count / columnCount;
     findMax();
     makeAxis();
     instantiateBars();
 }
Exemplo n.º 2
0
    // Use this for initialization
    void Awake()
    {
        // Read the data from the file using our "generic" adaptor
        rawData = DataAdaptor.ReadCSVFile("Assets/circular_heatchart_data.csv");
        // Parse the data from strings to floats
        foreach (string data in rawData)
        {
            energyData.Add(float.Parse(data));
        }

        max = 0;
        min = energyData[0];

        // Find the max and min of our array
        for (int i = 0; i < energyData.Count; i++)
        {
            if (energyData[i] > max)
            {
                max = energyData[i];
            }
            if (energyData[i] < min)
            {
                min = energyData[i];
            }
        }
        // Create a segment for each data point
        for (int i = 0; i < energyData.Count; i++)
        {
            int ringNumber = i / 12;

            Mesh       segmentWedge = CustomMeshGenerator.Create3DToroidWedge(40, ringNumber + 1, ringNumber + 2, 30, 1);
            GameObject newSegment   = new GameObject("Chart Segment" + (i + 1));
            newSegment.AddComponent <MeshCollider>().sharedMesh     = segmentWedge;
            newSegment.AddComponent <MeshFilter>().mesh             = segmentWedge;
            newSegment.AddComponent <MeshRenderer>().material.color = PointToColor(energyData[i]);
            // localRotation cannot be a vector3, have to use Quaternion
            newSegment.transform.localRotation = Quaternion.Euler(0, 0, -30 * (i % 12));
        }
        // Move the camera so we can see the whole chart
        transform.position = new Vector3(0f, 0f, -0.21f * energyData.Count);
    }