Populate the line path of amCharts and eliminate the y-axis labels

I'm experimenting with amCharts to generate the following:

https://i.sstatic.net/LWAQr.png

Currently, I'm facing some challenges:

  1. The y-axis labels are not disappearing. I attempted to use theYAxis.disabled = true; as mentioned in the documentation.
  2. I would like everything below the line graph to be filled with a blue shade. However, it's currently displaying just a line. I tried this approach:

var range = xAxis.axisRanges.create();
range.theXAxis.fill = chart.colors.getIndex(8);
range.theXAxis.fillOpacity = 0.2;

What could I be doing wrong?

Check out the Demo:

var chart = am4core.create("dataChart", am4charts.XYChart);

chart.data = [{
    "xValue": "Q1",
    "yValue": 3
}, {
    "xValue": "Q2",
    "yValue": 4
}, {
    "xValue": "Q3",
    "yValue": 7
}, {
    "xValue": "Q4",
    "yValue": 2
}, {
    "xValue": "Q5",
    "yValue": 9
}];

/* Create axes */
var theXAxis = chart.xAxes.push(new am4charts.CategoryAxis());
theXAxis.dataFields.category = "xValue";

// trying to fill area below line
//var range = xAxis.axisRanges.create();
//range.theXAxis.fill = chart.colors.getIndex(8);
//range.theXAxis.fillOpacity = 0.2;

/* Create value axis */
var theYAxis = chart.yAxes.push(new am4charts.ValueAxis());
//theYAxis.disabled = true; // . attempting to disable . for displaying 1-10


/* Create series */
var series1 = chart.series.push(new am4charts.LineSeries());
series1.dataFields.valueY = "yValue";
series1.dataFields.categoryX = "xValue";
series1.bullets.push(new am4charts.CircleBullet());
series1.tooltipText = "{valueY} / 10";

/* Create a cursor */
chart.cursor = new am4charts.XYCursor();
#dataChart{
  width: 100%;
  height: 500px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>

<div id="dataChart"></div>

Answer №1

If you want to get rid of the labels, simply disable them on the axis renderer. This can be done by following the instructions provided in the documentation.

theYAxis.renderer.labels.template.disabled = true;

For a basic fill under the line only, you can set the fill and fillOpacity properties directly on the series component.

series.stroke = "#000088"; //for the line
series.fill = "#000088";  // for the fill
series.fillOpacity = .3;

var chart = am4core.create("dataChart", am4charts.XYChart);

chart.data = [{
    "xValue": "Q1",
    "yValue": 3
}, {
    "xValue": "Q2",
    "yValue": 4
}, {
    "xValue": "Q3",
    "yValue": 7
}, {
    "xValue": "Q4",
    "yValue": 2
}, {
    "xValue": "Q5",
    "yValue": 9
}];

/* Create axes */
var theXAxis = chart.xAxes.push(new am4charts.CategoryAxis());
theXAxis.dataFields.category = "xValue";

// trying to create a filled line below
//var range = xAxis.axisRanges.create();
//range.theXAxis.fill = chart.colors.getIndex(8);
//range.theXAxis.fillOpacity = 0.2;

/* Create value axis */
var theYAxis = chart.yAxes.push(new am4charts.ValueAxis());
//theYAxis.disabled = true; // . trying to disable . to 1-10 showing here
theYAxis.renderer.labels.template.disabled = true;

/* Create series */
var series1 = chart.series.push(new am4charts.LineSeries());
series1.dataFields.valueY = "yValue";
series1.dataFields.categoryX = "xValue";
series1.bullets.push(new am4charts.CircleBullet());
series1.tooltipText = "{valueY} / 10";
series1.fill = "#000088";
series1.fillOpacity = .3;
series1.stroke = "#000088";

/* Create a cursor */
chart.cursor = new am4charts.XYCursor();
#dataChart{
  width: 100%;
  height: 500px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>

<div id="dataChart"></div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide on invoking a function within a Vue npm package

I have been working on displaying and modifying images of a car in my project. To achieve this, I utilized the vue-upload-multiple-image package for storing the images successfully. However, I encountered an issue when trying to retrieve these stored image ...

Create an array of various tags using the ngRepeat directive to iterate through a loop

I'm familiar with both ngRepeat and forEach, but what I really need is a combination of the two. Let me explain: In my $scope, I have a list of columns. I can display them using: <th ng-repeat="col in columns">{{ col.label }}</th> This ...

Using the touchscreen does not allow scrolling on mouse movement

I am a beginner in the world of CSS and HTML, and I have limited knowledge about JavaScript. Recently, I came across some JavaScript code on CodePen that works perfectly except when using a touchscreen device. How can I make the content of my div scroll sm ...

