Giter Club home page Giter Club logo

highcharts-chart's Introduction

<highcharts-chart> npm version Bower version Published on webcomponents.org

Web Component wrapper to the Highcharts Graphing Library, to create a multitude of graphs/maps (spline, pie, and more) using Polymer 3.0.

Demo

You can see a Realtime/Resonsive demo live! With a Tutorial Icon in the top right.

Install

Install the component using npm:

$ npm install highcharts-chart --save

Or download as ZIP.

Usage

  1. Import Web Components' polyfill, on older browsers:

    <script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
  2. Import Custom Element:

    <script type="module" src="node_modules/highcharts-chart/highcharts-chart.js"></script>
        OR
    <script type="module">
        import 'node_modules/highcharts-chart/highcharts-chart.js';
    </script>
        OR
    <script>
        import('node_modules/highcharts-chart/highcharts-chart.js');
    </script>
  3. Start using it!

    <highcharts-chart x-zoom type="spline"
                      title="Test-Spline Chart"
                      data='[[0,0],[1,7],[2,1],[3,6],[4,8],[5,6]]'
                      x-label="Iterations" y-label="Awesomeness Index"></highcharts-chart>

    Other Examples

    <highcharts-chart type="pie"></highcharts-chart>
    <highcharts-chart type="column"></highcharts-chart>
    <highcharts-map></highcharts-map>
    <highcharts-stock></highcharts-stock>

<highcharts-chart>

Provides you a simple interface to interact with the HighCharts API, with extensive Data Binding. The charting is also responsive.

Options

Attribute Options Default Description
type spline,pie,column spline Pick type of chart
title string Highcharts Chart Title of Chart
subtitle string "" Subtitle of Chart
xAxis object {} OR Time based Specifies the configuration for the X-Axis.
yAxis object {} Specifies the configuration for the Y-Axis.
xLabel string X-Axis Label for X-Axis
yLabel string Y-Axis Label for Y-Axis
xZoom boolean false Zooming Allowed On X-Axis
yZoom boolean false Zooming Allowed On Y-Axis
label string Label[for non numeric] Alias for both Axis
data array [] Data for chart [data for Series 1 OR array of series]
loading boolean false Toggle loading overlay on chart
loadingMessage string Loading... Loading Text Display
selected boolean [readonly] false Is any element selected on graph
selectedPoints array [readonly] [] Which elements are selected
vsTime boolean false Set all options appropriate for a time chart
chartOptions object {} Override/Add Properties for your type of chart
export boolean false Enable exporting of chart
legend boolean false Display the legend
colorByPoint* boolean false Every point treated/colored uniquely
credits boolean false Wish to thank/credit HighCharts?
legendOptions object {} Override/Add Options to your legend
tooltipOptions object {} Override/Add Options to your tooltip
highchartOptions object {} Override/Add Options to the chart initalization code [useful for custom charts]
height-responsive Attribute NA Make chart height responsive [define container height for this to work]
renderer object [readonly] {} Allows direct access to the Highcharts rendering layer in order to draw primitive shapes like circles, rectangles,paths or text directly on a chart, or independent from any chart.
_chart object [readonly] {} HighCharts exposed object

Note:

  • The * annotated properties above are not available in the highcharts-map element
  • If you bind a bunch of series objects to the data property instead of data for a single series, it will perform series level binding

Methods

