I am using the latest version of highstock.js (v5.0.14) and my custom styles (using CSS) are being usurped by inline fill attributes.
For example, this CSS:
.highcharts-color-0 {
fill: #2b908f;
stroke: #2b908f;
}
Is being overwritten by this HTML attribute:
<path fill="rgba(124,181,236,0.75)" ... />
I am looking to disable the fill attribute. Using !important does not work.
This problem came after I upgraded to v5.0.14 (previously using v5.0.9 where the "fill" attribute was not in use)
A more effective and durable way to change the default colors Highstock uses is by calling the function Highcharts.setOptions() (see http://api.highcharts.com/highstock/Highcharts.setOptions) and defining the colors there.
For example, you could do define your own colors as follows:
Highcharts.setOptions({
colors: [
'blue', /* first color chosen */
'red', /* second color chosen */
'#2b908f' /* third color chosen */
]
});
In this code, colors is an array of values.
Highstock will cycle through this array and use them for each series that is drawn on the chart. Using this example, the first series will plot with a fill color of blue, the second with red, and the third with the hex value #2b908f.
Place this code before you define your chart options so that it will inherit what you set.
I hope this helps!
Related
In Vaadin 14, I'm trying to determine how to change the graph's line style from solid to dashed? (I need to do this programatically.) At first, it seemed trivial (based on https://vaadin.com/blog/styling-your-vaadin-charts), but I do not see API for either color setting (eg
PlotOptionsLine redBirdOptions = new PlotOptionsLine();
redBirdOptions.setColor(new SolidColor("#d62031"));
) or dash-style setting available in Vaadin 14. Anyone have examples on how one can programmatically set the dash style (and color) of series in a Vaadin 14 line graph?
Disclaimer: There is no way to do it Java only. You would need to style chart using CSS. Though, the color can be changed via styles settings in Java like shown here Treemap custom colors, I will follow the CSS approach below
The documentation you are referring to is for Vaadin 8, which uses another version of the highcharts library. In Vaadin 14, you need to configure settings via css. There is no example especially for your use case, but you can find in the links below all the needed info :
CSS file configuration and correct import annotation CSS Styling
Class names that can be used to style charts Highcharts API
The color is set using .highcharts-color-{n} class (or the --vaadin-charts-color-{n} property, which is preferred here), where n can be defined for options on Java side like this : plotOptions.setColorIndex(2);. A highchart example for colors can be found here : CSS Colors
For dashed css you could check this : CSS dashstyle.
Overall, this should do the trick:
Create a chartStyles.css file
Put the content below there :
:host {
--vaadin-charts-color-2: red;
}
.highcharts-series-0 {
stroke-dasharray: 1, 3;
}
Import the style using :
#CssImport(value = "./styles/chartStyles.css", themeFor = "vaadin-chart", include = "vaadin-chart-default-theme")
Plot options have colorIndex of 2 (as this is the value in css we are referring to):
PlotOptionsAreasplinerange range=new PlotOptionsAreasplinerange();
range.setColorIndex(2);
dataSeries.setPlotOptions(range);
After that the chart color should change. You can skip the index assignment and use --vaadin-charts-color-0, if you have only one chart on the page. If not, I would suggest to add theme names to the chart and adjust css file to use them. This way you would ensure that only the chart you want is affected.
How to change color of mat-spinner
i tried this but doesn't work
Html
<mat-spinner [color]="red" ></mat-spinner>
<mat-spinner [color]="#ffffff" ></mat-spinner>
This code worked for me :
scss
.mat-spinner-color::ng-deep circle{
stroke: #FFFFFF !important;
}
html
<mat-spinner [diameter]="25" class="mat-spinner-color"></mat-spinner>
The color property only accepts the values primary, accent and warning. These are colors that correspond to the Material Design theme used in your project.
<mat-spinner color="primary"></mat-spinner>
If you want to override this with a custom color add the following css:
.mat-progress-spinner circle, .mat-spinner circle {
stroke: /* color */
}
EDIT
Place the styles in the global style sheet, view encapsulation prevents the styles from working when placed in a component style sheet.
The color input accepts three values:
primary: The primary palette of your app
warn: The warn palette of your app
accent: The accent palette of your app
To use hex codes, you can only do it with CSS. I suggest you use the Chrome DevTools to see which CSS classes to target. Note that you should use the !important selector as well.
I am converting all the charts in an application to Highcharts 5.x styled mode.
I cannot find how to make the solidgauge stops work in styled mode. When I inspect the SVG, I do not see any class for the colors.
I couldn't find any solidgauge stops example with styled mode.
Anyone can post a working example?
In a solid gauge series color is calculated dynamically based on stop values - currently, I do not think you can do the same with only css. The point fill atribute is calculated and set correctly but in this case css class takes precedence and the point's color has a fixed fill taken from the css file (highcharts-color-{n} class).
Keep stops in options and remove class from the point (or set colorIndex to a non existing number, e.g. 99)
.highcharts-color-0 {
fill: #7cb5ec; //remove fill attribute
stroke: #7cb5ec;
}
or:
data: [{y: 80, colorIndex: 99}], // the point's class will highcharts-color-99 now
example: http://jsfiddle.net/gj8zfw73/
I've got a toolbar with a custom theme and I'm trying to figure out where it's picking up the contrast colour for the <md-icon> fill. Everything I've tried so far results in white icons on my custom blue toolbar.
Looking through the Material code, I found that the value is being filled in with {{primary-contrast}} but I can't find where that's being set.
Where should I look to configure the primary-contrast value for my palette?
md-toolbar.md-THEME_NAME-theme:not(.md-menu-toolbar) md-icon {
color: '{{primary-contrast}}'; fill: '{{primary-contrast}}';
}
My palette:
$mdThemingProvider.definePalette('myBlue', {
'50': 'e3e4e7',
'100': 'b9bcc3',
'200': '8b8f9b',
'300': '5c6272',
'400': '394154',
'500': '161f36',
'600': '131b30',
'700': '101729',
'800': '0c1222',
'900': '060a16',
'A100': 'b9bcc3',
'A200': '8b8f9b',
'A400': '394154',
'A700': '101729',
'contrastDefaultColor': 'light'
});
My theme:
$mdThemingProvider.theme('myMenu')
.primaryPalette('myBlue')
.backgroundPalette('myBlue')
.dark();
Primary contrast colors are fixed as black and white at 0.7 opacity. As far as I know you cannot change these. You can however inject your own custom css and get color values replaced by the theme.
https://material.angularjs.org/latest/api/service/$mdThemingProvider#custom-theme-styles
I'm trying to set the background of highchart as Dotted line instead of default Grid .Please help me to set the options to set Dot .
The option you need is probably:
yAxis: {
gridLineDashStyle: 'longdash',
You can use the same option in the xAxis block to format the vertical lines. You can also specify different dash styles. The documentation is here:
http://api.highcharts.com/highcharts#yAxis.gridLineDashStyle
The dash style options are demonstrated here:
http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/