# Morris Chart

## Introduction

&#x20;It's a very simple API for drawing line, bar, area and donut charts, for more details you can check [here](https://morrisjs.github.io/morris.js/).

## How to Setup

### **HTML Structure**

```markup
<div id="m_chart_2" class="" style="height:294px;"></div>
```

## Dependency

### CSS

```markup
<!-- Morris Charts CSS -->
<link href="vendors/morris.js/morris.css" rel="stylesheet" type="text/css" />
```

### JS

```markup
<!-- Morris Charts JavaScript -->
<script src="vendors/raphael/raphael.min.js"></script>
<script src="vendors/morris.js/morris.min.js"></script>
<script src="dist/js/linecharts-data.js"></script>
```

### Initialize Morris Chart  JS

#### Line Chart

```javascript
/**Line Chart**/
Morris.Line({
    element: 'm_chart_2',
    data: [{
        period: '2010',
        iphone: 50,
    }, {
        period: '2011',
        iphone: 130,
    }, {
        period: '2012',
        iphone: 80,
    }, {
        period: '2013',
        iphone: 70,
    }, {
        period: '2014',
        iphone: 180,
    }, {
        period: '2015',
        iphone: 105,
    },
     {
        period: '2016',
        iphone: 250,
    }],
    xkey: 'period',
    ykeys: ['iphone'],
    labels: ['iPhone'],
    pointSize: 3,
    fillOpacity: 0,
		lineWidth:2,
		pointFillColors:['#fff'],
		pointStrokeColors:['#00acf0'],
		behaveLikeLine: true,
		hideHover: 'auto',
		gridLineColor: '#eaecec',
		lineColors: ['#00acf0'],
		resize: true,
		smooth:false,
		gridTextColor:'#5e7d8a',
		gridTextFamily:"Inherit"
});
```

#### Bar Chart

```javascript
Morris.Bar({
  element: 'm_chart_2',
  data: [
    { y: '2006', a: 100, b: 90 },
    { y: '2007', a: 75,  b: 65 },
    { y: '2008', a: 50,  b: 40 },
    { y: '2009', a: 75,  b: 65 },
    { y: '2010', a: 50,  b: 40 },
    { y: '2011', a: 75,  b: 65 },
    { y: '2012', a: 100, b: 90 }
  ],
  xkey: 'y',
  ykeys: ['a', 'b'],
  labels: ['Series A', 'Series B']
});
```

#### Area Chart

```javascript
Morris.Area({
  element: 'm_chart_2',
  data: [
    { y: '2006', a: 100, b: 90 },
    { y: '2007', a: 75,  b: 65 },
    { y: '2008', a: 50,  b: 40 },
    { y: '2009', a: 75,  b: 65 },
    { y: '2010', a: 50,  b: 40 },
    { y: '2011', a: 75,  b: 65 },
    { y: '2012', a: 100, b: 90 }
  ],
  xkey: 'y',
  ykeys: ['a', 'b'],
  labels: ['Series A', 'Series B']
});
```

#### Donut Chart

```javascript
Morris.Donut({
  element: 'm_chart_2',
  data: [
    {label: "Download Sales", value: 12},
    {label: "In-Store Sales", value: 30},
    {label: "Mail-Order Sales", value: 20}
  ]
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hencework.gitbook.io/pangong/charts/morris-chart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