Method Parameters Description
setData(data,z=0) Data Array,Series Index Replaces series data with the passed array
addData(x,y,z,drill) x,y,index,drillable? Appends to data [efficient]
pushData(x,y,z) x,y,index Shifts and adds to data [efficient]
addSeries(name,data,colorByPoint,otherOptions) String,Array,boolean,{} Adds a new Series to Plot
addDrillSeries(point,data,name) point,Array,String Adds a series that is viewable when an Element is clicked into
getSeries(z=0) index Fetch a series [given by z], else return a dummy object
updateSeries(k,v,z) String,Mixed,0 Modifies an option by Key Value for series [given by z]
updateSeries(options,z) {},0 Modifies the options for series [given by z]
removeSeries(z,redraw) index,true Removes Series denoted by index [should redraw after remove]
showLoading(t)* t [Text] Sets Loading-Message equal to t then turns on loading screen
resizeChart() none Efficient reflow of the chart to parent [can be attached to a parent resize]
resizeChartFixed() none Fixed Adjustment of chart [use if chart should not fluctuate over minor size changes]
zoomOut() none Zoom out the chart
reRender() none Will force a complete re-render of the Highchart [use it when binding is not possible]
downloadAs(name,options) chart,{} Download/Export the chart as a file
destroy() none Free's up the memory used by the chart [prevents memory leaks]

Note: The * annotated methods above are not available in the highcharts-map element

Events

Event Description Payload [e.detail]
chart-click Click event on chart e [original event], chart [chart object], component [self]
chart-load Fired when chart loaded e, chart, component
before-print Fired before chart print e, chart, component
after-print Fired after chart print e, chart, component
series-added Fired when series added e, chart, component
drill-down Fired when drill down is triggered e, chart, component
drill-up Fired when drill up is triggered e, chart, component
drill-up-all In a chart with multiple drilldown series, this event fires after all the series have been drilled up e, chart, component
selection Fired when a range of points are selected e, chart, component
redraw Fires when the chart is redrawn e, chart, component
render Fires after initial load of the chart, and after each redraw e, chart, component

Styling

Mixin Description
--highcharts-min-height Min Height for Highcharts-Chart container [default: 26em]
--highcharts-container The container that directly contains the Chart SVG

Contributing/Suggestions

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Install the Polymer-CLI

First, make sure you have the Polymer CLI and npm (packaged with Node.js) installed. Run npm install to install your element's dependencies, then run polymer serve to serve your element locally.

Viewing Your Element

$ polymer serve

Running Tests

$ polymer test

Your application is already set up to be tested via web-component-tester. Run polymer test to run your application's test suite locally.

Note: Polymer 3 docs and migration done by: @mindon 2018-10-19

License

MIT License © Apoorv Verma

LinkedIn

highcharts-chart's People

Contributors

avdaredevil avatar awsum avatar bitdeli-chef avatar dependabot[bot] avatar limonte avatar mindon avatar sorin-davidoi avatar varletconst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

highcharts-chart's Issues

Error : Highcharts is not defined

I am using highcharts-chart" with lit-element:
"highcharts": "^7.1.2",
"highcharts-chart": "^3.0.1",

import 'highcharts-chart/highcharts-chart';
<highcharts-chart id="chart" type="pie" .data="${this.data}"
selected-points="${this.selectedPoints}"
title='${this.title}' x-zoom x-label="" y-label="" color-by-point="true" legend="true">

But getting the error :
highcharts-behavior.js:5 Uncaught ReferenceError: Highcharts is not defined
at Module.rv95 (highcharts-behavior.js:5)
at webpack_require (bootstrap:785)
at fn (bootstrap:150)
at Module.iJsM (highcharts-chart.js:1)
at webpack_require (bootstrap:785)
at fn (bootstrap:150)
at Module.LB6A (selectable-pie-chart.js:1)
at webpack_require (bootstrap:785)
at fn (bootstrap:150)
at Module.4g6G (infrastr-grid-filter.js:1)

highcharts-chart doesn't render, when included indirectly via another web component

Hi there,

I am trying out this nice web component and everything worked fine until the highcharts module pulled via bower updated the patch level from 5.0.9 to 5.0.14.

I put together two examples to show this behavior:
https://github.com/hadjian/highcharts-chart-broken-with-5.0.14
https://github.com/hadjian/highcharts-chart-working-with-5.0.9

