Code Monkey home page Code Monkey logo

Comments (2)

santam85 avatar santam85 commented on August 16, 2024

horizontalBar is not a supported chart type according to ChartJs docs: https://www.chartjs.org/docs/latest/charts/area.html

from ng2-charts.

JakeKeenan avatar JakeKeenan commented on August 16, 2024

I feel you are supposed to be able to make a horizontal bar chart by setting it under the options for the bar chart in question.
options: { indexAxis: y }
The documentation in chart.js shows that you should be able to make a horizontal bar chart through setting the indexAxis to why under options: https://www.chartjs.org/docs/latest/samples/bar/horizontal.html

It does not seem this is supported in ng2-charts

For example, the following does not work:

(properties in myChart.component.ts)
public lineChartOptions = {
indexAxis: 'y',
responsive: true
};
public lineChartLabels = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
public lineChartType : ChartType = 'bar';
public lineChartLegend = true;
public lineChartData = [
{ data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' }
];

(myChart.component.html)
div style="display: block; width: 50vw">
<canvas baseChart
[datasets]="lineChartData"
[labels]="lineChartLabels"
[options]="lineChartOptions"
[legend]="lineChartLegend"
[type]="lineChartType"
>

/div>

type error:
Type '{ indexAxis: string; responsive: boolean; }' is not assignable to type '_DeepPartialObject<CoreChartOptions & ElementChartOptions & PluginChartOptions<...> & DatasetChartOptions<...> & ScaleChartOptions<...>>'.

from ng2-charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.