├── .gitignore ├── .npmignore ├── samples ├── assets │ ├── images │ │ ├── 1074.png │ │ ├── sky.jpg │ │ ├── 306013.png │ │ ├── 465753.png │ │ ├── 971659.png │ │ ├── clock.png │ │ ├── towels.jpg │ │ ├── 1101098.png │ │ ├── 2182392.png │ │ ├── abstract.jpg │ │ ├── pattern.jpg │ │ ├── ripples.png │ │ ├── stripes.jpg │ │ ├── stripes1.jpg │ │ ├── dot-pattern.jpg │ │ ├── decor-3379065_640.jpg │ │ ├── painting-3395289_640.jpg │ │ ├── 2979121308_59539a3898_z.jpg │ │ ├── 3262952695_0ce7340142_z.jpg │ │ ├── 4274635880_809a4b9d0d_z.jpg │ │ ├── 4679113782_ca13e2e6c0_z.jpg │ │ └── 5135522824_f0d4f9da2f_z.jpg │ └── styles.css ├── pie │ ├── simple-pie.html │ ├── simple-donut.html │ ├── gradient-donut.html │ ├── monochrome-pie.html │ ├── pie-with-image.html │ └── donut-with-pattern.html ├── radialBar │ ├── circle-chart.html │ ├── circle-chart-multiple.html │ ├── circle-chart-with-image.html │ ├── stroked-gauge.html │ ├── semi-circle-chart.html │ └── circle-custom-angle.html ├── bar │ ├── basic-bar.html │ ├── grouped-bar.html │ ├── stacked-bar-100.html │ ├── bar-with-custom-data-labels.html │ ├── bar-with-images.html │ ├── stacked-bar.html │ ├── bar-with-negative.html │ └── patterned-bar.html ├── area │ ├── area-spline.html │ ├── basic-area.html │ ├── stacked-area.html │ ├── timeseries-with-irregular-data.html │ ├── area-github-style.html │ └── area-datetime.html ├── line │ ├── line-with-missing-data.html │ ├── basic-line.html │ ├── realtime.html │ ├── zoomable-timeseries.html │ ├── dashed-line.html │ ├── line-with-data-labels.html │ ├── gradient-line.html │ ├── line-with-image.html │ ├── line-with-annotations.html │ ├── z-annotations-example.html │ └── syncing-charts.html ├── mixed │ ├── line-column.html │ ├── line-area.html │ ├── line-column-area.html │ └── multiple-yaxes.html ├── column │ ├── distributed-columns.html │ ├── stacked-column-100.html │ ├── stacked-column.html │ ├── basic-column.html │ ├── data.js │ ├── column-with-rotated-labels.html │ ├── histogram.html │ ├── column-with-negative.html │ └── column-with-data-labels.html ├── scatter │ ├── scatter-basic.html │ └── scatter-datetime.html ├── bubble │ ├── simple-bubble.html │ └── 3d-bubble.html └── heatmap │ ├── basic.html │ ├── multiple.html │ ├── rounded.html │ └── color-range.html ├── .eslintrc.js ├── src ├── assets │ ├── ico-home.svg │ ├── ico-select1.svg │ ├── ico-pan.svg │ ├── ico-reset.svg │ ├── ico-plus-square.svg │ ├── ico-minus.svg │ ├── ico-zoom.svg │ ├── ico-plus.svg │ ├── ico-camera.svg │ ├── ico-refresh.svg │ ├── ico-select.svg │ ├── ico-minus-square.svg │ ├── ico-zoom-in.svg │ ├── ico-zoom-out.svg │ └── ico-pan-hand.svg └── modules │ ├── Base.js │ ├── Title.js │ ├── Exports.js │ ├── SubTitle.js │ ├── Formatters.js │ ├── Crosshairs.js │ ├── tooltip │ └── Marker.js │ ├── Animations.js │ ├── Markers.js │ └── Theme.js ├── CHANGELOG.md ├── LICENSE ├── webpack.config.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | samples/ -------------------------------------------------------------------------------- /samples/assets/images/1074.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/1074.png -------------------------------------------------------------------------------- /samples/assets/images/sky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/sky.jpg -------------------------------------------------------------------------------- /samples/assets/images/306013.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/306013.png -------------------------------------------------------------------------------- /samples/assets/images/465753.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/465753.png -------------------------------------------------------------------------------- /samples/assets/images/971659.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/971659.png -------------------------------------------------------------------------------- /samples/assets/images/clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/clock.png -------------------------------------------------------------------------------- /samples/assets/images/towels.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/towels.jpg -------------------------------------------------------------------------------- /samples/assets/images/1101098.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/1101098.png -------------------------------------------------------------------------------- /samples/assets/images/2182392.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/2182392.png -------------------------------------------------------------------------------- /samples/assets/images/abstract.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/abstract.jpg -------------------------------------------------------------------------------- /samples/assets/images/pattern.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/pattern.jpg -------------------------------------------------------------------------------- /samples/assets/images/ripples.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/ripples.png -------------------------------------------------------------------------------- /samples/assets/images/stripes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/stripes.jpg -------------------------------------------------------------------------------- /samples/assets/images/stripes1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/stripes1.jpg -------------------------------------------------------------------------------- /samples/assets/images/dot-pattern.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/dot-pattern.jpg -------------------------------------------------------------------------------- /samples/assets/images/decor-3379065_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/decor-3379065_640.jpg -------------------------------------------------------------------------------- /samples/assets/images/painting-3395289_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/painting-3395289_640.jpg -------------------------------------------------------------------------------- /samples/assets/images/2979121308_59539a3898_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/2979121308_59539a3898_z.jpg -------------------------------------------------------------------------------- /samples/assets/images/3262952695_0ce7340142_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/3262952695_0ce7340142_z.jpg -------------------------------------------------------------------------------- /samples/assets/images/4274635880_809a4b9d0d_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/4274635880_809a4b9d0d_z.jpg -------------------------------------------------------------------------------- /samples/assets/images/4679113782_ca13e2e6c0_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/4679113782_ca13e2e6c0_z.jpg -------------------------------------------------------------------------------- /samples/assets/images/5135522824_f0d4f9da2f_z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chinanf-boy/apexcharts.js/master/samples/assets/images/5135522824_f0d4f9da2f_z.jpg -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "extends": "standard", 3 | "globals": { 4 | "Blob": true, 5 | "URL": true, 6 | "Apex": true, 7 | "screen": true 8 | } 9 | }; -------------------------------------------------------------------------------- /src/assets/ico-home.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/ico-select1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/assets/ico-pan.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/ico-reset.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/ico-plus-square.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/assets/ico-minus.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/assets/ico-zoom.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/ico-plus.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/assets/ico-camera.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/assets/ico-refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The document follows the conventions described in [“Keep a CHANGELOG”](http://keepachangelog.com). 6 | 7 | ==== 8 | 9 | 10 | ## [v1.0.2] - 2018-28-07 11 | 12 | ### Fixed 13 | - Added polyfill for certain es6 features (promise, includes, etc) as IE11 doesn't support them and the chart was failing to render in IE11 because of this. 14 | -------------------------------------------------------------------------------- /src/assets/ico-select.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/ico-minus-square.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/assets/ico-zoom-in.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/modules/Base.js: -------------------------------------------------------------------------------- 1 | import Config from './settings/Config' 2 | import Globals from './settings/Globals' 3 | 4 | /** 5 | * ApexCharts Base Class for extending user options with pre-defined ApexCharts config. 6 | * 7 | * @module Base 8 | **/ 9 | class Base { 10 | constructor (opts) { 11 | this.opts = opts 12 | } 13 | 14 | init () { 15 | const config = new Config(this.opts).init() 16 | const globals = new Globals().init(config) 17 | 18 | const w = { 19 | config, 20 | globals 21 | } 22 | 23 | return w 24 | } 25 | } 26 | 27 | module.exports = Base 28 | -------------------------------------------------------------------------------- /src/assets/ico-zoom-out.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/assets/ico-pan-hand.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/pie/simple-pie.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Simple Pie 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /samples/pie/simple-donut.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Simple Donut 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 ApexCharts 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/modules/Title.js: -------------------------------------------------------------------------------- 1 | import Graphics from './Graphics' 2 | 3 | export default class Title { 4 | constructor (ctx) { 5 | this.ctx = ctx 6 | this.w = ctx.w 7 | } 8 | 9 | drawTitle () { 10 | let w = this.w 11 | 12 | let x = w.globals.svgWidth / 2 13 | let y = w.config.title.offsetY 14 | let textAnchor = 'middle' 15 | 16 | if (w.config.title.align === 'left') { 17 | x = 10 18 | textAnchor = 'start' 19 | } else if (w.config.title.align === 'right') { 20 | x = w.globals.svgWidth - 10 21 | textAnchor = 'end' 22 | } 23 | 24 | x = x + w.config.title.offsetX 25 | y = y + parseInt(w.config.title.style.fontSize) + 2 26 | 27 | if (w.config.title.text !== undefined) { 28 | let graphics = new Graphics(this.ctx) 29 | let titleText = graphics.drawText({ 30 | x: x, 31 | y: y, 32 | text: w.config.title.text, 33 | textAnchor: textAnchor, 34 | fontSize: w.config.title.style.fontSize, 35 | foreColor: w.config.title.style.foreColor, 36 | opacity: 1 37 | }) 38 | 39 | titleText.node.setAttribute('class', 'apexcharts-title-text') 40 | 41 | w.globals.dom.Paper.add(titleText) 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /samples/pie/gradient-donut.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Gradient Donut 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/modules/Exports.js: -------------------------------------------------------------------------------- 1 | 2 | class Exports { 3 | constructor (ctx) { 4 | this.ctx = ctx 5 | this.w = ctx.w 6 | } 7 | 8 | getSvgString () { 9 | return this.w.globals.dom.Paper.svg() 10 | } 11 | 12 | exportToSVG () { 13 | const w = this.w 14 | 15 | // hide some elements to avoid printing them on exported svg 16 | const xcrosshairs = w.globals.dom.baseEl.querySelector( 17 | '.apexcharts-xcrosshairs' 18 | ) 19 | const ycrosshairs = w.globals.dom.baseEl.querySelector( 20 | '.apexcharts-ycrosshairs' 21 | ) 22 | if (xcrosshairs) { 23 | xcrosshairs.setAttribute('x', -500) 24 | } 25 | if (ycrosshairs) { 26 | ycrosshairs.setAttribute('y1', -100) 27 | ycrosshairs.setAttribute('y2', -100) 28 | } 29 | 30 | const svgData = this.getSvgString() 31 | const svgBlob = new Blob([svgData], {type: 'image/svg+xml;charset=utf-8'}) 32 | const svgUrl = URL.createObjectURL(svgBlob) 33 | const downloadLink = document.createElement('a') 34 | downloadLink.href = svgUrl 35 | downloadLink.download = 'apexcharts-' + w.globals.cuid + '.svg' 36 | document.body.appendChild(downloadLink) 37 | downloadLink.click() 38 | document.body.removeChild(downloadLink) 39 | } 40 | } 41 | 42 | export default Exports 43 | -------------------------------------------------------------------------------- /src/modules/SubTitle.js: -------------------------------------------------------------------------------- 1 | import Graphics from './Graphics' 2 | 3 | export default class SubTitle { 4 | constructor (ctx) { 5 | this.ctx = ctx 6 | this.w = ctx.w 7 | } 8 | 9 | drawSubtitle () { 10 | let w = this.w 11 | 12 | let x = w.globals.svgWidth / 2 13 | let y = w.config.subtitle.offsetY 14 | let textAnchor = 'middle' 15 | 16 | if (w.config.subtitle.align === 'left') { 17 | x = 10 18 | textAnchor = 'start' 19 | } else if (w.config.subtitle.align === 'right') { 20 | x = w.globals.svgWidth - 10 21 | textAnchor = 'end' 22 | } 23 | 24 | x = x + w.config.subtitle.offsetX 25 | y = y + parseInt(w.config.subtitle.style.fontSize) + parseInt(w.config.title.style.fontSize) + 10 26 | 27 | if (w.config.subtitle.text !== undefined) { 28 | let graphics = new Graphics(this.ctx) 29 | let subtitleText = graphics.drawText({ 30 | x: x, 31 | y: y, 32 | text: w.config.subtitle.text, 33 | textAnchor: textAnchor, 34 | fontSize: w.config.subtitle.style.fontSize, 35 | foreColor: w.config.subtitle.style.color, 36 | opacity: 1 37 | }) 38 | 39 | subtitleText.attr('class', 'apexcharts-subtitle-text') 40 | 41 | w.globals.dom.Paper.add(subtitleText) 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /samples/radialBar/circle-chart.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Circle Gauge Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /samples/pie/monochrome-pie.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Monochrome Pie 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /samples/radialBar/circle-chart-multiple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Circle Gauge Chart - Multiple 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /samples/assets/styles.css: -------------------------------------------------------------------------------- 1 | /*@import url('https://fonts.googleapis.com/css?family=Lato:300,400,600,700');*/ 2 | 3 | * { 4 | font-family: Arial; 5 | } 6 | 7 | body { 8 | height: 100vh; 9 | background: #f9f9f9; 10 | } 11 | 12 | #chart, .chart-box { 13 | padding-top: 20px; 14 | padding-left: 10px; 15 | background: #fff; 16 | border: 1px solid #ddd; 17 | box-shadow: 0 22px 35px -16px rgba(0,0,0, 0.1); 18 | } 19 | 20 | select.flat-select { 21 | -moz-appearance: none; 22 | -webkit-appearance: none; 23 | appearance: none; 24 | background: #008FFB url("data:image/svg+xml;utf8,") no-repeat scroll right 2px top 9px / 16px 16px; 25 | border: 0 none; 26 | border-radius: 3px; 27 | color: #fff; 28 | font-family: arial,tahoma; 29 | font-size: 16px; 30 | font-weight: bold; 31 | outline: 0 none; 32 | height: 33px; 33 | padding: 5px 20px 5px 10px; 34 | text-align: center; 35 | text-indent: 0.01px; 36 | text-overflow: ""; 37 | text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); 38 | transition: all 0.3s ease 0s; 39 | width: auto; 40 | -webkit-transition: 0.3s ease all; 41 | -moz-transition: 0.3s ease all; 42 | -ms-transition: 0.3s ease all; 43 | -o-transition: 0.3s ease all; 44 | transition: 0.3s ease all; 45 | } 46 | select.flat-select:focus, select.flat-select:hover { 47 | border: 0; 48 | outline: 0; 49 | } 50 | 51 | 52 | .apexcharts-canvas { 53 | margin: 0 auto; 54 | } -------------------------------------------------------------------------------- /samples/bar/basic-bar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Basic Bar Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /samples/pie/pie-with-image.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Pie with Image 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /samples/area/area-spline.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Area Spline 9 | 10 | 11 | 12 | 18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 | 26 | 27 | 28 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /samples/line/line-with-missing-data.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Line Chart with missing data 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var webpack = require('webpack'); 2 | var path = require('path'); 3 | 4 | module.exports = { 5 | entry: ['core-js/fn/promise','core-js/fn/array/includes', path.resolve(__dirname, 'src/apexcharts.js')], 6 | output: { 7 | library: 'ApexCharts', 8 | libraryTarget: 'umd', 9 | umdNamedDefine: true, 10 | path: path.resolve(__dirname, 'dist/'), 11 | filename: 'apexcharts.min.js' , 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.(js)$/, 17 | enforce: 'pre', 18 | exclude: [/node_modules/, path.resolve(__dirname, 'src/utils/ClassListPolyfill.js'), path.resolve(__dirname, 'src/utils/Utils.js')], 19 | include: path.resolve(__dirname, 'src/'), 20 | use: [ 21 | { 22 | options: { 23 | fix: true, 24 | eslintPath: require.resolve('eslint'), 25 | parser: require.resolve('babel-eslint'), 26 | }, 27 | loader: require.resolve('eslint-loader'), 28 | }, 29 | ], 30 | }, 31 | { 32 | test: /\.js?$/, 33 | loader:'babel-loader', 34 | options: { 35 | presets: ['es2015', 'stage-0'], 36 | plugins: [ 37 | 'transform-class-properties', 38 | 'transform-decorators-legacy' 39 | ] 40 | } 41 | }, 42 | 43 | { 44 | test: /\.css$/, 45 | use: [ 'style-loader', 'css-loader' ] 46 | }, 47 | { 48 | test: /\.svg$/, 49 | loader: 'svg-inline-loader' 50 | } 51 | ], 52 | 53 | }, 54 | watchOptions: { 55 | poll: true 56 | }, 57 | resolve: { 58 | modules: [ 59 | __dirname, 60 | "src", 61 | "node_modules" 62 | ], 63 | 64 | extensions: ['.js', '.json'] 65 | }, 66 | }; 67 | -------------------------------------------------------------------------------- /samples/mixed/line-column.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Line, Column & Area 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /samples/bar/grouped-bar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Grouped Bar Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /samples/area/basic-area.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Basic Area 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /samples/line/basic-line.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Basic Line Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "apexcharts", 3 | "description": "A JavaScript Chart Library", 4 | "version": "1.1.0", 5 | "main": "dist/apexcharts.min.js", 6 | "directories": { 7 | "test": "tests" 8 | }, 9 | "scripts": { 10 | "start": "webpack --watch", 11 | "build": "webpack -p", 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "dependencies": { 15 | "core-js": "^2.5.7", 16 | "es6-promise-promise": "^1.0.0", 17 | "svg.draggable.js": "^2.2.1", 18 | "svg.easing.js": "^2.0.0", 19 | "svg.filter.js": "^2.0.2", 20 | "svg.js": "^2.6.5", 21 | "svg.pathmorphing.js": "^0.1.3", 22 | "svg.resize.js": "^1.4.1", 23 | "svg.select.js": "^2.1.2" 24 | }, 25 | "devDependencies": { 26 | "babel-core": "^6.9.0", 27 | "babel-eslint": "^8.2.2", 28 | "babel-loader": "^6.2.4", 29 | "babel-plugin-add-module-exports": "^0.2.1", 30 | "babel-plugin-transform-class-properties": "^6.9.0", 31 | "babel-plugin-transform-decorators-legacy": "^1.3.4", 32 | "babel-preset-es2015": "^6.9.0", 33 | "babel-preset-stage-0": "^6.5.0", 34 | "concurrently": "^3.5.1", 35 | "css-loader": "^0.28.10", 36 | "eslint": "^4.18.1", 37 | "eslint-config-airbnb": "^16.1.0", 38 | "eslint-config-airbnb-base": "^12.1.0", 39 | "eslint-config-standard": "^11.0.0", 40 | "eslint-loader": "^2.0.0", 41 | "eslint-plugin-import": "^2.9.0", 42 | "eslint-plugin-node": "^6.0.1", 43 | "eslint-plugin-promise": "^3.6.0", 44 | "eslint-plugin-standard": "^3.0.1", 45 | "imports-loader": "^0.7.1", 46 | "style-loader": "^0.20.2", 47 | "svg-inline-loader": "^0.8.0", 48 | "webpack": "^2.2.1" 49 | }, 50 | "author": { 51 | "name": "Juned Chhipa", 52 | "email": "juned.chhipa@gmail.com" 53 | }, 54 | "bugs": { 55 | "url": "https://github.com/apexcharts/apexcharts.js/issues" 56 | }, 57 | "license": "MIT", 58 | "licenses": [ 59 | { 60 | "type": "MIT", 61 | "url": "http://www.opensource.org/licenses/mit-license.php" 62 | } 63 | ], 64 | "keywords": [ 65 | "charts", 66 | "graphs", 67 | "visualizations", 68 | "data" 69 | ] 70 | } 71 | -------------------------------------------------------------------------------- /samples/column/distributed-columns.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Distributed Bar 9 | 10 | 11 | 12 | 13 | 22 | 23 | 24 | 25 |
26 | 27 |
28 | 29 | 30 | 31 | 32 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /samples/mixed/line-area.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Line, Column & Area 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /samples/radialBar/circle-chart-with-image.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Circle Gauge Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /samples/column/stacked-column-100.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Stacked Column 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /samples/pie/donut-with-pattern.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Donut Chart with pattern 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /samples/column/stacked-column.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Stacked Column 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /samples/line/realtime.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Dynamic Updating Line Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /samples/radialBar/stroked-gauge.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Stroked Gauge 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /samples/column/basic-column.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Basic Column - Grouped 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /samples/mixed/line-column-area.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Line, Column & Area 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/modules/Formatters.js: -------------------------------------------------------------------------------- 1 | import DateTime from '../utils/DateTime' 2 | import Utils from '../utils/Utils' 3 | 4 | /** 5 | * ApexCharts Formatter Class for setting value formatters for axes as well as tooltips. 6 | * 7 | * @module Formatters 8 | **/ 9 | 10 | class Formatters { 11 | constructor (ctx) { 12 | this.ctx = ctx 13 | this.w = ctx.w 14 | this.tooltipKeyFormat = 'dd MMM' 15 | } 16 | 17 | // xLabelFormat is the formatter function which is used 18 | xLabelFormat (fn, val) { 19 | let w = this.w 20 | 21 | // if datetime series 22 | if (w.config.xaxis.type === 'datetime') { 23 | // if user has not specified a custom formatter, use the 24 | if (w.config.tooltip.x.formatter === undefined) { 25 | let datetimeObj = new DateTime(this.ctx) 26 | return datetimeObj.formatDate(new Date(val), w.config.tooltip.x.format) 27 | } 28 | } 29 | 30 | return fn(val) 31 | } 32 | 33 | setLabelFormatters () { 34 | let w = this.w 35 | 36 | w.globals.xLabelFormatter = function (val, opts) { 37 | return val 38 | } 39 | 40 | // this is commented for now, can be give as a customization to user later 41 | // w.globals.xaxisTooltipLabelFormatter = function (val) { 42 | // return val 43 | // } 44 | 45 | w.globals.ttKeyFormatter = function (val, opts) { 46 | return val 47 | } 48 | 49 | w.globals.ttZFormatter = function (val, opts) { 50 | return val 51 | } 52 | 53 | w.globals.legendFormatter = function (val, opts) { 54 | return val 55 | } 56 | 57 | if (w.config.tooltip.x.formatter !== undefined) { 58 | w.globals.ttKeyFormatter = w.config.tooltip.x.formatter 59 | } 60 | 61 | if (w.config.tooltip.y.formatter !== undefined) { 62 | w.globals.ttValFormatter = w.config.tooltip.y.formatter 63 | } 64 | 65 | if (w.config.tooltip.z.formatter !== undefined) { 66 | w.globals.ttZFormatter = w.config.tooltip.z.formatter 67 | } 68 | 69 | // legend formatter - if user wants to append any global values of series to legend text 70 | if (w.config.legend.formatter !== undefined) { 71 | w.globals.legendFormatter = w.config.legend.formatter 72 | } 73 | 74 | // formatter function will always overwrite format property 75 | if (w.config.xaxis.labels.formatter !== undefined) { 76 | w.globals.xLabelFormatter = w.config.xaxis.labels.formatter 77 | } else { 78 | w.globals.xLabelFormatter = function (val, opts) { 79 | if (Utils.isInt(val)) { 80 | return val.toFixed(0) 81 | } 82 | return val 83 | } 84 | } 85 | } 86 | } 87 | 88 | export default Formatters 89 | -------------------------------------------------------------------------------- /samples/radialBar/semi-circle-chart.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Semi Circle Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /samples/column/data.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Randomize array element order in-place. 3 | * Using Durstenfeld shuffle algorithm. 4 | */ 5 | function shuffleArray(array) { 6 | for (var i = array.length - 1; i > 0; i--) { 7 | var j = Math.floor(Math.random() * (i + 1)); 8 | var temp = array[i]; 9 | array[i] = array[j]; 10 | array[j] = temp; 11 | } 12 | return array; 13 | } 14 | 15 | var arrayData = [{ 16 | y: 400, 17 | quarters: [{ 18 | x: 'Q1', 19 | y: 120 20 | }, { 21 | x: 'Q2', 22 | y: 90 23 | }, { 24 | x: 'Q3', 25 | y: 100 26 | }, { 27 | x: 'Q4', 28 | y: 90 29 | }] 30 | }, { 31 | y: 430, 32 | quarters: [{ 33 | x: 'Q1', 34 | y: 120 35 | }, { 36 | x: 'Q2', 37 | y: 110 38 | }, { 39 | x: 'Q3', 40 | y: 90 41 | }, { 42 | x: 'Q4', 43 | y: 110 44 | }] 45 | }, { 46 | y: 448, 47 | quarters: [{ 48 | x: 'Q1', 49 | y: 70 50 | }, { 51 | x: 'Q2', 52 | y: 100 53 | }, { 54 | x: 'Q3', 55 | y: 140 56 | }, { 57 | x: 'Q4', 58 | y: 138 59 | }] 60 | }, { 61 | y: 470, 62 | quarters: [{ 63 | x: 'Q1', 64 | y: 150 65 | }, { 66 | x: 'Q2', 67 | y: 60 68 | }, { 69 | x: 'Q3', 70 | y: 190 71 | }, { 72 | x: 'Q4', 73 | y: 70 74 | }] 75 | }, { 76 | y: 540, 77 | quarters: [{ 78 | x: 'Q1', 79 | y: 120 80 | }, { 81 | x: 'Q2', 82 | y: 120 83 | }, { 84 | x: 'Q3', 85 | y: 130 86 | }, { 87 | x: 'Q4', 88 | y: 170 89 | }] 90 | }, { 91 | y: 580, 92 | quarters: [{ 93 | x: 'Q1', 94 | y: 170 95 | }, { 96 | x: 'Q2', 97 | y: 130 98 | }, { 99 | x: 'Q3', 100 | y: 120 101 | }, { 102 | x: 'Q4', 103 | y: 160 104 | }] 105 | }]; 106 | 107 | function makeData() { 108 | var dataSet = shuffleArray(arrayData) 109 | 110 | var dataYearSeries = [{ 111 | x: "2011", 112 | y: dataSet[0].y, 113 | color: colors[0], 114 | quarters: dataSet[0].quarters 115 | }, { 116 | x: "2012", 117 | y: dataSet[1].y, 118 | color: colors[1], 119 | quarters: dataSet[1].quarters 120 | }, { 121 | x: "2013", 122 | y: dataSet[2].y, 123 | color: colors[2], 124 | quarters: dataSet[2].quarters 125 | }, { 126 | x: "2014", 127 | y: dataSet[3].y, 128 | color: colors[3], 129 | quarters: dataSet[3].quarters 130 | }, { 131 | x: "2015", 132 | y: dataSet[4].y, 133 | color: colors[4], 134 | quarters: dataSet[4].quarters 135 | }, { 136 | x: "2016", 137 | y: dataSet[5].y, 138 | color: colors[5], 139 | quarters: dataSet[5].quarters 140 | }]; 141 | 142 | return dataYearSeries 143 | } -------------------------------------------------------------------------------- /samples/bar/stacked-bar-100.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Stacked Bar Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /samples/scatter/scatter-basic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Scatter Chart 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | 30 | 31 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /samples/column/column-with-rotated-labels.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Column with Rotates Labels 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /samples/line/zoomable-timeseries.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Zoomable TimeSeries 10 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /samples/line/dashed-line.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Dashed Line Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /samples/bar/bar-with-custom-data-labels.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Basic Bar Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /samples/bar/bar-with-images.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Bar Chart with Images 9 | 10 | 11 | 12 | 13 | 23 | 24 | 25 | 26 |
27 | 28 |
29 | 30 | 31 | 32 | 33 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /samples/bar/stacked-bar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Stacked Bar Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /samples/radialBar/circle-custom-angle.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Circle Custom Angle 9 | 10 | 11 | 12 | 13 | 23 | 24 | 25 | 26 |
27 | 28 |
29 | 30 | 31 | 32 | 33 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /samples/area/stacked-area.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Stacked Area 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /samples/scatter/scatter-datetime.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Timeline Scatter Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /samples/line/line-with-data-labels.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Line with Data Labels 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /samples/line/gradient-line.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Gradient Line 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /samples/column/histogram.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Time Series 9 | 10 | 11 | 12 | 13 | 24 | 25 | 26 | 27 | 28 |
29 |
30 | Selected: 0 31 |
32 | 33 | 34 | 35 | 36 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /samples/bar/bar-with-negative.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Stacked Bar Chart with Negative Values 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /src/modules/Crosshairs.js: -------------------------------------------------------------------------------- 1 | import Graphics from './Graphics' 2 | import Filters from './Filters' 3 | 4 | class Crosshairs { 5 | constructor (ctx) { 6 | this.ctx = ctx 7 | this.w = ctx.w 8 | } 9 | 10 | drawXCrosshairs () { 11 | const w = this.w 12 | 13 | let graphics = new Graphics(this.ctx) 14 | let filters = new Filters(this.ctx) 15 | 16 | let crosshairGradient = w.config.xaxis.crosshairs.fill.gradient 17 | let crosshairShadow = w.config.xaxis.crosshairs.dropShadow 18 | 19 | let fillType = w.config.xaxis.crosshairs.fill.type 20 | let gradientFrom = crosshairGradient.colorFrom 21 | let gradientTo = crosshairGradient.colorTo 22 | let opacityFrom = crosshairGradient.opacityFrom 23 | let opacityTo = crosshairGradient.opacityTo 24 | let stops = crosshairGradient.stops 25 | 26 | let shadow = 'none' 27 | let dropShadow = crosshairShadow.enabled 28 | let shadowLeft = crosshairShadow.left 29 | let shadowTop = crosshairShadow.top 30 | let shadowBlur = crosshairShadow.blur 31 | let shadowOpacity = crosshairShadow.opacity 32 | 33 | let xcrosshairsFill = w.config.xaxis.crosshairs.fill.color 34 | 35 | if (w.config.xaxis.crosshairs.show) { 36 | if (fillType === 'gradient') { 37 | xcrosshairsFill = graphics.drawGradient( 38 | 'vertical', 39 | gradientFrom, 40 | gradientTo, 41 | opacityFrom, 42 | opacityTo, 43 | null, 44 | stops 45 | ) 46 | } 47 | 48 | let xcrosshairs = graphics.drawRect() 49 | xcrosshairs.attr({ 50 | class: 'apexcharts-xcrosshairs', 51 | x: 0, 52 | y: 0, 53 | width: 0, 54 | height: w.globals.gridHeight, 55 | fill: xcrosshairsFill, 56 | filter: shadow, 57 | 'fill-opacity': w.config.xaxis.crosshairs.opacity, 58 | 'stroke': w.config.xaxis.crosshairs.stroke.color, 59 | 'stroke-width': w.config.xaxis.crosshairs.stroke.width, 60 | 'stroke-dasharray': w.config.xaxis.crosshairs.stroke.dashArray 61 | }) 62 | 63 | if (dropShadow) { 64 | xcrosshairs = filters.dropShadow(xcrosshairs, { 65 | left: shadowLeft, 66 | top: shadowTop, 67 | blur: shadowBlur, 68 | opacity: shadowOpacity 69 | }) 70 | } 71 | 72 | w.globals.dom.elGraphical.add(xcrosshairs) 73 | } 74 | } 75 | 76 | drawYCrosshairs () { 77 | const w = this.w 78 | 79 | let graphics = new Graphics(this.ctx) 80 | 81 | let crosshair = w.config.yaxis[0].crosshairs 82 | 83 | if (w.config.yaxis[0].crosshairs.show) { 84 | let ycrosshairs = graphics.drawLine(0, 0, w.globals.gridWidth, 0, crosshair.stroke.color, crosshair.stroke.dashArray, crosshair.stroke.width) 85 | ycrosshairs.attr({ 86 | class: 'apexcharts-ycrosshairs' 87 | }) 88 | 89 | w.globals.dom.elGraphical.add(ycrosshairs) 90 | } 91 | 92 | // draw an invisible crosshair to help in positioning the yaxis tooltip 93 | let ycrosshairsHidden = graphics.drawLine(0, 0, w.globals.gridWidth, 0, crosshair.stroke.color, 0, 0) 94 | ycrosshairsHidden.attr({ 95 | class: 'apexcharts-ycrosshairs-hidden' 96 | }) 97 | 98 | w.globals.dom.elGraphical.add(ycrosshairsHidden) 99 | } 100 | } 101 | 102 | export default Crosshairs 103 | -------------------------------------------------------------------------------- /samples/bar/patterned-bar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Bar Chart with Pattern Fill 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /samples/line/line-with-image.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Line with Image Fill 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /samples/column/column-with-negative.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Basic Bar 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /samples/mixed/multiple-yaxes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Multiple Y Axis Chart 9 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | 23 |
24 | 25 |
26 | 27 |
28 | 29 |
30 | 31 | 32 | 33 | 34 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /samples/bubble/simple-bubble.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Simple Bubble 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /samples/bubble/3d-bubble.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 3d Bubble Chart 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /samples/area/timeseries-with-irregular-data.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | TimeSeries With Irregular Data 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /samples/line/line-with-annotations.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Line Chart with Annotations 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /samples/line/z-annotations-example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Line Chart with Annotations 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /samples/column/column-with-data-labels.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Column with Data Labels 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /samples/heatmap/basic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Simple HeatMap 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /samples/heatmap/multiple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Simple HeatMap 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /src/modules/tooltip/Marker.js: -------------------------------------------------------------------------------- 1 | import Graphics from '../Graphics' 2 | import Position from './Position' 3 | import Markers from '../../modules/Markers' 4 | 5 | /** 6 | * ApexCharts Tooltip.Marker Class to draw texts on the tooltip. 7 | * 8 | * @module Tooltip.Marker 9 | **/ 10 | 11 | class Marker { 12 | constructor (tooltipContext) { 13 | this.w = tooltipContext.w 14 | this.ttCtx = tooltipContext 15 | this.ctx = tooltipContext.ctx 16 | this.tooltipPosition = new Position(tooltipContext) 17 | } 18 | 19 | drawDynamicPoints () { 20 | const ttCtx = this.ttCtx 21 | let w = this.w 22 | 23 | let graphics = new Graphics(this.ctx) 24 | let marker = new Markers(this.ctx) 25 | 26 | let elsSeries = w.globals.dom.baseEl.querySelectorAll( 27 | '.apexcharts-series' 28 | ) 29 | 30 | for (let i = 0; i < elsSeries.length; i++) { 31 | let seriesIndex = parseInt(elsSeries[i].getAttribute('data:realIndex')) 32 | 33 | let pointsMain = w.globals.dom.baseEl.querySelector( 34 | `.apexcharts-series[data\\:realIndex='${seriesIndex}'] .apexcharts-series-markers-wrap` 35 | ) 36 | 37 | if (pointsMain !== null) { 38 | // it can be null as we have tooltips in donut/bar charts 39 | let point 40 | 41 | let PointClasses = `apexcharts-marker w${(Math.random() + 1).toString(36).substring(4)}` 42 | if (((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts) && !w.config.tooltip.intersect) { 43 | PointClasses += ' no-pointer-events' 44 | } 45 | 46 | let elPointOptions = marker.getMarkerConfig(PointClasses, seriesIndex) 47 | 48 | point = graphics.drawMarker(0, 0, elPointOptions) 49 | 50 | let elPointsG = document.createElementNS(w.globals.svgNS, 'g') 51 | elPointsG.classList.add('apexcharts-series-markers') 52 | 53 | elPointsG.appendChild(point.node) 54 | pointsMain.appendChild(elPointsG) 55 | 56 | ttCtx.allPoints = w.globals.dom.baseEl.querySelectorAll( 57 | '.apexcharts-series-markers .apexcharts-marker' 58 | ) 59 | } 60 | } 61 | } 62 | 63 | enlargeCurrentPoint (rel, point) { 64 | let w = this.w 65 | 66 | if (w.config.chart.type !== 'bubble') { 67 | this.newPointSize(rel, point) 68 | } 69 | 70 | let cx = point.getAttribute('cx') 71 | let cy = point.getAttribute('cy') 72 | 73 | this.tooltipPosition.moveXCrosshairs(cx) 74 | 75 | if (!this.fixedTooltip) { 76 | this.tooltipPosition.moveTooltip( 77 | cx, 78 | cy, 79 | w.config.markers.hover.size 80 | ) 81 | } 82 | } 83 | 84 | enlargePoints (j) { 85 | let w = this.w 86 | let me = this 87 | const ttCtx = this.ttCtx 88 | 89 | let col = j 90 | 91 | let points = w.globals.dom.baseEl.querySelectorAll( 92 | '.apexcharts-marker' 93 | ) 94 | 95 | let newSize = w.config.markers.hover.size 96 | 97 | for (let p = 0; p < points.length; p++) { 98 | let rel = points[p].getAttribute('rel') 99 | 100 | if (col === parseInt(rel)) { 101 | me.newPointSize(col, points[p]) 102 | 103 | let cx = points[p].getAttribute('cx') 104 | let cy = points[p].getAttribute('cy') 105 | 106 | me.tooltipPosition.moveXCrosshairs(cx) 107 | 108 | if (!ttCtx.fixedTooltip) { 109 | me.tooltipPosition.moveTooltip(cx, cy, newSize) 110 | } 111 | } else { 112 | me.oldPointSize(points[p]) 113 | } 114 | } 115 | } 116 | 117 | newPointSize (rel, point) { 118 | let w = this.w 119 | let newSize = w.config.markers.hover.size 120 | let elPoint = null 121 | 122 | if (rel === 0) { 123 | elPoint = point.parentNode.firstChild 124 | } else { 125 | elPoint = point.parentNode.lastChild 126 | } 127 | 128 | elPoint.setAttribute('r', newSize) 129 | // elPoint.style.opacity = w.config.markers.hover.opacity 130 | } 131 | 132 | oldPointSize (point) { 133 | let w = this.w 134 | let currSize = w.config.markers.size 135 | 136 | point.setAttribute('r', currSize) 137 | // point.style.opacity = w.config.markers.opacity 138 | } 139 | 140 | resetPointsSize () { 141 | let w = this.w 142 | 143 | let currSize = w.config.markers.size 144 | 145 | let points = w.globals.dom.baseEl.querySelectorAll( 146 | '.apexcharts-marker' 147 | ) 148 | for (let p = 0; p < points.length; p++) { 149 | points[p].setAttribute('r', currSize) 150 | // points[p].style.opacity = w.config.markers.opacity; 151 | } 152 | } 153 | } 154 | module.exports = Marker 155 | -------------------------------------------------------------------------------- /samples/line/syncing-charts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Syncing charts 10 | 11 | 12 | 13 | 14 | 25 | 26 | 27 | 28 |
29 |
30 | 31 |
32 | 33 |
34 | 35 |
36 |
37 | 38 | 39 | 40 | 41 | 42 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /src/modules/Animations.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ApexCharts Animation Class. 3 | * 4 | * @module Animations 5 | **/ 6 | 7 | class Animations { 8 | constructor (ctx) { 9 | this.ctx = ctx 10 | this.w = ctx.w 11 | 12 | this.setEasingFunctions() 13 | } 14 | 15 | setEasingFunctions () { 16 | let easing = '<>' 17 | 18 | const userDefinedEasing = this.w.config.chart.animations.easing 19 | 20 | switch (userDefinedEasing) { 21 | case 'linear': { 22 | easing = '-' 23 | break 24 | } 25 | case 'easein': { 26 | easing = '<' 27 | break 28 | } 29 | case 'easeout': { 30 | easing = '>' 31 | break 32 | } 33 | case 'easeinout': { 34 | easing = '<>' 35 | break 36 | } 37 | default: { 38 | easing = '<>' 39 | } 40 | } 41 | 42 | this.w.globals.easing = easing 43 | } 44 | 45 | animateLine (el, from, to, speed) { 46 | el.attr(from).animate(speed).attr(to) 47 | } 48 | 49 | /* 50 | ** Animate radius of a circle element 51 | */ 52 | animateCircleRadius (el, from, to, speed) { 53 | if (!from) from = 0 54 | 55 | el.attr( 56 | { 57 | r: from 58 | } 59 | ).animate(speed).attr( 60 | { 61 | r: to 62 | } 63 | ) 64 | } 65 | 66 | /* 67 | ** Animate radius and position of a circle element 68 | */ 69 | animateCircle (el, from, to, speed) { 70 | el.attr( 71 | { 72 | r: from.r, 73 | cx: from.cx, 74 | cy: from.cy 75 | } 76 | ).animate(speed).attr( 77 | { 78 | r: to.r, 79 | cx: to.cx, 80 | cy: to.cy 81 | } 82 | ) 83 | } 84 | 85 | /* 86 | ** Animate rect properties 87 | */ 88 | animateRect (el, from, to, speed) { 89 | el.attr(from).animate(speed).attr(to) 90 | } 91 | 92 | animatePathsGradually (params) { 93 | let { el, pathFrom, pathTo, speed, delay, strokeWidth } = params 94 | 95 | let me = this 96 | let w = this.w 97 | 98 | let delayFactor = 0 99 | 100 | if (w.config.chart.animations.animateGradually.enabled) { 101 | delayFactor = 102 | w.config.chart.animations.animateGradually.delay 103 | } 104 | 105 | if ( 106 | w.config.chart.animations.dynamicAnimation.enabled && 107 | w.globals.dataChanged 108 | ) { 109 | delayFactor = 0 110 | } 111 | 112 | me.morphSVG( 113 | el, 114 | pathFrom, 115 | pathTo, 116 | speed, 117 | strokeWidth, 118 | delay * delayFactor 119 | ) 120 | } 121 | 122 | // SVG.js animation for morphing one path to another 123 | morphSVG ( 124 | el, 125 | pathFrom, 126 | pathTo, 127 | speed, 128 | strokeWidth, 129 | delay 130 | ) { 131 | let w = this.w 132 | 133 | if (!pathFrom) { 134 | pathFrom = el.attr('pathFrom') 135 | } 136 | 137 | if (!pathTo) { 138 | pathTo = el.attr('pathTo') 139 | } 140 | 141 | if (pathFrom.indexOf('undefined') > -1 || pathFrom.indexOf('NaN') > -1) { 142 | pathFrom = `M 0 ${w.globals.gridHeight}` 143 | speed = 1 144 | } 145 | if (pathTo.indexOf('undefined') > -1 || pathTo.indexOf('NaN') > -1) { 146 | pathTo = `M 0 ${w.globals.gridHeight}` 147 | speed = 1 148 | } 149 | 150 | el.plot(pathFrom).animate(1, w.globals.easing, delay).plot(pathFrom).animate(speed, w.globals.easing, delay).plot(pathTo) 151 | } 152 | 153 | /* This function is called when initial animation ends. 154 | ** as we are delaying some elements on axis chart types and showing after initialAnim 155 | */ 156 | showDelayedElements () { 157 | let w = this.w 158 | 159 | let anim = w.config.chart.animations 160 | let speed = anim.speed 161 | let gradualAnimate = anim.animateGradually.enabled 162 | let gradualDelay = anim.animateGradually.delay 163 | 164 | if (anim.enabled && !w.globals.resized) { 165 | for (let i = 0; i < w.globals.series.length; i++) { 166 | let delay = 0 167 | if (gradualAnimate) { 168 | delay = (i + 1) * (gradualDelay / 1000) 169 | } 170 | 171 | for (let z = 0; z < w.globals.delayedElements.length; z++) { 172 | if (w.globals.delayedElements[z].index === i) { 173 | let ele = w.globals.delayedElements[z].el 174 | ele.classList.add('apexcharts-showAfterDelay') 175 | ele.style.animationDelay = (speed / 950) + delay + 's' 176 | } 177 | } 178 | } 179 | } 180 | 181 | if ( 182 | w.config.chart.animations.dynamicAnimation.enabled && 183 | w.globals.dataChanged 184 | ) { 185 | for (let z = 0; z < w.globals.delayedElements.length; z++) { 186 | let ele = w.globals.delayedElements[z].el 187 | ele.classList.add('apexcharts-showAfterDelay') 188 | ele.style.animationDelay = 189 | w.config.chart.animations.dynamicAnimation.speed / 950 + 's' 190 | } 191 | } 192 | } 193 | } 194 | 195 | module.exports = Animations 196 | -------------------------------------------------------------------------------- /src/modules/Markers.js: -------------------------------------------------------------------------------- 1 | import Filters from './Filters' 2 | import Graphics from './Graphics' 3 | 4 | /** 5 | * ApexCharts Markers Class for drawing points on y values in axes charts. 6 | * 7 | * @module Markers 8 | **/ 9 | 10 | class Markers { 11 | constructor (ctx, opts) { 12 | this.ctx = ctx 13 | this.w = ctx.w 14 | } 15 | 16 | plotChartMarkers (pointsPos, seriesIndex, j) { 17 | let w = this.w 18 | 19 | let p = pointsPos 20 | let elPointsWrap = null 21 | 22 | let graphics = new Graphics(this.ctx) 23 | 24 | let point 25 | 26 | if (w.config.markers.size > 0) { 27 | elPointsWrap = graphics.group({ 28 | class: 'apexcharts-series-markers' 29 | }) 30 | } 31 | 32 | if (p.x instanceof Array) { 33 | for (let q = 0; q < p.x.length; q++) { 34 | let realIndexP = j 35 | 36 | let PointClasses = 'apexcharts-marker' 37 | if (((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts) && !w.config.tooltip.intersect) { 38 | PointClasses += ' no-pointer-events' 39 | } 40 | 41 | if (w.config.markers.size > 0) { 42 | if (p.y[q] !== null) { 43 | PointClasses += ` w${(Math.random() + 1).toString(36).substring(4)}` 44 | } else { 45 | PointClasses = 'apexcharts-nullpoint' 46 | } 47 | 48 | let opts = this.getMarkerConfig(PointClasses, seriesIndex) 49 | w.config.markers.discrete.map((marker, mIndex) => { 50 | if (marker.i === seriesIndex && marker.j === realIndexP) { 51 | opts.pointStrokeColor = marker.strokeColor 52 | opts.pointFillColor = marker.fillColor 53 | opts.size = marker.size 54 | } 55 | }) 56 | 57 | point = graphics.drawMarker( 58 | p.x[q], 59 | p.y[q], 60 | opts 61 | ) 62 | 63 | // a small hack as we have 2 points for the first val to connect it 64 | if (j === 1 && q === 0) realIndexP = 0 65 | if (j === 1 && q === 1) realIndexP = 1 66 | 67 | point.attr('rel', realIndexP) 68 | point.attr('j', realIndexP) 69 | point.attr('index', seriesIndex) 70 | 71 | this.setSelectedPointFilter(point, seriesIndex, realIndexP) 72 | this.addEvents(point) 73 | 74 | elPointsWrap.add(point) 75 | } else { 76 | // dynamic array creation - multidimensional 77 | if (typeof (w.globals.pointsArray[seriesIndex]) === 'undefined') w.globals.pointsArray[seriesIndex] = [] 78 | 79 | w.globals.pointsArray[seriesIndex].push([p.x[q], p.y[q]]) 80 | } 81 | } 82 | } 83 | 84 | return elPointsWrap 85 | } 86 | 87 | getMarkerConfig (cssClass, seriesIndex) { 88 | const w = this.w 89 | let pStyle = this.getMarkerStyle(seriesIndex) 90 | 91 | const pSize = w.config.markers.size 92 | 93 | return { 94 | pSize: (pSize instanceof Array ? pSize[seriesIndex] : pSize), 95 | pRadius: w.config.markers.radius, 96 | pWidth: w.config.markers.strokeWidth, 97 | pointStrokeColor: pStyle.pointStrokeColor, 98 | pointFillColor: pStyle.pointFillColor, 99 | shape: (w.config.markers.shape instanceof Array ? w.config.markers.shape[seriesIndex] : w.config.markers.shape), 100 | class: cssClass, 101 | pointStrokeOpacity: w.config.markers.strokeOpacity, 102 | pointFillOpacity: w.config.markers.fillOpacity, 103 | seriesIndex 104 | } 105 | } 106 | 107 | addEvents (circle) { 108 | const graphics = new Graphics(this.ctx) 109 | circle.node.addEventListener( 110 | 'mouseenter', 111 | graphics.pathMouseEnter.bind(this.ctx, circle) 112 | ) 113 | circle.node.addEventListener( 114 | 'mouseleave', 115 | graphics.pathMouseLeave.bind(this.ctx, circle) 116 | ) 117 | 118 | circle.node.addEventListener( 119 | 'mousedown', 120 | graphics.pathMouseDown.bind(this.ctx, circle) 121 | ) 122 | 123 | circle.node.addEventListener( 124 | 'touchstart', 125 | graphics.pathMouseDown.bind(this.ctx, circle) 126 | ) 127 | } 128 | 129 | setSelectedPointFilter (circle, realIndex, realIndexP) { 130 | const w = this.w 131 | if (typeof w.globals.selectedDataPoints[realIndex] !== 'undefined') { 132 | if (w.globals.selectedDataPoints[realIndex].includes(realIndexP)) { 133 | circle.node.setAttribute('selected', true) 134 | let activeFilter = w.config.states.active.filter 135 | if (activeFilter !== 'none') { 136 | const filters = new Filters(this.ctx) 137 | filters.applyFilter(circle, activeFilter.type, activeFilter.value) 138 | } 139 | } 140 | } 141 | } 142 | 143 | getMarkerStyle (seriesIndex) { 144 | let w = this.w 145 | 146 | let colors = w.config.markers.colors 147 | 148 | let pointStrokeColor = w.config.markers.strokeColor 149 | let pointFillColor = (colors instanceof Array ? colors[seriesIndex] : colors) 150 | 151 | return { 152 | pointStrokeColor, pointFillColor 153 | } 154 | } 155 | } 156 | 157 | module.exports = Markers 158 | -------------------------------------------------------------------------------- /samples/heatmap/rounded.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Simple HeatMap 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /src/modules/Theme.js: -------------------------------------------------------------------------------- 1 | import Utils from '../utils/Utils' 2 | 3 | /** 4 | * ApexCharts Theme Class for setting the colors and palettes. 5 | * 6 | * @module Theme 7 | **/ 8 | 9 | class Theme { 10 | constructor (ctx) { 11 | this.ctx = ctx 12 | this.w = ctx.w 13 | this.colors = [] 14 | } 15 | 16 | init () { 17 | this.setDefaultColors() 18 | } 19 | 20 | setDefaultColors () { 21 | let w = this.w 22 | let utils = new Utils() 23 | 24 | if (w.config.colors === undefined) { 25 | w.config.colors = this.predefined() 26 | } 27 | 28 | const defaultColors = w.config.colors.slice() 29 | 30 | if (w.config.theme.monochrome.enabled) { 31 | let monoArr = [] 32 | let glsCnt = w.globals.series.length 33 | if (w.config.plotOptions.bar.distributed && w.config.chart.type === 'bar') { 34 | glsCnt = w.globals.series[0].length * w.globals.series.length 35 | } 36 | 37 | let mainColor = w.config.theme.monochrome.color 38 | let part = 1 / (glsCnt / w.config.theme.monochrome.shadeIntensity) 39 | let shade = w.config.theme.monochrome.shadeTo 40 | let percent = 0 41 | 42 | for (let gsl = 0; gsl < glsCnt; gsl++) { 43 | let newColor = mainColor 44 | 45 | if (shade === 'dark') { 46 | newColor = utils.shadeColor(percent * -1, mainColor) 47 | percent = percent + part 48 | } else { 49 | newColor = utils.shadeColor(percent, mainColor) 50 | percent = percent + part 51 | } 52 | 53 | monoArr.push(newColor) 54 | } 55 | w.config.colors = monoArr.slice() 56 | } 57 | 58 | // if user specfied less colors than no. of series, push the same colors again 59 | this.pushExtraColors(w.config.colors) 60 | 61 | // The Border colors 62 | if (w.config.stroke.colors === undefined) { 63 | w.config.stroke.colors = defaultColors 64 | } else { 65 | this.pushExtraColors(w.config.stroke.colors) 66 | } 67 | 68 | // The FILL colors 69 | if (w.config.fill.colors === undefined) { 70 | w.config.fill.colors = w.config.colors 71 | } else { 72 | this.pushExtraColors(w.config.fill.colors) 73 | } 74 | 75 | if (w.config.dataLabels.style.colors === undefined) { 76 | w.config.dataLabels.style.colors = defaultColors 77 | } else { 78 | this.pushExtraColors(w.config.dataLabels.style.colors) 79 | } 80 | 81 | // The point colors 82 | if (w.config.markers.colors === undefined) { 83 | w.config.markers.colors = defaultColors 84 | } else { 85 | this.pushExtraColors(w.config.markers.colors) 86 | } 87 | } 88 | 89 | // When the number of colors provided is less than the number of series, this method 90 | // will push same colors to the list 91 | // params: 92 | // distributed is only valid for distributed column/bar charts 93 | pushExtraColors (colorSeries, distributed = null) { 94 | let w = this.w 95 | 96 | let len = w.globals.series.length 97 | 98 | if (distributed === null) { 99 | distributed = w.config.chart.type === 'bar' && w.config.plotOptions.bar.distributed 100 | } else { 101 | distributed = false 102 | } 103 | 104 | if (distributed) { 105 | len = w.globals.series[0].length * w.globals.series.length 106 | } 107 | 108 | if (colorSeries.length < len) { 109 | let diff = len - colorSeries.length 110 | for (let i = 0; i < diff; i++) { 111 | colorSeries.push(colorSeries[i]) 112 | } 113 | } 114 | } 115 | 116 | predefined () { 117 | let palette = this.w.config.theme.palette 118 | // D6E3F8, FCEFEF, DCE0D9, A5978B, EDDDD4, D6E3F8, FEF5EF 119 | switch (palette) { 120 | case 'palette1': 121 | this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'] 122 | break 123 | case 'palette2': 124 | this.colors = ['#3f51b5', '#03a9f4', '#4caf50', '#f9ce1d', '#FF9800'] 125 | break 126 | case 'palette3': 127 | this.colors = ['#33b2df', '#546E7A', '#d4526e', '#13d8aa', '#A5978B'] 128 | break 129 | case 'palette4': 130 | this.colors = ['#546E7A', '#4ecdc4', '#c7f464', '#81D4FA', '#fd6a6a'] 131 | break 132 | case 'palette5': 133 | this.colors = ['#2b908f', '#f9a3a4', '#90ee7e', '#fa4443', '#69d2e7'] 134 | break 135 | case 'palette6': 136 | this.colors = ['#449DD1', '#F86624', '#EA3546', '#662E9B', '#C5D86D'] 137 | break 138 | case 'palette7': 139 | this.colors = ['#D7263D', '#1B998B', '#2E294E', '#F46036', '#C5D86D'] 140 | break 141 | case 'palette8': 142 | this.colors = ['#662E9B', '#F86624', '#F9C80E', '#EA3546', '#43BCCD'] 143 | break 144 | case 'palette9': 145 | this.colors = ['#5fba7d', '#f48024', '#8884d8', '#c34459', '#f9ee45'] 146 | break 147 | case 'palette10': 148 | this.colors = ['#5C4742', '#A5978B', '#8D5B4C', '#5A2A27', '#C4BBAF'] 149 | break 150 | case 'palette11': 151 | this.colors = ['#A300D6', '#7D02EB', '#5653FE', '#2983FF', '#00B1F2'] 152 | break 153 | default: 154 | this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'] 155 | break 156 | } 157 | return this.colors 158 | } 159 | } 160 | 161 | module.exports = Theme 162 | -------------------------------------------------------------------------------- /samples/area/area-github-style.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Syncing charts 10 | 11 | 12 | 13 | 14 | 55 | 56 | 57 | 58 |
59 |
60 | 61 |
62 |
63 | 65 |
66 | coder 67 | 68 | commits 69 | 70 |
71 |
72 | 73 |
74 | 75 |
76 |
77 | 78 | 79 | 80 | 81 | 82 | 83 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /samples/area/area-datetime.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Area Chart - Datetime X-Axis 9 | 10 | 11 | 12 | 13 | 43 | 44 | 45 | 46 | 47 |
48 |
49 | 50 | 51 | 52 | 53 | 54 |
55 |
56 |
57 | 58 | 59 | 60 | 61 | 62 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /samples/heatmap/color-range.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Range HeatMap 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 174 | 175 | 176 | --------------------------------------------------------------------------------