The one, that is working explicitly pulls highcharts version 5.0.9 in bower.json. Both projects are based on the polymer starter example and include the highcharts-chart component via src/polytest-app/polytest-app.html. Including the component directly in index.html seems to work in both cases. Apologies in advance, if I made some newcomer mistake.

Regards,

Pedram

ability to set height

is there a way to specify the height of a graph? I want to stack four spline charts vertically in the viewport and have them be relatively sized 25%. I'm using iron-flex-layout for the structure but the graphs are overflowing their containers.

Upgrade to Highcharts v5.0.0

  • New Methods if needed
  • Update existing API's to work with new binding
    • Zoom Updates
  • Update old forms of binding
  • Fix Bugs

HighChart content is not getting displayed

Hi,

I am using polymer version #1.9 - 2. and i have installed highcharts-chart using command below
bower i highcharts-chart#polymer-1.0
and i have imported the highcharts component and used like below

when i inspect the svg conent is not getting loaded inside highcharts-chart component.

</highcharts-chart>

Could you please help in resolving this issue.

Upgrading to Polymer 2.x

Hi,
Thanks for having created this component !
I am planning to use it in my Polymer 2.x project.
I can initiate an upgrade to polymer 2.x but just wondering if you could create a branch for that (because it is going to be a full Polymer 2.x upgrade not hybrid).
Please let me know what your thoughts are on this.

How to use height-responsive?

Hi, thanks for providing this component. Saved me a lot of time.

Is the height-responsive attribute supposed to mean to expand the chart to its container? If so I can't seem to get it to work.

I tried:

<div style="height:1000px">
   <highcharts-chart height-responsive data="[1,2,3]"></highcharts-chart>
</div>

And so I would expect to see a chart of height 1000px but I'm not.

Have I misunderstood what this attribute is for?

Many thanks.

Real Time Axis Settings

Hello,

Sooo, I am using this very cool component in an application using electron+polymer which reads real time data from a microcontroller, via serial port.

All is good, however I have had some trouble shifting the plotted data as the new data is read. (See pic)

screenshot - 250217 - 01 36 13

Now, my problem is that I cannot find a way to control the (xmin,xmax) but using reRender(), the documentation in highcharts has an example using a function for the Axis called setExtremes, which I have not been able to find in this component.

What I do is to fill in an array with data and after a number has been reached push - shift - reRender, but I was wondering if there is some other way of doing so which would allow more binding and customisation on the fly?

This is the markup of the element and the properties:

<div id="hccontainer">
    <highcharts-chart id="hcplot"
    type="line"
    plot-options=[[plotOptions]]
    title="Sensor A0 time-series"
    x-axis=[[xoptions]]
    y-axis=[[yoptions]]
    ></highcharts-chart>
   </div>

The options which are kind of irrelevant:

        xoptions:{
          type: Object,
          value:{
            //min: 0,
            maxPadding: 0.05,
            minPadding: 0.05,
            //hendOnTick: false,
            //tickAmount: 10,
            //type: 'datetime',
            //tickPixelInterval: 150,
            //maxZoom: 20 * 1000
          },
          notify:true,
        },

        yoptions:{
          type: Object,
          value:{
            min: -1.0,
            max: 5.5,
            tickAmount: 8,
          },
          notify: true,
        },

        plotOptions:{
          type:Object,
          value:{
                  line: {
                    marker: {
                       enabled: false,
                    }
                 }
               },
        },


here is my plot function:

`
plotdata: function(){

    if ((this.sensor)&&(this.sensor.instance)){
    _this=this
    this.sensor.instance.scale(0,5).on('data', function(){
    if (_this.drawswitch==true){
        _this.tseries.push([_this.pltindex*(_this.freq/1000.0),_this.sensor.instance.value])
        if(_this.pltindex>100){
        _this.tseries.shift()
        }
        if (_this.pltindex%2==0){
        _this.$.hcplot.reRender()
        _this.$.hcplot.setData(_this.tseries)
        }
        _this.pltindex++
      }
    })
   }
  },

`
I would really appreciate any suggestion to have some more control over the real time updates which i would like to be able to manipulate from the gui somehow.

