How do I format axes on line chart google chart material?

后端 未结 1 1537
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 03:16

I\'m having problems formatting the axes of material charts.

Using \"classic\" line chart if I would like to format my vertical axis with a dollar sign, I would do

1条回答
  •  无人及你
    2021-01-27 04:06

    the options simply are not available on Material charts...

    see --> Tracking Issue for Material Chart Feature Parity #2143


    when using a Core chart instead, there is an option that will get the chart "close" to Material chart...

    theme: 'material'
    

    see following working snippet...

    google.charts.load('current', {
      callback: drawChart,
      packages: ['corechart']
    });
    
    function drawChart() {
      var data = new google.visualization.DataTable();
      data.addColumn('date','Date');
      data.addColumn('number','Value');
      data.addRows([
        [new Date(2017, 1, 12), 250],
        [new Date(2017, 1, 13), 200],
        [new Date(2017, 1, 14), 150]
      ]);
    
      var options = {
        hAxis: {
          format: 'yyyy-MM-dd'
        },
        theme: 'material',
        vAxis: {
          format: '$#,##',
          title: 'Amount'
        }
      };
    
      var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }
    
    

    0 讨论(0)
提交回复
热议问题