Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

amcharts

<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
<script src="https://cdn.amcharts.com/lib/5/xy.js"></script>

<div id="chartdiv"></div>

<script>
// Create root and chart
var root = am5.Root.new("chartdiv"); 
var chart = root.container.children.push( 
  am5xy.XYChart.new(root, {
    panY: false,
    layout: root.verticalLayout
  }) 
);

// Define data
var data = [{ 
  category: "Research", 
  value1: 1000, 
  value2: 588 
}, { 
  category: "Marketing", 
  value1: 1200, 
  value2: 1800 
}, { 
  category: "Sales", 
  value1: 850, 
  value2: 1230 
}];

// Craete Y-axis
var yAxis = chart.yAxes.push( 
  am5xy.ValueAxis.new(root, { 
    renderer: am5xy.AxisRendererY.new(root, {}) 
  }) 
);

// Create X-Axis
var xAxis = chart.xAxes.push(
  am5xy.CategoryAxis.new(root, {
    renderer: am5xy.AxisRendererX.new(root, {}),
    categoryField: "category"
  })
);
xAxis.data.setAll(data);

// Create series
var series1 = chart.series.push( 
  am5xy.ColumnSeries.new(root, { 
    name: "Series", 
    xAxis: xAxis, 
    yAxis: yAxis, 
    valueYField: "value1", 
    categoryXField: "category" 
  }) 
);
series1.data.setAll(data);

var series2 = chart.series.push( 
  am5xy.ColumnSeries.new(root, { 
    name: "Series", 
    xAxis: xAxis, 
    yAxis: yAxis, 
    valueYField: "value2", 
    categoryXField: "category" 
  }) 
);
series2.data.setAll(data);

// Add legend
var legend = chart.children.push(am5.Legend.new(root, {})); 
legend.data.setAll(chart.series.values);

// Add cursor
chart.set("cursor", am5xy.XYCursor.new(root, {}));
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: binary sort js 
Javascript :: how to check for null in javascript 
Javascript :: how to uninstall nodejs web server 
Javascript :: how to add multiple event listener in javascript 
Javascript :: if syntax javascript 
Javascript :: angular inner page in refresh 404 after ng build 
Javascript :: Get title assert 
Javascript :: message.channel.name.includes 
Javascript :: jquery document ready deprecated 
Javascript :: use two div id in jquery 
Javascript :: object loop 
Javascript :: Send Data Using Express With Post 
Javascript :: create record mongoose model 
Javascript :: javascript extract from object and array 
Javascript :: react date picker 
Javascript :: mobile detect js 
Javascript :: omit key from object js 
Javascript :: reduce method 
Javascript :: how to use javascript in django template 
Javascript :: find the sum of an attribute in sequelize 
Javascript :: add to a js object 
Javascript :: linear search javascript 
Javascript :: uselayouteffect 
Javascript :: nested for loop in angular 
Javascript :: html call javascript function with input value 
Javascript :: clear input value with javascript 
Javascript :: return the first matching object from an array 
Javascript :: what is const in javascript 
Javascript :: how to sent react from data in mongodb 
Javascript :: Use the parseInt Function 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =