0

I want to customize the bar chart with the user's data, and redraw it accordingly on run time. user should give details on both axis and their values. What code i should write to it ? Can angular variables be a good choice for doing it ?

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
  google.load("visualization", "1", {packages:["corechart"]});
  google.setOnLoadCallback(drawChart);
  function drawChart() {
    var data = google.visualization.arrayToDataTable([
      ['Year', 'Sales', 'Expenses'],
      ['2004',  600,      400],
      ['2005',  1170,      460],
      ['2006',  660,       1120],
      ['2007',  1030,      540]
      ['2008',  2000,      250]
    ]);

    var options = {
      title: 'Company Performance',
      vAxis: {title: 'Year',  titleTextStyle: {color: 'blue'}}
    };

    var chart = new google.visualization.BarChart(document.getElementById('div1'));

    chart.draw(data, options);
  }
</script>

2 Answers 2

1

Take a look at AngularJs Google Chart Tools directive

If you want to do things the "Angular way" you should use directives for all of your DOM manipulation. So i suggest you to store all of your data inside a controller, and then in your view use a directive to render a view from your data

Sign up to request clarification or add additional context in comments.

Comments

1

Go through this Google chart tools AngularJs Directive

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.