Sliding to alter the vertex coordinates

Seeking help to dynamically change the x and y position of the first vertex in a triangle using sliders on datgui. Below is my code, can someone help me figure out what I'm doing wrong by assigning variables inside animate()? I've been struggling ...

Utilizing a Proxy with Vite for Vue Frontend in Conjunction with Django Rest Framework

Have you ever noticed the difference between accessing a view with Django Rest API on a browser versus sending an Ajax request and receiving JSON? I'm currently trying to modify the proxy settings for Vite, but I'm struggling to find comprehensiv ...

Creating a personalized pop-up container similar to the style seen on YouTube

I am looking to create a popup window similar to the YouTube share feature where it sticks next to a button. I have tried using Bootstrap modal, but it opens in the middle of the screen. I want the popup to appear around the button when the YouTube share b ...

Error: Badge not responsive in Boostrap 4

I have a project to create a table of contents using BOOTSTRAP4. I researched and used https://getbootstrap.com/docs/4.6/components/list-group/. However, the Badge does not align correctly as expected, it remains fixed with the content. <ul class=&qu ...

How to Use jQuery to Iterate Through a JSON Array and Add to an HTML Container Element?

I'm currently embarking on a personal project and have a query relating to jQuery and its usage in looping through a JSON array. Here is the JSON array I am working with: var thumbDir = [ '"https://www.location.com/1.jpg"', '"https:// ...

CSS: Determining the Best Time to Utilize Display Flex Versus Display Inline-Block

https://i.sstatic.net/SHfd0.png Hey there! I'm looking to create a layout similar to the one shown above. I'm using Bootstrap4 and I know that I can utilize either display:flex or display:inline-block to achieve this. However, I'm unsure of ...

Tips on how to update the styling of an active link

http://jsfiddle.net/G8djC/2/ Looking to create a tabbed area where content changes based on the tab clicked. The Javascript function switches the link class to active upon clicking. However, struggling to change the color of the active tab beyond the firs ...

Guide on how to fill a jQuery DataTable with data from an XMLHttpRequest response

I have come across multiple inquiries on this topic, but none of the solutions provided have brought me close enough to resolving my issue. Hopefully, someone out there will find it simple to address. I am attempting to populate a DataTable using an XHR re ...

Is it possible to display a complete list of my items along with their parameters using jQuery ajax?

My function code is set up to display all the items from my list of discipline codes, but I'm facing issues viewing them due to data:{params} always being present. alert('Could not retrieve data'); Any assistance would be greatly appreci ...

When attempting to display an updated value in a dialog window using an ajax response for the second time, the change

Upon submission of my form, a PHP script is triggered via AJAX to perform validation. Currently, the script simply echoes the post value. For example, if a user inputs "Dog" into "formEntry," the AJAX response will display Dog. However, if the user cancels ...

Adjust the section and aside elements to automatically expand when used within the main tag

Is there a way to ensure that the inner-section and sidebar have a minimum height, while also expanding vertically along with the main tag? Here is an example of the HTML code: <body> <header></header> <main> <s ...

Using Angular 4: Redirecting Menu to Component with Electron

I am currently working on my first project using Angular 4 and Electron to develop a desktop application. One of the challenges I'm facing is figuring out how to redirect to a specific component when a submenu item is clicked after overriding the ele ...

Effortlessly transfer files with Ajax through Box

I attempted to utilize the Box.com API for file uploads according to instructions from https://gist.github.com/seanrose/5570650. However, I encountered the following error message: `XMLHttpRequest cannot load "". No 'Access-Control-Allow-Origin&ap ...

Check out the CSS media query for screens with a maximum width on larger devices

Is there a way to preview a specific div and see how it appears on mobile devices? The HTML code for the div is obtained from an external source, like this: var external_html='<div>Responsive div</div>' + '<style>@media ...

3D spinning icosahedron adorned with circles at each corner using three.js

In my project, I am working with an interactive icosahedron mesh that undergoes rotation. As part of the animation loop, circle geometries are dynamically added, and their locations are set to each vertex of the mesh at every frame. geometry = new THREE.I ...

Having trouble getting a react application using Webpack 2 and code splitting to run properly without dynamic files

After creating a beautiful React app with Webpack 2 and code splitting, I now have an index.html file along with several JS apps like bundle.js, 1.bundle.js, etc. in a build folder. My initial thought was to simply serve these assets statically on a server ...

Shine a spotlight on the submit button when an input field is in focus in an

Embarking on my journey into front-end web development, I encountered a task of creating a subscription form. My goal is to make the subscribe button stand out when a user clicks on the input field. Is it possible to achieve this effect using CSS alone, wi ...