Thanks,

Zoom options

Hi,

I ve got a problem with x axis zoom. When i set data dynamically in the chart and i clicked on the "All" button, after 2-3 minutes the selection in the zoom time panel decreases step by step.

Do you have a solution?
Thanks

Overriding default Highcharts options

Overriding default options seems counterintuitive.

Consider people moving from using Highcharts directly to using this element. They will copy-paste their configuration and expect the chart to look the same, since it is the same configuration. However, they will now have to hunt down the options that have been overwritten, both in the documentation of this element (to find out what has been overwritten) and in Highcharts' documentation, to figure out what was the original default value.

This also make it difficult for people which are already familiar with the Highcharts API, since they are familiar with the default values, and will have to go through the same process.

A really unintuitive example is the legend: it is vertical by default, in contrast to horizontal in Highcharts. Setting legend-position to { align: 'center', verticalAlign: 'bottom', layout: 'horizontal' } is not enough, since we also have to set legend-pos to { x: 0, y: 0 }.

Problems using dom-repeat with highcharts

Hey there,

i've an issue when trying to render highcharts inside a // .

It doesn't render the chart at all (not to mention that it doesn't get the items inside the data-attribute).

Snippet:

<div class="card card--1-5 text-center animated fadeInUp">
    <div class="card__chart">
        <highcharts-chart
                index$="[[index]]"
                id$="[[index]]"
                style="min-height: auto;"
                type='pie'
                tooltip-options='{"enabled":false}'
                color-by-point='true'
                highchart-options='{"chart":{"height":"150px"},"plotOptions":{"pie":{"colors":["#2f84e5","#f5f8fb"],"dataLabels":{"enabled":false},"innerSize":"80%","center":["50%","50%"]}}}'
                chart-options='{"backgroundColor": null}'
                data='[50,50]'
                title=''>
        </highcharts-chart>
    </div>
</div>                                

Do you have any idea how to debug this one or fix it?
It works fine when it's not inside another template-tag..

xAxis not doing anything.

Hello,
This is a dull question but I have been trying to make the xAxis option to work (just adding a vertical line to a line chart) without success so far.

I am really stuck with this and I will appreciate any help. The plot is fine, it just dont show the vertical marker at all.

Thanks.

Install Highcharts locally

Use case: After doing bower install, it is common to expect that everything that is needed to run the application is installed in bower_components.

Behavior: Highcharts is loaded directly from their website.

Expected behavior: Should be installed via bower.

How do you feel about this? I could do a pull request if it's alright with you.

xAxis and yAxis attributes not having effect on chart.

I am trying to use multiple yAxes for my chart. Usually in high charts I would use an array with multiple yAxis objects inside. In your docs it looks like that attribute is not meant for arrays.

I have my chart set up like this:

<highcharts-chart type="spline" data='{{chartData.series}}' title='Test' xAxis='{{chartData.xAxis}}' yAxis='{{chartData.yAxis}}'></highcharts-chart>

And my chartData object:

chartData = { series: [{}], xAxis: {title: {text: "X Axis"} }, yAxis: [ {title: {text: "Y Axis 1"} }, {title: {text: "Y Axis 2"}, opposite: true } ] }
I do not see an xAxis or yAxis title.

I tried using the same code on the demo of your webcomponents page (here's a screenshot), but it didn't seem to work there either.

Can you tell me if I'm doing something wrong or if this is a bug?

Great job on the web component by the way!

Thanks!

Multiple Series Data

How to use multiple series data? I tried to use the addSeries function but it wouldn't recognize it.
Also, what dependencies have to be added if RequireJS is being used?

Angular?

It's possible to use in angular 4 app?

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.