![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ngx-line-chart
Advanced tools
Good-looking, easy-to-use, customizable Angular line chart library for 1 or 2 data sets with separate or common y-axes.
Good-looking, easy-to-use, customizable Angular line chart library for 1 or 2 data sets with separate or common y-axes.
deepmerge
) without any transitive dependenciesxLabelFunction
or yLabelFunction
To install this library, run:
$ npm install ngx-line-chart # Add --save if using npm version < 5
and then add the module in AppModule
as an imported module:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import the module
import { NgxLineChartModule } from 'ngx-line-chart';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgxLineChartModule // Add module here
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Now a component with selector ngx-line-chart
is registered and is usable in the templates.
Module only contains single component, called ngx-line-chart
to be used in the templates:
<ngx-line-chart [dataSets]="myDataSets" [xLabelFunction]="formXAxisValue.bind(this)"></ngx-line-chart>
export class MyComponent {
myDataSets = [{
name: 'likes',
points: [
{x: 10, y: 100},
{x: 20, y: 500}
]
}];
formatXAxisValue(value: number) {
return `Value ${value}`;
}
}
See below for details about all of the inputs.
Input | Type | Example value | Description |
---|---|---|---|
dataSets | IDataSet[] | [{name: 'likes', points: [{x: 10, y: 100}, {x: 20, y: 500}, {x: 50, y: 40}]] | Array of 1 or 2 data sets each containing a name and the actual data points (x and y as numbers). There data sets will be used to determine x-axis values along with the corresponding y-axis for each data set. |
xLabelFunction | (value: number) => string | (value: number) => value.toString() (this is the default) | This function will be called for each value of the x-axis labels for it to be formatted. Default function shows the values as they are. You may use this to format values as for example dates. See example above for how to pass a method (bind is needed). |
yLabelFunction | (value: number) => string | (value: number) => value.toString() (this is the default) | This function will be called for each value of the y-axis labels for it to be formatted. Default function shows the values as they are. |
xAxisValues | number[] | number | [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] or 10 |
style | IChartStyle | See Chart details below. |
Layout level section explains how to specify the size for the chart where as the details allow you to specify the colors and widths used within the chart.
The most important thing to note is that the line chart will always fulfill the element it is inserted into. What this means in practice is that if you have something like
<div style="width: 600px; height: 400px;">
<ngx-line-chart ...></ngx-line-chart>
</div>
The chart will now be 600px x 400px as it fulfills the container. Please note that the container doesn't of course need to have size specified as pixels but instead it can be declared as percentages etc.
Details of the chart can be fine tuned with style
input. default-style.ts gives a good example on how the object passed should look like:
import { IChartStyle } from './chart-style';
export const defaultStyle: IChartStyle = {
dataSetStyles: [
{
circle: {
color: '#0051BA',
radius: 4
},
labels: {
value: {
color: '#0051BA',
fontSize: 18
},
yAxis: {
color: '#0051BA',
fontSize: 18
}
},
line: {
color: 'rgba(0, 81, 186, 0.4)',
width: 5
}
},
{
circle: {
color: '#1F1F21',
radius: 4
},
labels: {
value: {
color: '#1F1F21',
fontSize: 18
},
yAxis: {
color: '#575759',
fontSize: 18
}
},
line: {
color: 'rgba(87, 87, 89, 0.4)',
width: 5
}
}
],
xAxis: {
labels: {
color: '#8C8C8E',
fontSize: 24,
angle: 60
}
}
};
These are also the default values and can be partially or fully altered by providing the input as follows:
<ngx-line-chart [style]="chartStyles"></ngx-line-chart>
export class MyComponent {
chartStyles = {
xAxis: {
labels: {
color: 'red'
}
}
}
}
This will now merge the specified red color for x-axis labels with the default styles.
For colors all the ways possible to declare a color in CSS will work. This includes:
red
and blue
#FFFFFF
, #242424
, rgb(255, 255, 255)
and rgba(60, 60, 60, 0.5)
hsl(120, 100%, 50%)
and hsla(120, 100%, 25%, 0.4)
Plan is to generalize the library as going forward. Things to be included contain at least:
Pull requests would be greatly appreciated for any of these or any other features you feel would be useful.
To run the demo project:
npm run build
in the root directory to generate dist/
(npm install
first, of course)demo/
and run npm install
npm run prepare-demo
. This copies dist/
folder to the node_modules/
of demo application. This is essentially what npm link
would achieve with symbolic link, but there's a known problem with Angular and npm link
.demo/
and start dev server with npm start
So to conclude:
npm install
npm run build
cd demo
npm install
cd ..
npm run prepare-demo
cd demo
npm start
To generate all *.js
, *.d.ts
and *.metadata.json
files:
$ npm run build
To lint all *.ts
files:
$ npm run lint
MIT © Roope Hakulinen
FAQs
Good-looking, easy-to-use, customizable Angular line chart library for 1 or 2 data sets with separate or common y-axes.
We found that ngx-line-chart demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.