Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
76 views
in Technique[技术] by (71.8m points)

javascript - how can I used a variable inside the chart ( the chart gets the values in json formats)

I have a chart in my side nav and I want to show some data on the chart, but when I used the variable it said that the variable is undefined. I used the https://www.zingchart.com/ library for my chart. I want to know what should I do to set the my value in the chart.

here is my code:

const a = 100;
const b = 200;

    
        var myConfig = {

      "type": "funnel",
      "scale-y": {
        "placement": "opposite",
        "labels": ["Arash", "Trial Downloads", "Quote Requests", "Sales", "Renewals"],
        "item": {
          "font-color": "#999999",
          "font-family": "Georgia"
        }
      },
      "plot": {
        "value-box": {
          "text": "%v",
          "placement": "left-out", //"auto"/"in", "top", "bottom", "left", "right", "left-out", or "right-out"
          "font-color": "gray",
          "font-family": "Georgia",
          "font-size": 12,
          "font-weight": "normal"
     
        },
        "min-exit": "10%",
        "hover-state": {
          "background-color": "purple",
          "border-color": "gray",
          "border-width": 3,
          "line-style": "dashdot"
        }
      },
      "series": [{
          "values": [a],
          "text": "Arash-arash",
          "background-color": "red"
        },
        {
          "values": [b],
          "text": "arash2",
          "background-color": "orange"
        },
        {
          "values": [90],
          "text": "Quote Requests",
          "background-color": "yellow"
        },
        {
          "values": [30],
          "text": "Sales",
          "background-color": "green"
        },
        {
          "values": [15],
          "text": "Renewals",
          "background-color": "blue"
        }
      ]
    };
     
    zingchart.render({
      id: 'myChart',
      data: myConfig,
      height: "100%",
      width: "100%"
    });
question from:https://stackoverflow.com/questions/65901355/how-can-i-used-a-variable-inside-the-chart-the-chart-gets-the-values-in-json-f

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

screenshot from zingchart documentation you are not defining the property correctly, in the screenshot above from the documentation, it should be scaleY rather scale-y as defined in your code above


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...