Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
Amchart XYchart with multiple series and string-based Y-axis

Using amchart4, I have problems to draw a XYChat with Y-axis as a category-axis (string values), and having multiple series for that.

When I only have one seri which I can set yAxis.dataFields.category there is no problem. Also if I have two series with y-axis as a value-axis (numerical value) there is no problem. The problem happened with Y-category-axis and multiple series.

Here is my code:

  let myData = [
    {
      title: "2",
      //y:6,
      //y1:9,
      customer1: "Internet_BB",
      customer2: "Space",
    },
    {
      title: "1",
      //y:12,
      //y1:6,
      customer1: "Cloud_transmission_BB",
      customer2: "Internet_BB",
    },
    {
      title: "rhs",
      //y:5,
      //y1:7,
      customer1: "COLOCATION",
      customer2: "InternalData_BB_(NIN)",
    }

  ];

    am4core.useTheme(am4themes_animated);

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

    chart.data = myData;

    var xAxis = chart.xAxes.push(new am4charts.CategoryAxis());
    xAxis.dataFields.category = "title";

    var yAxis = chart.yAxes.push(new am4charts.CategoryAxis());
    // var yAxis = chart.yAxes.push(new am4charts.ValueAxis());

    // Create series
    var series1 = chart.series.push(new am4charts.LineSeries());
    series1.dataFields.categoryY = "customer1";
    // series1.dataFields.valueY = "y"
    series1.dataFields.categoryX = "title";
    series1.name = "customer1";
    series1.strokeWidth = 3;
    series1.tooltipText = "{name} in {categoryX}: {categoryY}";
    series1.legendSettings.valueText = "{categoryY}";

    var series2 = chart.series.push(new am4charts.LineSeries());
    series2.dataFields.categoryY = "customer2";
    // series2.dataFields.valueY = "y1"
    series2.dataFields.categoryX = "title";
    series2.name = "customer2";
    series2.strokeWidth = 3;
    series2.tooltipText = "{name} in {categoryX}: {categoryY}";
    series2.legendSettings.valueText = "{categoryY}";

    chart.cursor = new am4charts.XYCursor();
    chart.cursor.behavior = "zoomY";
    chart.legend = new am4charts.Legend();
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!