• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript create a Apache chart using a method

Sarandis

New Coder
guys i have been asked to create a few Apache E-charts. the way i am doing it copy paste the whole code everytime pass the values i want and render the chart in the screen.
the problem is that if i have 10 charts on the screen then i have 10 blocks of code. one for each chart. therefore i am trying to create a method and every-time i need a chart call the method pass the values i want and render it to the screen.

here is what i have done:


JavaScript:
    callTheMethod(titleText:String,titleButest:String,){
      // console.log("hi" + name +"your surname is"+ surname)

      this.myPieChart6 = {
        title: {
          text: titleText,
          subtext: titleButest,
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: [
              { value: 40, name: 'Internal' },
              { value: 44, name: 'External' },
              { value: 40, name: 'Int/Ext' },
              { value: 32, name: 'Unclassified' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
  }

then i call the method like this:
Code:
callTheMethod("my chart","this is a subtitle",)


the problem i have is with the name of the chart - this.myPieChart6
i cant pass a parameter that everytime changes the name of the chart.
i dont want all the charts to have the same same- this.myPieChart6
i want to be able to differentiate them...
how i do that ?? any ideas?
 

New Threads

Latest posts

Buy us a coffee!

300x250
Top Bottom