如何从JSON计算x,y和z值

时间:2018-01-24 05:55:04

标签: javascript json echarts

我有以下给出的json数据格式。从这些数据我只需要在3D图表中显示group11情感。所以我需要x,y和z值。如果得到这些值,请给我一些逻辑。我们可以使用这个给定的json中的任何东西。

JSON

{
  "status": "success",
  "result": {
    "duration": "15034.88",
    "sessionStatus": "Done",
    "analysisSegments": [
      {
        "offset": 0,
        "duration": 10000,
        "end": 10000,
        "analysis": {
          "Temper": {
            "Value": "62.00",
            "Group": "medium",
            "Score": "59.00"
          },
          "Valence": {
            "Value": "96.00",
            "Group": "positive",
            "Score": "94.00"
          },
          "Arousal": {
            "Value": "98.00",
            "Group": "high",
            "Score": "97.00"
          },
          "Vad": {
            "Voiced": "70.00"
          },
          "Mood": {
            "Group7": {
              "Primary": {
                "Id": 1,
                "Phrase": "Angry"
              },
              "Secondary": {
                "Id": 3,
                "Phrase": "Enthusiastic"
              }
            },
            "Group11": {
              "Primary": {
                "Id": 11,
                "Phrase": "Supremacy, Arrogance"
              },
              "Secondary": {
                "Id": 1,
                "Phrase": "Creative, Passionate"
              }
            },
            "Group21": {
              "Primary": {
                "Id": 9,
                "Phrase": "egoism"
              },
              "Secondary": {
                "Id": 18,
                "Phrase": "motivation"
              }
            },
            "Composite": {
              "Primary": {
                "Id": 143,
                "Phrase": "Insistence and stubbornness. Possibly childishness."
              },
              "Secondary": {
                "Id": 5,
                "Phrase": "Ambitious. Assertiveness to achieve goals."
              }
            }
          }
        }
      },
      {
        "offset": 5000,
        "duration": 10000,
        "end": 15000,
        "analysis": {
          "Temper": {
            "Value": "63.00",
            "Group": "medium",
            "Score": "57.00"
          },
          "Valence": {
            "Value": "89.00",
            "Group": "positive",
            "Score": "84.00"
          },
          "Arousal": {
            "Value": "94.00",
            "Group": "high",
            "Score": "91.00"
          },
          "Vad": {
            "Voiced": "62.00"
          },
          "Mood": {
            "Group7": {
              "Primary": {
                "Id": 1,
                "Phrase": "Angry"
              },
              "Secondary": {
                "Id": 3,
                "Phrase": "Enthusiastic"
              }
            },
            "Group11": {
              "Primary": {
                "Id": 11,
                "Phrase": "Supremacy, Arrogance"
              },
              "Secondary": {
                "Id": 6,
                "Phrase": "Leadership, Charisma"
              }
            },
            "Group21": {
              "Primary": {
                "Id": 8,
                "Phrase": "dominance"
              },
              "Secondary": {
                "Id": 18,
                "Phrase": "motivation"
              }
            },
            "Composite": {
              "Primary": {
                "Id": 107,
                "Phrase": "Possessiveness. Ownership. Authoritative."
              },
              "Secondary": {
                "Id": 41,
                "Phrase": "Strong drive."
              }
            }
          }
        }
      }
    ],
    "analysisSummary": {
      "AnalysisResult": {
        "Temper": {
          "Mode": "medium",
          "ModePct": "100.00"
        },
        "Valence": {
          "Mode": "positive",
          "ModePct": "100.00"
        },
        "Arousal": {
          "Mode": "high",
          "ModePct": "100.00"
        }
      }
    }
  }
}

我尝试了什么

  1. x-Emotion name(Supremacy,Arrogance)
  2. y-情绪计数(重复多少次)
  3. z-情绪持续时间(以分钟为单位)
  4. json parse

    var counter4=0;
    var val4 =0;
    var val4minute =0;
       var phrase = rawdata[i]["analysis"]["Mood"]["Group11"]["Primary"]["Phrase"];
          if (phrase == "Supremacy, Arrogance") {
      counter4++;
     val4 = counter4 * 10000;
     val4minute = Math.floor(val4 / 60000);
    }
    

    这里x是“Supremacy,Arrogance”counter4是y轴,val4minute是z轴

    但这种逻辑是错误的,任何人都可以给我一个更好的逻辑。

0 个答案:

没有答案